ImageMagick will do it with a bit of prodding, and it has win32 and *nix binaries.
I've not got any binaries on this PC so I can't test, but I'm fairly sure this will work:
Code:
convert big.jpg -resize 400x300 -background black -mavity center -extent 400x300 small.jpg
(Resize to maximum dimensions of 400x300, maintaining aspect ratio; set the background to black; put the image in the center; extend the "canvas" to 400x300. Replace big.jpg and small.jpg with the original file and the desired output file.)
OK, I've been playing around with this...
What I've notice while generating thumbnails is give the following two examples in VB:-
ImageMagick.Convert(public_txtSourcePath + FileName, "-resize", "400x300", "-quality", "50", public_txtThumbPath + FileName)
ImageMagick.Convert(public_txtSourcePath + FileName, "-thumbnail", "400x300", "-quality", "50", public_txtThumbPath + FileName)
In one particular case the -resize gives an image of 72KB, where as the -thumb gives a far image size of 8K, with the images looking the same.
So obviously the -thumb is ideal! However, the -thumb doesn't seem to like the -extent coding.
So this works:-
ImageMagick.Convert(public_txtSourcePath + FileName, "-resize", "400x300", "-background", "black", "-mavity", "center", "-extent", "400x300", "-quality", "50", public_txtThumbPath + FileName)
But this does not:-
ImageMagick.Convert(public_txtSourcePath + FileName, "-thumbnail", "400x300", "-background", "black", "-mavity", "center", "-extent", "400x300", "-quality", "50", public_txtThumbPath + FileName)
Have you got any idea how either:-
1) To get the -extent coing to work with the -thumbnail request?
2) How to get a -resize to produce images as small/efficient as the -thumb?
Thanks!
EDIT: -strip does the trick with the -resize option. It makes the difference between a 72K image, or an 8K image!!