ImageMagick 6.3.2 with the MagickWand-API and I had troubles to convert and resize a partially transparent png to an jpg-file.
I tried the command line tools and the same things happend.
convert png.png png.jpg
–> a jpg-file is created and the transparent area is white
convert png.png -resize 500×400 png_small.jpg
–> a jpg-file in the right dimension is generated and the transparent area is black
What settings do i have to set if i want transparent areas always to be white?
First you will loss all transparent in JPG. It just don’t understand it. As such whatever the transparent color in the image is, is what it uses. Your original used fully-transparent white (typical of PNG). However resize knows transparent is invisible, and as it is easier mathematically, it just makes all transparent colors, ‘none’ or fully transparent black.
It is just the way things happen.
Second, and no disrespect to ‘el_supremo’, your solution is fine, but there is a better way, to replace the transparent colors with a specific background, and is actually the same operation. -flatten the image. IM creates the right sized canvas and uses the default ‘over’ composition to overlay the image onto it. Just the one image.
convert png.png -resize 500x400 -background white -flatten png_small.jpg
See: http://www.cit.gu.edu.au/~anthony/graph … s/#flatten
There are also otherways to do this , including adding a zero width border!
ASIDE: el_supremo may also have forgotting that resize may not produce the size requested as it preserves the aspect ratio. If you catually what a final image that is exactly that size ‘pad out’ the image as pure the IM example thumbnail section.