animated gif colours
animated gif colours
i have successfully created an animated gif from these png images
convert -dispose previous -delay 200 -loop 0 w*.png w.anim.gif
i wanted to reduce the size of the final gif file so i created the png with a transparent background
convert -dispose previous -delay 200 -loop 0 w*.png w.anim.gif
convert backgroundGrid.png backgroundGrid.gif
convert backgroundGrid.gif w.anim.gif -loop 0 w.anim.gif
as you can see the colours are not correct
what am i doing wrong?
i think it is something to do with the palette but am not sure what
the first image into the pipeline should set the palette i guess or it is using some default palette but i don't understand how the first one works but not the second
i have tried converting the png to gif before making the animated gif and also tried a background.png but neither of these give a result similar to the first
TIA
Zeus
convert -dispose previous -delay 200 -loop 0 w*.png w.anim.gif
i wanted to reduce the size of the final gif file so i created the png with a transparent background
convert -dispose previous -delay 200 -loop 0 w*.png w.anim.gif
convert backgroundGrid.png backgroundGrid.gif
convert backgroundGrid.gif w.anim.gif -loop 0 w.anim.gif
as you can see the colours are not correct
what am i doing wrong?
i think it is something to do with the palette but am not sure what
the first image into the pipeline should set the palette i guess or it is using some default palette but i don't understand how the first one works but not the second
i have tried converting the png to gif before making the animated gif and also tried a background.png but neither of these give a result similar to the first
TIA
Zeus
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: animated gif colours
gif images only hold 256 colors (including one assigned to transparency). I suspect, if each of your images contain different 256 colors, then your animation will have too many colors and the colors will get changed. So you may need to convert each image to a common set of colors (palette) using -remap or -map before making the animation. However, as I am not an animation expert, I will defer to Anthony or others who know more about this than I.
see
http://www.imagemagick.org/Usage/anim_basics/
http://www.imagemagick.org/Usage/anim_opt/
http://www.imagemagick.org/Usage/anim_mods/
http://www.imagemagick.org/Usage/quantize/#remap (but use +dither to turn off dithering)
see
http://www.imagemagick.org/Usage/anim_basics/
http://www.imagemagick.org/Usage/anim_opt/
http://www.imagemagick.org/Usage/anim_mods/
http://www.imagemagick.org/Usage/quantize/#remap (but use +dither to turn off dithering)
Re: animated gif colours
i read all of those
that is where i got the bit about putting the background in last and making the others transparent
my images have 19 colours + transparent + black(for the background) + grey(for the lines)
they are created using setpixel on a 1000x1000 canvas with no effects or aliasing
that is why i am puzzled
the first one is converted to the animated gif keeping all of the colours ok
the second one with the transparent background doesn't
as you can see in the transparent pics i posted the colours are fine
they look fine even when i convert them all to gif and then use gifs to make the animated gif but the result is still wrong
here are the colours i am using in these pics
█
█
█
█
█
█
█
█
█
█
█
█
█
█
█
█
█
█
█
[ color=#D786D7]█[/color]
[ color=#00FF00]█[/color]
[ color=#6B43FF]█[/color]
[ color=#2FCC16]█[/color]
[ color=#CCD566]█[/color]
[ color=#33FF33]█[/color]
[ color=#4E4DFF]█[/color]
[ color=#00B800]█[/color]
[ color=#9C9C9C]█[/color]
[ color=#0000FF]█[/color]
[ color=#22FF22]█[/color]
[ color=#79C7C7]█[/color]
[ color=#33FF33]█[/color]
[ color=#0080CC]█[/color]
[ color=#220067]█[/color]
[ color=#FF0000]█[/color]
[ color=#FFAACC]█[/color]
[ color=#EEEEEE]█[/color]
[ color=#33FF33]█[/color]
that is where i got the bit about putting the background in last and making the others transparent
my images have 19 colours + transparent + black(for the background) + grey(for the lines)
they are created using setpixel on a 1000x1000 canvas with no effects or aliasing
that is why i am puzzled
the first one is converted to the animated gif keeping all of the colours ok
the second one with the transparent background doesn't
as you can see in the transparent pics i posted the colours are fine
they look fine even when i convert them all to gif and then use gifs to make the animated gif but the result is still wrong
here are the colours i am using in these pics
█
█
█
█
█
█
█
█
█
█
█
█
█
█
█
█
█
█
█
[ color=#D786D7]█[/color]
[ color=#00FF00]█[/color]
[ color=#6B43FF]█[/color]
[ color=#2FCC16]█[/color]
[ color=#CCD566]█[/color]
[ color=#33FF33]█[/color]
[ color=#4E4DFF]█[/color]
[ color=#00B800]█[/color]
[ color=#9C9C9C]█[/color]
[ color=#0000FF]█[/color]
[ color=#22FF22]█[/color]
[ color=#79C7C7]█[/color]
[ color=#33FF33]█[/color]
[ color=#0080CC]█[/color]
[ color=#220067]█[/color]
[ color=#FF0000]█[/color]
[ color=#FFAACC]█[/color]
[ color=#EEEEEE]█[/color]
[ color=#33FF33]█[/color]
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: animated gif colours
are the lines and numbers anti-aliased so that you get many gray values?
Re: animated gif colours
the lines aren't but upon closer inspection
so i did a
convert backgroundGrid.gif -colorspace Gray backgroundGrid2.gif
then
convert -dispose previous -delay 200 -loop 0 w*.png w.anim.gif
convert backgroundGrid2.gif w.anim.gif -loop 0 w.anim.gif
but still got the same wrong result
i thought we might be on the right track for a second
so i did a
convert backgroundGrid.gif -colorspace Gray backgroundGrid2.gif
then
convert -dispose previous -delay 200 -loop 0 w*.png w.anim.gif
convert backgroundGrid2.gif w.anim.gif -loop 0 w.anim.gif
but still got the same wrong result
i thought we might be on the right track for a second
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: animated gif colours
colorspace gray may still have many gray shades which add to the 256 color limit.
Does it work properly without the background grid and numbers? If so, then it is the background grid and numbers. If not, then you may still have too many colors coming from all the images.
Does it work properly without the background grid and numbers? If so, then it is the background grid and numbers. If not, then you may still have too many colors coming from all the images.
Re: animated gif colours
well i tried a
convert backgroundGrid.gif -monochrome backgroundGrid2.gif
thinking i would get only black and white
not perfect but worth a test
however i got a pure black image (i guess the grey was less than 50%)
and i tried that as the background
convert -dispose previous -delay 200 -loop 0 w*.png w.anim.gif
convert backgroundGrid2.gif w.anim.gif -loop 0 w.anim.gif
still got the wrong result
just to be sure i created a pure black background with IM
convert -size 1000x1000 xc:black black.gif
and then
convert -dispose previous -delay 200 -loop 0 w*.png w.anim.gif
convert black.gif w.anim.gif -loop 0 w.anim.gif
and still got the same wrong result
so the background isn't the problem
it must be something to do with the transparent images
they look fine individually
if i draw exactly the same pixels onto the background grid and make an animated gif from that it looks ok
but they are nearly double the size
the images i posted are exactly the ones i am using
maybe someone could give it a try?
convert backgroundGrid.gif -monochrome backgroundGrid2.gif
thinking i would get only black and white
not perfect but worth a test
however i got a pure black image (i guess the grey was less than 50%)
and i tried that as the background
convert -dispose previous -delay 200 -loop 0 w*.png w.anim.gif
convert backgroundGrid2.gif w.anim.gif -loop 0 w.anim.gif
still got the wrong result
just to be sure i created a pure black background with IM
convert -size 1000x1000 xc:black black.gif
and then
convert -dispose previous -delay 200 -loop 0 w*.png w.anim.gif
convert black.gif w.anim.gif -loop 0 w.anim.gif
and still got the same wrong result
so the background isn't the problem
it must be something to do with the transparent images
they look fine individually
if i draw exactly the same pixels onto the background grid and make an animated gif from that it looks ok
but they are nearly double the size
the images i posted are exactly the ones i am using
maybe someone could give it a try?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: animated gif colours
Your transparent image is 32-bit and probably needs to be converted to a -type palettematte rather than truecolor.
Perhaps it has to do with the fact that you have both opaque black and transparent black and you cannot assign both in a gif. Gif needs one an only one color assigned as transparent. So you need to make the background color under the transparency one of your 256 colors, but not included in any of the other 255 colors.
Perhaps it has to do with the fact that you have both opaque black and transparent black and you cannot assign both in a gif. Gif needs one an only one color assigned as transparent. So you need to make the background color under the transparency one of your 256 colors, but not included in any of the other 255 colors.
Re: animated gif colours
i create the images using System.Drawing.Bitmap
i set the pixels of the little dots to whatever colour
then save it as png
if i edit that then it shows as transparent
i guess the background is black and transparent because it is 0,0,0,0 (ARGB) and the little dots are 255,x,x,x (ARGB)
so
i created a new background grid using 255,1,1,1 (ARGB) as i still want it to look sort of black
and tried that but still got the same wrong result
i would rather not regenerate the images because they take quite a long time to generate
there are only 20 colours in the images
is there a way to make changes to palettematte as i make the animated gif?
i set the pixels of the little dots to whatever colour
then save it as png
if i edit that then it shows as transparent
i guess the background is black and transparent because it is 0,0,0,0 (ARGB) and the little dots are 255,x,x,x (ARGB)
so
i created a new background grid using 255,1,1,1 (ARGB) as i still want it to look sort of black
and tried that but still got the same wrong result
i would rather not regenerate the images because they take quite a long time to generate
there are only 20 colours in the images
is there a way to make changes to palettematte as i make the animated gif?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: animated gif colours
Lets go back to square one.
Furthermore, why do you think using and (32-bit color) transparent background image would make things smaller. Seems to me that you are eventually going to overlay those transparent images on your black background. So why not just draw them as you originally did with the first example that works.
Explain what you mean by reduce the size of the gif. Do you mean file size or image size?i wanted to reduce the size of the final gif file so i created the png with a transparent background
Furthermore, why do you think using and (32-bit color) transparent background image would make things smaller. Seems to me that you are eventually going to overlay those transparent images on your black background. So why not just draw them as you originally did with the first example that works.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: animated gif colours
try this, it works for me on IM 6.7.0.2 Q16 Mac OSX Tiger. Note I renamed your images for simplicity.
convert -delay 200 1.png 2.png -loop 0 miff:- |\
convert - -draw 'image DstOver 0,0 0,0 "3.gif"' \
-layers Optimize 4.gif
convert -delay 200 1.png 2.png -loop 0 miff:- |\
convert - -draw 'image DstOver 0,0 0,0 "3.gif"' \
-layers Optimize 4.gif
Re: animated gif colours
ok square onefmw42 wrote:Lets go back to square one.
Explain what you mean by reduce the size of the gif. Do you mean file size or image size?i wanted to reduce the size of the final gif file so i created the png with a transparent background
Furthermore, why do you think using and (32-bit color) transparent background image would make things smaller. Seems to me that you are eventually going to overlay those transparent images on your black background. So why not just draw them as you originally did with the first example that works.
i created an image with background as i finally wanted it to look (119kb)
then i created another one (119kb)
i wanted to create a change graph so i created an animated gif of the two images (134kb)
as the number of still images increased the resulting gif was getting a bit big so i needed to reduce the size but keep the dimensions the same
i read in the help that the best way to do this is create transparent images so that the background wasn''t repeated in every layer
so i created 2 images without the background (98kb x 2) and a background (17kb)
i then merged them into an animated gif (123kb)i create the images using System.Drawing.Bitmap
i set the pixels of the little dots to whatever colour
then save it as png
if i edit that then it shows as transparent
i guess the background is black and transparent because it is 0,0,0,0 (ARGB) and the little dots are 255,x,x,x (ARGB)
this isn't a big difference with only 2 images but with 100 it will be significant
i don't really care what format i save the images in
bitmap is too large
png seemed like the right way to go as i might eventually try to make animated png
anyway that is beside the point
i can convert the png to gif with IM
the only problem is that the results are wrong
is there a way to create a palette and tell IM to use that?
i am only working with 20 or so colours and the background grid
it seems like it would be easier if i could just allocate 20 colours plus the transparent 0,0,0,0 ARGB in a palette and let IM play with the other 235 slots
Re: animated gif colours
well i gave it a try but after 5 minutes of 100% of one of my CPUs i cancelled itfmw42 wrote:try this, it works for me on IM 6.7.0.2 Q16 Mac OSX Tiger. Note I renamed your images for simplicity.
convert -delay 200 1.png 2.png -loop 0 miff:- |\
convert - -draw 'image DstOver 0,0 0,0 "3.gif"' \
-layers Optimize 4.gif
i did look at the -layers optimize right at the beginning but unfortunately it didn't do anything for me
it works best when you have small areas changing
as the number of dots i have in an image increases to almost fill the grid it has nothing to optimize
looking at the layers of the result it is almost the same as the images with background grid that i started with so that isn't going to help me
the only thing i can see to reduce the file size of my resulting gif is to reduce the amount of information in the individual layers, hence trying the transparent background
Re: animated gif colours
i tried this
convert w1.png -format %c -depth 8 histogram:info:-
on my transparent png and got this
988644: ( 0, 0, 0, 0) #00000000 none
1019: ( 0, 0,255,255) #0000FF blue
301: ( 0,128,204,255) #0080CC rgba(0,128,204,1)
1284: ( 0,184, 0,255) #00B800 rgba(0,184,0,1)
325: ( 0,255, 0,255) #00FF00 lime
96: ( 34, 0,103,255) #220067 rgba(34,0,103,1)
603: ( 47,204, 22,255) #2FCC16 rgba(47,204,22,1)
1726: ( 51,255, 51,255) #33FF33 rgba(51,255,51,1)
594: ( 78, 77,255,255) #4E4DFF rgba(78,77,255,1)
925: (107, 67,255,255) #6B43FF rgba(107,67,255,1)
1111: (156,156,156,255) #9C9C9C grey61
299: (204,213,102,255) #CCD566 rgba(204,213,102,1)
985: (215,134,215,255) #D786D7 rgba(215,134,215,1)
742: (238,238,238,255) #EEEEEE rgba(238,238,238,1)
650: (255, 0, 0,255) #FF0000 red
696: (255,170,204,255) #FFAACC rgba(255,170,204,1)
there is definitely a red in there
then i tried this
convert w1.png -unique-colors -scale 1000% w1_colors.gif
and got this
that isn't right at all
looks like the range of colours i have in the wrong animated gif
just for fun i tried this
convert w1.png -unique-colors -scale 1000% w1_colors.png
and got this
that is the right range of colours that are in the png file
it seems that just converting my png file to a gif is screwing up before it gets to the animation part
even though it has a small range of colours even the -unique-colors gets it wrong
if i do this to the -unique-colors results
convert w1_colors.png -format %c -depth 8 histogram:info:-
100: ( 0, 0, 0, 0) #00000000 none
100: ( 0, 0,255,255) #0000FF blue
100: ( 0,128,204,255) #0080CC rgba(0,128,204,1)
100: ( 0,184, 0,255) #00B800 rgba(0,184,0,1)
100: ( 0,255, 0,255) #00FF00 lime
100: ( 34, 0,103,255) #220067 rgba(34,0,103,1)
100: ( 47,204, 22,255) #2FCC16 rgba(47,204,22,1)
100: ( 51,255, 51,255) #33FF33 rgba(51,255,51,1)
100: ( 78, 77,255,255) #4E4DFF rgba(78,77,255,1)
100: (107, 67,255,255) #6B43FF rgba(107,67,255,1)
100: (156,156,156,255) #9C9C9C grey61
100: (204,213,102,255) #CCD566 rgba(204,213,102,1)
100: (215,134,215,255) #D786D7 rgba(215,134,215,1)
100: (238,238,238,255) #EEEEEE rgba(238,238,238,1)
100: (255, 0, 0,255) #FF0000 red
100: (255,170,204,255) #FFAACC rgba(255,170,204,1)
convert w1_colors.gif -format %c -depth 8 histogram:info:-
100: ( 0, 0, 0,255) #000000 black
100: ( 0, 0, 0, 0) #00000000 none
100: ( 0, 0,103,255) #000067 rgba(0,0,103,1)
100: ( 0, 0,255,255) #0000FF blue
100: ( 0, 67,255,255) #0043FF rgba(0,67,255,1)
100: ( 0, 77,255,255) #004DFF rgba(0,77,255,1)
100: ( 0,128,204,255) #0080CC rgba(0,128,204,1)
100: ( 0,134,215,255) #0086D7 rgba(0,134,215,1)
100: ( 0,156,156,255) #009C9C rgba(0,156,156,1)
100: ( 0,170,204,255) #00AACC rgba(0,170,204,1)
100: ( 0,184, 0,255) #00B800 rgba(0,184,0,1)
100: ( 0,204, 22,255) #00CC16 rgba(0,204,22,1)
100: ( 0,213,102,255) #00D566 rgba(0,213,102,1)
100: ( 0,238,238,255) #00EEEE rgba(0,238,238,1)
100: ( 0,255, 0,255) #00FF00 lime
100: ( 0,255, 51,255) #00FF33 rgba(0,255,51,1)
it looks like it has dropped the red channel
i highlighted what i think is #4E4DFF in both histograms
and my #FF0000 has become #000000
surely this is a big BUG?
convert w1.png -format %c -depth 8 histogram:info:-
on my transparent png and got this
988644: ( 0, 0, 0, 0) #00000000 none
1019: ( 0, 0,255,255) #0000FF blue
301: ( 0,128,204,255) #0080CC rgba(0,128,204,1)
1284: ( 0,184, 0,255) #00B800 rgba(0,184,0,1)
325: ( 0,255, 0,255) #00FF00 lime
96: ( 34, 0,103,255) #220067 rgba(34,0,103,1)
603: ( 47,204, 22,255) #2FCC16 rgba(47,204,22,1)
1726: ( 51,255, 51,255) #33FF33 rgba(51,255,51,1)
594: ( 78, 77,255,255) #4E4DFF rgba(78,77,255,1)
925: (107, 67,255,255) #6B43FF rgba(107,67,255,1)
1111: (156,156,156,255) #9C9C9C grey61
299: (204,213,102,255) #CCD566 rgba(204,213,102,1)
985: (215,134,215,255) #D786D7 rgba(215,134,215,1)
742: (238,238,238,255) #EEEEEE rgba(238,238,238,1)
650: (255, 0, 0,255) #FF0000 red
696: (255,170,204,255) #FFAACC rgba(255,170,204,1)
there is definitely a red in there
then i tried this
convert w1.png -unique-colors -scale 1000% w1_colors.gif
and got this
that isn't right at all
looks like the range of colours i have in the wrong animated gif
just for fun i tried this
convert w1.png -unique-colors -scale 1000% w1_colors.png
and got this
that is the right range of colours that are in the png file
it seems that just converting my png file to a gif is screwing up before it gets to the animation part
even though it has a small range of colours even the -unique-colors gets it wrong
if i do this to the -unique-colors results
convert w1_colors.png -format %c -depth 8 histogram:info:-
100: ( 0, 0, 0, 0) #00000000 none
100: ( 0, 0,255,255) #0000FF blue
100: ( 0,128,204,255) #0080CC rgba(0,128,204,1)
100: ( 0,184, 0,255) #00B800 rgba(0,184,0,1)
100: ( 0,255, 0,255) #00FF00 lime
100: ( 34, 0,103,255) #220067 rgba(34,0,103,1)
100: ( 47,204, 22,255) #2FCC16 rgba(47,204,22,1)
100: ( 51,255, 51,255) #33FF33 rgba(51,255,51,1)
100: ( 78, 77,255,255) #4E4DFF rgba(78,77,255,1)
100: (107, 67,255,255) #6B43FF rgba(107,67,255,1)
100: (156,156,156,255) #9C9C9C grey61
100: (204,213,102,255) #CCD566 rgba(204,213,102,1)
100: (215,134,215,255) #D786D7 rgba(215,134,215,1)
100: (238,238,238,255) #EEEEEE rgba(238,238,238,1)
100: (255, 0, 0,255) #FF0000 red
100: (255,170,204,255) #FFAACC rgba(255,170,204,1)
convert w1_colors.gif -format %c -depth 8 histogram:info:-
100: ( 0, 0, 0,255) #000000 black
100: ( 0, 0, 0, 0) #00000000 none
100: ( 0, 0,103,255) #000067 rgba(0,0,103,1)
100: ( 0, 0,255,255) #0000FF blue
100: ( 0, 67,255,255) #0043FF rgba(0,67,255,1)
100: ( 0, 77,255,255) #004DFF rgba(0,77,255,1)
100: ( 0,128,204,255) #0080CC rgba(0,128,204,1)
100: ( 0,134,215,255) #0086D7 rgba(0,134,215,1)
100: ( 0,156,156,255) #009C9C rgba(0,156,156,1)
100: ( 0,170,204,255) #00AACC rgba(0,170,204,1)
100: ( 0,184, 0,255) #00B800 rgba(0,184,0,1)
100: ( 0,204, 22,255) #00CC16 rgba(0,204,22,1)
100: ( 0,213,102,255) #00D566 rgba(0,213,102,1)
100: ( 0,238,238,255) #00EEEE rgba(0,238,238,1)
100: ( 0,255, 0,255) #00FF00 lime
100: ( 0,255, 51,255) #00FF33 rgba(0,255,51,1)
it looks like it has dropped the red channel
i highlighted what i think is #4E4DFF in both histograms
and my #FF0000 has become #000000
surely this is a big BUG?
Re: animated gif colours
p.s.
convert -version
Version: ImageMagick 6.6.9-8 2011-05-04 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP
OS: windows 7 64 bit
convert -version
Version: ImageMagick 6.6.9-8 2011-05-04 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP
OS: windows 7 64 bit