The following command will resize all the .jpg images in the current directory, maintaining aspect ratio, and making the longest side 640 pixels.
sips -Z 640 *.jpg