Page 1 of 1
png to gif - Transparency
Posted: 2016-08-27T09:30:44-07:00
by agriz
Code: Select all
convert a.png -background LightSteelBlue -flatten a_overlay.gif
This was the example code which i found in imagemagick website.
Without using this -background LightsteelBlue, can't we achieve this effect?
Re: png to gif - Transparency
Posted: 2016-08-27T09:42:25-07:00
by GeeMack
agriz wrote:This was the example code which i found in imagemagick website.
Without using this -background LightsteelBlue, can't we achieve this effect?
Not quite sure what you're trying to do there, but with IM you can always use "none" as a color descriptor. That often works when you want transparent backgrounds, borders, etc. Maybe try "-background none".
Re: png to gif - Transparency
Posted: 2016-08-27T10:10:52-07:00
by fmw42
agriz wrote:Code: Select all
convert a.png -background LightSteelBlue -flatten a_overlay.gif
This was the example code which i found in imagemagick website.
Without using this -background LightsteelBlue, can't we achieve this effect?
Please always provide your IM version and platform. Also an example of your input and your resulting output and explain why the command is not working the way you want. A pointer to where you found this code would also be helpful.
Please read the top-most post in this forum at viewtopic.php?f=1&t=9620.
Re: png to gif - Transparency
Posted: 2016-08-27T11:58:34-07:00
by fmw42
PNG only has one layer. So if it has transparency, then I see no need for the background or flatten, unless you want to remove the transparency. So if you want to keep the transparency, then just do
If you want to replace the transparency with some color, then you can do
Code: Select all
convert image.png -background skyblue -flatten image.gif
or
Code: Select all
convert image.png -background skyblue -alpha remove -alpha off image.gif
Re: png to gif - Transparency
Posted: 2016-08-27T20:05:54-07:00
by agriz
It is not working sir
ImageMagick-6.7.8.9-13
Re: png to gif - Transparency
Posted: 2016-08-27T20:09:02-07:00
by agriz
Code: Select all
convert -size 70x60 xc:none -font Candice -pointsize 50 \
-fill black -annotate +10+45 'A' -channel RGBA -blur 0x5 \
-fill white -stroke black -draw "text 5,40 'A'" a.gif
Code: Select all
convert -size 70x60 xc:none -font Candice -pointsize 50 \
-fill black -annotate +10+45 'A' -channel RGBA -blur 0x5 \
-fill white -stroke black -draw "text 5,40 'A'" a.png
Re: png to gif - Transparency
Posted: 2016-08-27T20:13:08-07:00
by fmw42
PNG supports 8-bit transparency. But GIF only supports binary transparency. So your PNG shadow will be thresholded at about 50% when saving as GIF and you will get either fully transparent part shadow and full opaque part shadow. Since your transparency is black underneath the opaque part shows as black.
Re: png to gif - Transparency
Posted: 2016-08-27T20:20:31-07:00
by agriz
Is there no way to use png to generate animated gif? When i use few layers of a.png with shadow, it becomes like the above image.
Re: png to gif - Transparency
Posted: 2016-08-27T21:15:05-07:00
by fmw42
No way if you keep transparency with smooth shadow. If you flatten transparent png images against some background color such as white, then the gifs will be fine.
Re: png to gif - Transparency
Posted: 2016-08-28T02:08:38-07:00
by agriz
If i use imagemagick 7.0, and if i create gif by appending few jpg images, i get the right image size
If i use imagemagick 6.7 and if i create gif by appending the same jpg images, i get the wrong image size.
Sir, if i use identify -verbose info: image.gif
//if created in 6.7 - Should be about 300
[4] => Geometry: 29x490+0+0
Is there a chance that i can change the image width and height in the image information?
So when i use php's getimagesize($image) i will get the right image size.
Re: png to gif - Transparency
Posted: 2016-08-28T11:54:33-07:00
by fmw42
Please don't change topics within a post. Please create a new post in the future. IM 6.7 is ancient (over 200 versions old) and might have a bug. No way to go back to fix the bug in IM 6.7. You might be able to use EXIFTOOL to make changes to the meta data if you need to correct the image. But if IM 7 works fine, then there must have been a bug in IM 6.7.
Re: png to gif - Transparency
Posted: 2016-08-28T18:48:13-07:00
by agriz
Ok sir. I updated to IM 7. It is working good.