[SOLVED] Huge PNG file when using change-mask
Posted: 2011-06-05T13:31:15-07:00
I want to store a series of screenshots more efficiently by only storing their difference. Therefore I want to produce a PNG file that is fully transparent except for the parts that are different between two images.
This command basically has the desired effect (d1-2.png containing the difference between s1.png and s2.png):
composite s1.png s2.png -compose change-mask d1-2.png
However, the resulting image (d1-2.png) is still just as large as the screenshots themselves - even though it is far less complex (e.g. the background image is invisible). I think I know why: if I convert d1-2.png to JPEG (mogrify -format jpg d1-2.png), it looks exactly like s2.png - instead of also showing just the changes as d1-2.png does.
Apparently the complete image is stored and the parts that did not change are just hidden by the alpha channel. Nifty, but I don't want that.
From the looks of it, "-alpha background" should help me out ("Set any fully-transparent pixel to the background color, while leaving it fully-transparent. This can make some image file formats, such as PNG, smaller as the RGB values of transparent pixels are more uniform, and thus can compress better."). Unfortunately, it does not have any effect at all.
So, how do I make the pixels that are fully transparent a constant color so that PNG can better compress the image?
I'm using ImageMagick 6.5.6-8 2009-10-03 Q8 OpenMP on Windows XP, but ImageMagick 6.7.0-3 2011-05-26 Q16 makes no difference. Any hints? :-/
This command basically has the desired effect (d1-2.png containing the difference between s1.png and s2.png):
composite s1.png s2.png -compose change-mask d1-2.png
However, the resulting image (d1-2.png) is still just as large as the screenshots themselves - even though it is far less complex (e.g. the background image is invisible). I think I know why: if I convert d1-2.png to JPEG (mogrify -format jpg d1-2.png), it looks exactly like s2.png - instead of also showing just the changes as d1-2.png does.
Apparently the complete image is stored and the parts that did not change are just hidden by the alpha channel. Nifty, but I don't want that.
From the looks of it, "-alpha background" should help me out ("Set any fully-transparent pixel to the background color, while leaving it fully-transparent. This can make some image file formats, such as PNG, smaller as the RGB values of transparent pixels are more uniform, and thus can compress better."). Unfortunately, it does not have any effect at all.
So, how do I make the pixels that are fully transparent a constant color so that PNG can better compress the image?
I'm using ImageMagick 6.5.6-8 2009-10-03 Q8 OpenMP on Windows XP, but ImageMagick 6.7.0-3 2011-05-26 Q16 makes no difference. Any hints? :-/