OSX images batch resizing using Terminal

One reason because I like to use OSX is its propension for “command line” (like other unix-like os) without renouncing to a beautiful GUI.
If you want to resize (and not only) several images with a single command then you can use sips.
Open terminal (in a folder with images JPG) and try to type :

sips -Z 1014 *.jpg --out /tmp
all files with extension jpg will be resampled with height = 1024 pixels and result files are placed in /tmp.
about sips Click-Here

#1 Bonus (extract thumbnails)

When I found this command I was looking for a script that could help me to find all files images (not based on extensions) in order to extract a thumbnails.
This because on a my old disk I have files with name like a0001 (without extension) that are images together to files with name like a0002 that are documents (without extension).
 WARNING : below command is potentially dangerous

Extract thumbnails from files identified as images :

find . -exec file {} ; | grep -i image | cut -d ":" -f 1 | xargs -I % sips -Z 124 "%" --out /tmp

Where :
 find  searchs all files and foreach of them is executed the command “file <filename>”
 file   is a command which reports type of file

Example of command file (lanternoff.jpg is an image ):

file lanternoff.jpg
lanternoff.jpg: JPEG image data, EXIF standard 

 grep … really ?
 cut uses as delimeter : ( -d “:” ) and get the first field ( -f 1 ) in order to extract only file name
 xargs get from stdin strings and uses them as arguments in order to execute sips

Know bugs :
 file collision :  directory is always /tmp for all images so names collisions are quite probable
 find and xargsfile name found by the command find could contain delimiting characters used by xargs (-print0 & -0 optionts ?).