OS X doesn't come with a shell command for this. But you have three options.
OS X does come with a way to do this in Applescript: Image Events. You could write a three-liner in Applescript—or Python or Ruby with appscript or ScriptingBridge—that does what you want, and then run that from the shell.
OS X also has some pretty high-level image support built into Cocoa, which you can access from Python, Ruby, ObjC, Applescript, etc., so you could write a five-liner that way that does what you want.
Or you could use a third-party tool that gives you what you want. ImageMagick, as suggested by user4815162342, is probably the best one.
(I wouldn't even mention the first two possibilities if you posted on SU rather than SO.)