Converting transparent PNG
Converting transparent PNG
Hi, I'm trying to convert a PNG with transparency, but if I add vignette I have my transparency replaced with black.
Is it possible to replace with white
I tried:
convert agrate_brianza.png -background transparent -transparent-color white -gravity Center -crop 150.0x150.0+0+0 -resize '136.0' -opaque white -fill white -transparent white -vignette 1x1+2+2 agg3.png
But didn't work.
Thanks in advance
Is it possible to replace with white
I tried:
convert agrate_brianza.png -background transparent -transparent-color white -gravity Center -crop 150.0x150.0+0+0 -resize '136.0' -opaque white -fill white -transparent white -vignette 1x1+2+2 agg3.png
But didn't work.
Thanks in advance
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Converting transparent PNG
post a link to your image. also explain what you want to happen with the transparency. it is hard to know what you are trying to do without seeing your image and your bad result and know what you want for a good result. also let us know what version of IM and platform you are using.
you certainly have too many combinations of -fill, -opaque, -transparent (and often in the wrong order) and -transparent color will do nothing.
If I understand, then try
convert image -crop ... -resize ... -alpha off -vignette ... -alpha on resultimage
you certainly have too many combinations of -fill, -opaque, -transparent (and often in the wrong order) and -transparent color will do nothing.
If I understand, then try
convert image -crop ... -resize ... -alpha off -vignette ... -alpha on resultimage
Re: Converting transparent PNG
Hi,
Thanks for replying, so this is the pic in question:
http://dl.dropbox.com/u/1069056/agrate_brianza.png
And this is the command line:
convert agrate_brianza.png -background transparent -transparent-color white -gravity Center -crop 150.0x150.0+0+0 -resize '136.0' -opaque white -fill white -transparent white -vignette 1x1+2+2 agg3.png
Thanks for any tips on that.
Bye
Thanks for replying, so this is the pic in question:
http://dl.dropbox.com/u/1069056/agrate_brianza.png
And this is the command line:
convert agrate_brianza.png -background transparent -transparent-color white -gravity Center -crop 150.0x150.0+0+0 -resize '136.0' -opaque white -fill white -transparent white -vignette 1x1+2+2 agg3.png
Thanks for any tips on that.
Bye
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Converting transparent PNG
Both these work for me:
First line: crop and resize your image
Second line: clone the result and extract the alpha channel
Third line: clone the alpha channel, colorize with black then draw a white circle
Fourth line: take the previous two (alpha channel) images and multiply them
Fifth line: put the multiplied alpha channel back into your cropped and resized image.
convert \( agrate_brianza.png -gravity Center -crop 150x150+0+0 -resize '136' \) \
\( +clone -alpha extract \) \
\( +clone -fill black -colorize 100% -fill white -draw "circle 68,68 68,136" \) \
\( -clone 1 -clone 2 -compose multiply -composite \) \
-delete 1,2 -alpha off -compose copy_opacity -composite agrate_brianza1.png
Same as above, but use vignette rather than drawing a circle
convert \( agrate_brianza.png -gravity Center -crop 150x150+0+0 -resize '136' \) \
\( +clone -alpha extract \) \
\( +clone -fill white -colorize 100% -background black -vignette 1x1+2+2 \) \
\( -clone 1 -clone 2 -compose multiply -composite \) \
-delete 1,2 -alpha off -compose copy_opacity -composite agrate_brianza2.png
First line: crop and resize your image
Second line: clone the result and extract the alpha channel
Third line: clone the alpha channel, colorize with black then draw a white circle
Fourth line: take the previous two (alpha channel) images and multiply them
Fifth line: put the multiplied alpha channel back into your cropped and resized image.
convert \( agrate_brianza.png -gravity Center -crop 150x150+0+0 -resize '136' \) \
\( +clone -alpha extract \) \
\( +clone -fill black -colorize 100% -fill white -draw "circle 68,68 68,136" \) \
\( -clone 1 -clone 2 -compose multiply -composite \) \
-delete 1,2 -alpha off -compose copy_opacity -composite agrate_brianza1.png
Same as above, but use vignette rather than drawing a circle
convert \( agrate_brianza.png -gravity Center -crop 150x150+0+0 -resize '136' \) \
\( +clone -alpha extract \) \
\( +clone -fill white -colorize 100% -background black -vignette 1x1+2+2 \) \
\( -clone 1 -clone 2 -compose multiply -composite \) \
-delete 1,2 -alpha off -compose copy_opacity -composite agrate_brianza2.png
Re: Converting transparent PNG
that works for me too! Thank you very much.
Re: Converting transparent PNG
I tried again, but the pic I get has transparent background while I want to have it white. Is it possible? Thanks
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Converting transparent PNG
add -compose over -background white -flatten just before your output image. see if that gets you what you want.
I will try to give you a shorter version later today.
I will try to give you a shorter version later today.
Re: Converting transparent PNG
Thanks for replying
I did:
convert \( agrate_brianza.png -gravity Center -crop 150x150+0+0 -resize '136' \) \( +clone -alpha extract \) \( +clone -fill black -colorize 100% -fill white -draw "circle 68,68 68,136" \) \( -clone 1 -clone 2 -compose multiply -composite \) -delete 1,2 -alpha off -compose copy_opacity -composite -compose over -background white -flatten agrate_brianza89.png
but the resulting image is no longer a circle
I did:
convert \( agrate_brianza.png -gravity Center -crop 150x150+0+0 -resize '136' \) \( +clone -alpha extract \) \( +clone -fill black -colorize 100% -fill white -draw "circle 68,68 68,136" \) \( -clone 1 -clone 2 -compose multiply -composite \) -delete 1,2 -alpha off -compose copy_opacity -composite -compose over -background white -flatten agrate_brianza89.png
but the resulting image is no longer a circle
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Converting transparent PNG
what color do you want outside the circle and what color inside the circle?
Re: Converting transparent PNG
It Should be white inside and tranparent outside (I mean it's the transparency that makes the pic looks circular)
Thanks
Thanks
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Converting transparent PNG
Try this. If that is not what you want, then let me know further.
convert \( agrate_brianza.png -gravity Center -crop 150x150+0+0 +repage \
-resize 136 -background white -flatten \) \
\( +clone -fill black -colorize 100% -fill white -draw "circle 68,68 68,136" \) \
-alpha off -compose copy_opacity -composite agrate_brianza4.png
The +repage is needed to remove the virtual canvas so that the canvas size is the same as the image size at 150x150 so that your resize will end up 136x136 without distortion.
The -background white -flatten makes the background white. Then the circle mask the outside as transparent when put into the alpha channel.
convert \( agrate_brianza.png -gravity Center -crop 150x150+0+0 +repage \
-resize 136 -background white -flatten \) \
\( +clone -fill black -colorize 100% -fill white -draw "circle 68,68 68,136" \) \
-alpha off -compose copy_opacity -composite agrate_brianza4.png
The +repage is needed to remove the virtual canvas so that the canvas size is the same as the image size at 150x150 so that your resize will end up 136x136 without distortion.
The -background white -flatten makes the background white. Then the circle mask the outside as transparent when put into the alpha channel.