Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

CoreImageTool - process images with Apple's CoreImage framework

In addition to command line tools such as man sips, ImageMagick or GIMP (batch mode) there's CoreImageTool to edit images from the command line using Apple's CoreImage framework (Mac OS X 10.4 and Mac OS X 10.5).

# download & install CoreImageTool

# create /usr/local/bin
/usr/bin/sudo /bin/mkdir -p /usr/local/bin
/usr/bin/sudo /usr/sbin/chown root:wheel /usr/local /usr/local/bin
/usr/bin/sudo /bin/chmod 0755 /usr/local /usr/local/bin

cd ~/Desktop
/usr/bin/curl -L -O http://www2.entropy.ch/download/CoreImageTool
/usr/bin/sudo /bin/mv -i ~/Desktop/CoreImageTool /usr/local/bin

/usr/bin/sudo /usr/sbin/chown root:wheel /usr/local/bin/CoreImageTool
/usr/bin/sudo /bin/chmod 755 /usr/local/bin/CoreImageTool

ls -l /usr/local/bin/CoreImageTool


/bin/mkdir -p ~/Desktop/CoreImageDir
/bin/cp /Library/Desktop\ Pictures/Nature/Ladybug.jpg ~/Desktop/CoreImageDir

chmod 0777 ~/Desktop/CoreImageDir/Ladybug.jpg
ls -l ~/Desktop/CoreImageDir/Ladybug.jpg

cd ~/Desktop/CoreImageDir


# process Ladybug.jpg

# convert .jpg to .png
CoreImageTool load pic Ladybug.jpg store pic Ladybug.png public.png

CoreImageTool \
   load pic Ladybug.jpg \
   store pic Ladybug.png public.png

open -a Preview Ladybug.jpg
open -a Preview Ladybug.png

CoreImageTool load pic Ladybug.jpg filter pic CILanczosScaleTransform scale=0.5 store pic Ladybug2.jpg public.jpeg
open -a Preview Ladybug2.jpg

CoreImageTool load pic Ladybug.jpg filter pic CILanczosScaleTransform scale=0.1 store pic Ladybug3.jpg public.jpeg
open -a Preview Ladybug3.jpg

CoreImageTool load pic Ladybug.jpg filter pic CICrystallize radius=6.0 store pic Ladybug4.jpg public.jpeg
CoreImageTool load pic Ladybug.jpg filter pic CICrystallize radius=12.0 store pic Ladybug4.jpg public.jpeg
open -a Preview Ladybug4.jpg

CoreImageTool load pic Ladybug.jpg filter pic CICrop rectangle=250,250,800,800 store pic Ladybug5.jpg public.jpeg
open -a Preview Ladybug5.jpg

# sharpen image
CoreImageTool load pic Ladybug.jpg filter pic CISharpenLuminance sharpness=3 store pic Ladybug6.jpg public.jpeg
open -a Preview Ladybug6.jpg

CoreImageTool load pic Ladybug.jpg filter pic CIUnsharpMask radius=1.0:intensity=2.0 store pic Ladybug7.jpg public.jpeg
open -a Preview Ladybug7.jpg


Further information:

- CoreImageTool
- Apple's CoreImage power in the Terminal
- Apple Core Image Filter Reference
- Developing with Core Image