Page 1 of 1
Re: Resizing PNG removes the opacity/transparency
Posted: 2008-07-16T10:02:08-07:00
by fmw42
This works just fine for me on IM 6.4.2-2
convert logo: -transparent white logo_trans.png
convert logo_trans.png -resize 50% logo_trans_50.png
Re: Resizing PNG removes the opacity/transparency
Posted: 2008-07-16T16:20:47-07:00
by anthony
What format did you write it in? As you mentioned GIF you are obviously writing in other formats as well as PNG.
JPEG does not support transparency, and is lossy (not exact colors)
GIF only supports boolean transparency, and a small number of colors.
See
IM examples, Common Image Formats for more details of all three image file formats.
Re: Resizing PNG removes the opacity/transparency
Posted: 2009-10-26T13:37:29-07:00
by roach
I'm having the same problem described in the Title. It looks as though this thread has rotted away (some posts are missing?)
Anyways, I need to take an existing "watermark" image (PNG file, with Transparency), resize it to an appropriate dimension for the "target" image (the image I'm trying to watermark), then composite it over the target image, and save to an output file.
Step 1, Resize the watermark (.PNG overlay) file:
Code: Select all
convert watermark.png -resize 640x480^ -gravity center -extent 640x480 watermark_temp.png
[code]
Step 2, apply the watermark to the target image:
[code]
composite -gravity center watermark_temp.png inputfile.jpg outputfile.jpg
[code]
Seems to work, but watermark_temp.png has all of it's transparency converted to plain white, so the outputfile.jpg image basically looks like a watermark, on a white background.
I'm using ImageMagick 6.5.6-Q16 on Windows 7, via the OLE object.
Anyone have any ideas?
Re: Resizing PNG removes the opacity/transparency
Posted: 2009-10-26T14:38:56-07:00
by Bonzo
Try:
Code: Select all
convert inputfile.jpg ( watermark.png -resize 640x480^ ) -gravity center -composite over -matte outputfile.jpg
Re: Resizing PNG removes the opacity/transparency
Posted: 2009-10-26T15:12:52-07:00
by fmw42
try enabling the alpha channel as follows on your watermark image
convert inputfile.jpg \( watermark.png -channel rgba -alpha on -resize '640x480^' \) -gravity center -composite over outputfile.jpg
you can use -matte rather than -alpha on if your system is too old.
if on windows see
http://www.imagemagick.org/Usage/windows/
Re: Resizing PNG removes the opacity/transparency
Posted: 2009-10-26T17:02:27-07:00
by roach
Thanks Bonzo! Turns out removing the "-extent 640x480" was the key. Something about the "extent" was removing the alpha channel. Since I didn't need it, I took it out, and everything works fine now.
thanks!