-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gray artifacts in large gif when using -layers optimize #57
Comments
This is not a bug in -layers optimize but an issue with your command order. You should put the +dither before your optimize your layers. We get the correct result with the following command:
|
Confirmed. Is there an explanation for why it works the way it does, because I'm confused why it works with the first command and doesn't with the second? I have seen this before but I don't think I've ever tried moving the +dither command as a fix. |
In IM 6, settings (+dither) should come before operators (such as -colors); otherwise, the operator does not know what setting to use. see http://www.imagemagick.org/Usage/quantize/#colors. Command lines are mostly parsed in sequence. See http://www.imagemagick.org/Usage/basics/#syntax However, I am puzzled, since I do not see any operator in your command that would be affected by: -quantize, -fuzz or +dither. I am not aware that -layers optimize is sensitive to any of those |
I just threw that there because I though that only the color reduction to 256 would be affected by dithering. I haven't had a "set" place for the setting in my gif making before, but I guess I should just put it in the front like with the -delay setting. Then again I just tried leaving the +dither out entirely, and then explicitly specifying -dither FloydSteinberg as the first option, before the -delay, and I'm getting gray artifacts in both cases. |
I am totally puzzled as I said above, since I do not know what operator in your command line is dither sensitive. What do you get when you leave all that off? Is it the same as putting +dither at the beginning?
What version of IM are you using? |
the command was |
I realize that. But I do not see why you have any need for -quantize, -fuzz and +dither. There is no operator there that should be affected to my knowledge. So I wanted to see if you got a decent result or any different result from what you had before with +dither at the beginning. So I asked you to run
and there report back any difference. |
The |
@fmw42 Running I use -quantize lab because afaik it treats perceptually similar lighting and color change equally, so it's "the fairest" quantization method. Usually I use ordered dither in the lab colorspace when making gifs, but with some cartoons I've found that it's better to just use quantization. Also running this command (without -fuzz) balloons the file size from 3.99MB (which is just under my maximum file size of 4MB) to 15.6MB, because every tiny color change in every pixel is treated as a meaningful change. With cartoony source like this, I can sometimes use up to 4% or 5% fuzz without a significant drop in the visual quality. |
Sorry, I did not realize that -layers optimize does a color quatization, as dlemstra points out above. Thus dither, fuzz, quantize would be needed prior to -layers optimize. |
Do you still have some questions or can we close your issue? |
I'm confused about your question. Is the gray artifacting intended behaviour? Especially in this case I added earlier: This is the resulting gif, btw: https://i.imgur.com/E93Y4Xl.gif If gifs made with that command like are supposed to have terrible gray smears all over, then I guess this issue can be closed, but I intended this to be a bug report, because that seems like a bug to me. |
It is somehow related to the lenght of the gif, if I only use the first 19 frames, i.e. Could this be caused by some overflow happening in the quantization code? There is a "big number" of pixels. Adding their numbers to the histogram could fail. I haven't looked at Imagemagick's quantization code, but I assume a histogram is built at some point of it. |
Try your command with ImageMagick 6.9.2-8. |
Hey, it works! No more artifacts. |
2016-03-22 6.9.3-8 Cristy <quetzlzacatenango@image...> * Respect gravity when rendering text (e.g. convert -gravity center my.txt) * Return empty string for %d property and no directory (reference https://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=29365) * Return filename for the %i property (reference https://www.imagemagick.org/discourse-server/viewtopic.php?f=2&t=29364). * Fixed lost pixels in frequency space (reference https://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=29374). 2016-03-06 6.9.3-7 Cristy <quetzlzacatenango@image...> * New version 6.9.3-7, GIT revision 10628:810a9fe:20160306 2016-03-05 6.9.3-7 Dirk Lemstra <dirk@lem.....org> * -size can now be used the specify the maximum width/height for the following vector formats: * SVG (when librsvg and cairo are being used). * EMF (did not work on Windows). 2016-02-29 6.9.3-7 Cristy <quetzlzacatenango@image...> * Fixed text alignment issue for label: / coder: (reference https://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=29223). 2016-02-27 6.9.3-6 Cristy <quetzlzacatenango@image...> * New version 6.9.3-6, GIT revision 10597:83584a1:20160228. 2016-02-25 6.9.3-6 Cristy <quetzlzacatenango@image...> * Ensure TXT: image format survives round-trip (reference https://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=29206). 2016-02-21 6.9.2-6 Dirk Lemstra <dirk@lem.....org> * Added wavelet denoise. 2016-02-20 6.9.3-5 Cristy <quetzlzacatenango@image...> * New version 6.9.3-5, GIT revision 10572:cb24a69:20160219. 2016-02-16 6.9.3-5 Cristy <quetzlzacatenango@image...> * Too many bytes when writing raw image formats (reference ImageMagick/ImageMagick#132). 2016-02-12 6.9.3-4 Cristy <quetzlzacatenango@image...> * New version 6.9.3-4, GIT revision 10560:09f5f5d:20160212. 2016-02-12 6.9.3-4 Dirk Lemstra <dirk@lem.....org> * Fixed memory leak when reading an SVG without width/height (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=27&p=130197). 2016-02-09 6.9.3-4 Cristy <quetzlzacatenango@image...> * Fix compiler error for complext text layout. 2016-02-05 6.9.3-3 Cristy <quetzlzacatenango@image...> * New version 6.9.3-3, GIT revision 10540:6b4c918:20160206. 2016-02-04 6.9.3-3 Cristy <quetzlzacatenango@image...> * Numerous bugs fixed from fuzzed images (reference ImageMagick/ImageMagick#123). * The -bias option is no longer a noop (reference ImageMagick/ImageMagick#125). 2016-01-25 6.9.3-3 Dirk Lemstra <dirk@lem.....org> * Read XCF layer name (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&p=129638). 2016-01-23 6.9.3-2 Cristy <quetzlzacatenango@image...> * New version 6.9.3-2, GIT revision 10496:315028c:20160122. 2016-01-17 6.9.3-2 Cristy <quetzlzacatenango@image...> * Don't reuse lock after free (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=29031). 2016-01-21 6.9.3-2 Dirk Lemstra <dirk@lem.....org> * Fixed writing DocClass in CALS coder (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&p=129478). 2016-01-17 6.9.3-1 Cristy <quetzlzacatenango@image...> * New version 6.9.3-1, GIT revision 10488:e4f046e:20160116. 2016-01-06 6.9.3-1 Cristy <quetzlzacatenango@image...> * Pair AcquireMagickResource with calls to RelinquishMagickResource when resource limits are hit (reference ImageMagick/ImageMagick#75). * Return non-zero for the -format %b option (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=28969). 2016-01-01 6.9.3-0 Cristy <quetzlzacatenango@image...> * New version 6.9.3-0, GIT revision 10445:620328b:20160101. 2015-12-31 6.9.3-0 Cristy <quetzlzacatenango@image...> * Don't break on euro-style numbers (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=28910). 2015-12-22 6.9.3-0 Glenn Randers-Pehrson <glennrp@image...> * 16-bit pnm images have a max value of 65535. 2015-12-18 6.9.2-10 Cristy <quetzlzacatenango@image...> * New version 6.9.2-10, GIT revision 10415:e31c09d:20151219. 2015-12-19 6.9.2-10 Cristy <quetzlzacatenango@image...> * Fixed compile error when POSIX threads are not defined. http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=28791). 2015-12-18 6.9.2-9 Cristy <quetzlzacatenango@image...> * New version 6.9.2-9, GIT revision 10402:0027295:20151219 2015-12-05 6.9.2-9 Dirk Lemstra <dirk@lem.....org> * Fixed memory leak when reading incorrect PSD files (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=28791). 2015-12-05 6.9.2-9 Cristy <quetzlzacatenango@image...> * Enhance PDF to properly handle unicode titles (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=28786). * Fix memory leak in icon coder (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=6&t=28848). 2015-12-05 6.9.2-8 Cristy <quetzlzacatenango@image...> * New version 6.9.2-8, GIT revision 10374:ac7d144:20151205. 2015-12-04 6.9.2-8 Cristy <quetzlzacatenango@image...> * Gray artifacts in large gif when using -layers optimize (reference ImageMagick/ImageMagick#57). 2015-11-26 6.9.2-7 Cristy <quetzlzacatenango@image...> * New version 6.9.2-7, GIT revision 10370:eeb7d4e:20151126. 2015-11-24 6.9.2-7 Dirk Lemstra <dirk@lem.....org> * The DICOM reader now handles the rescale intercept and slope. * Added 'bmp3:alpha' option for including the alpha channel when writing an image in the BMP3 format. (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=28733). * Only one thread permitted when delegating to the Ghostscript library under Windows. 2015-11-14 6.9.2-6 Cristy <quetzlzacatenango@image...> * New version 6.9.2-6, GIT revision 10341:f408196:20151113. 2015-11-08 6.9.2-6 Cristy <quetzlzacatenango@image...> * PixelColor off by one on i386 (reference ImageMagick/ImageMagick#54). * Eliminate stack overflow (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=28658). 2015-11-03 6.9.2-6 Dirk Lemstra <dirk@lem.....org> * Added local contrast enhancement. * Fixed bug in SetPixelCacheExtent that made images all black (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=28514). * Added support for reading DICOM images with implicit vr little-endian transfer syntax. 2015-11-02 6.9.2-6 Samuel Thibault <samuel.thibault@...org> * Added 6dot variant for unicode and iso braille formats (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=2&p=127111). 2015-10-31 6.9.2-5 Cristy <quetzlzacatenango@image...> * New version 6.9.2-5, GIT revision 10316:86a76b6:20151031. 2015-10-15 6.9.2-5 Dirk Lemstra <dirk@lem.....org> * Fixed alpha blending issue with semi-transparent pixels in the merged image of PSD files. This can be disabled by setting the option 'psd:alpha-unblend' to 'off' (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=28169). * Fixed issue in jpeg:extent that prevented it from working (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&p=126638). * Fixed memory leak when reading Photoshop layers in a TIFF file. 2015-10-12 6.9.2-5 Cristy <quetzlzacatenango@image...> * Support gradient:bounding-box, gradient:vector, gradient:center, and gradient:radius to shape the gradient rendering. * Recognize label:@- as stdin (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=28501). * Make commas optional for coordinates (e.g. 0,0 256,256). 2015-10-10 6.9.2-4 Cristy <quetzlzacatenango@image...> * New version 6.9.2-4, GIT revision 10273:e00cf21:20151010 2015-10-08 6.9.2-4 Dirk Lemstra <dirk@lem.....org> * Fixed accessing subimage in a TIFF photoshop layer (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=28469). * Fixed out of bounds error in -splice (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=28466). 2015-09-25 6.9.2-4 Eric McConville <emcconville@emccon...> * Created Manhattan Interpolate method for -sparse-color (reference ImageMagick/ImageMagick#36). 2015-09-22 6.9.2-4 Cristy <quetzlzacatenango@image...> * Prevent null pointer access (reference ImageMagick/ImageMagick#34). * Specify histogram code image format implictedly (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=28412). * Don't round up for JPEG image resolution (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=28422). * Read the whole image @ image.jp2[0] or an individual tile @ image.jp2[1], image.jp2[2]. * The -caption option no longer fails for filenames with @ prefix (reference ImageMagick/ImageMagick#43). * Honor $XDG_CONFIG_HOME and $XDG_CACHE_HOME (reference ImageMagick/ImageMagick#44). 2015-09-19 6.9.2-3 Cristy <quetzlzacatenango@image...> * New version 6.9.2-3, GIT revision 10235:c40ee57:20150919 2015-09-17 6.9.2-2 Dirk Lemstra <dirk@lem.....org> * Added extra checks to avoid out of bounds error when parsing the 8bim profile (reference ImageMagick/ImageMagick#31). * Fixed size of memory allocation in RLE coder to avoid segfault (reference ImageMagick/ImageMagick#32). 2015-09-16 6.9.2-2 Cristy <quetzlzacatenango@image...> * Add Bootstrap MIT license to ImageMagick web CSS and JS. * Use modern idiom for autoconf Fix a forgotten dir when regenerating html doc (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=28363). * The -colorspace gray option no long leaves a ghostly shadow (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=28350). 2015-09-14 6.9.2-1 Cristy <quetzlzacatenango@image...> * New version 6.9.2-1, GIT revision 10201:5879612:20150913. 2015-09-13 6.9.2-1 Dirk Lemstra <dirk@lem.....org> * Preserving image origin in TGA files (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=28310). 2015-08-15 6.9.2-1 Cristy <quetzlzacatenango@image...> * Support color compliance for TXT format (e.g. -define txt:compliance=css) (bug report from Anthony). * The first argument of a hsl() color is integer, not percentage (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=2&t=26072). * Limit -fx recursive to avoid stack overflow (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=28200). * Support inline images with data URLS. * Report progress less often (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=28299). * Don't set image colorspace to gray for -alpha copy option. * Fixed a possible memory leak associated with the -sampling-factor option. * GetImageType() no longer has side-effects to match behavior of IMv7. 2015-08-15 6.9.2-0 Cristy <quetzlzacatenango@image...> * New version 6.9.2-0, GIT revision 10143:3534f6d:20150815. 2015-08-10 6.9.2-0 Cristy <quetzlzacatenango@image...> * Swap pixels for -spread command-line option (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=28043). * fx logical operations short circuit (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=28179). * Type cast intensity variable (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=28182). * Fix ModulusAdd & ModulusSubstract for HDRI compositing (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=28186). 2015-07-25 6.9.2-0 Dirk Lemstra <dirk@lem.....org> * Added "-set colorspace:auto-grayscale false" that will prevent automatic conversion to grayscale inside coders that support grayscale. * Fixed -list weight and the options for -weight. * Added fontFamily, fontStyle, fontWeight and textUnderColor to the Image class of Magick++. * Fixed reading Photoshop layers of LSB TIFF files (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=28045). * Fixed memory leak in font cache under Windows (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=6&t=28191). 2015-07-25 6.9.1-10 Cristy <quetzlzacatenango@image...> * New version 6.9.1-10, SVN revision 19269. 2015-07-20 6.9.1-10 Glenn Randers-Pehrson <glennrp@image...> * coders/magick.c: added "-define h:format=FMT" and "-define magick:format=FMT" options. FMT can be any output format supported by ImageMagick except "H" or "MAGICK". If this define is omitted, the encoder uses GIF by default for pseudoclass images and PNM for directclass images, as previously. Made "MAGICK" (read-write) and "H" (write-only) visible in the format list. 2015-07-18 6.9.1-10 Dirk lemstra <dirk@lem.....org> * Removed incorrect EOF check in the DDS reader (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=28065). 2015-07-18 6.9.1-10 Cristy <quetzlzacatenango@image...> * Fixed undefined behaviors (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=28067). * Return exception message for unknown image properties. * Color shift removed when reading transparent gray images (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=28081) 2015-07-18 6.9.1-9 Cristy <quetzlzacatenango@image...> * New version 6.9.1-9, SVN revision 19200. 2015-07-12 6.9.1-9 Dirk Lemstra <dirk@lem.....org> * Fixed issue with radial gradient in MVG (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=27995). 2015-07-11 6.9.1-8 Cristy <quetzlzacatenango@image...> * New version 6.9.1-8, SVN revision 19167. 2015-06-25 6.9.1-8 Cristy <quetzlzacatenango@image...> * Correct install location of the Magick++ headers (reference https://github.com/ImageMagick/ImageMagick/pull/17/commits). * Different gif cropping behavior between versions (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=28013). * Cannot read properly simple psd file (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=28002).
When creating a large .gif, using -layers optimize causes gray artifacts to appear all over the image.
The source frames I'm using in these commands are in this zip file: http://www26.zippyshare.com/v/rOwQZL3D/file.html and they are originally from this cartoon: https://youtu.be/_2WMLV1UeuM
The version I'm using is the newest available atm, but this bug was also present in some 6.8 version I was using before I updated:
I'm using Windows 7 and cygwin terminal to run these commands, they won't work as-is with the default windows command prompt. I haven't tested if the problem happens in Linux as well.
This command works properly and creates a 1,72 MB gif with no artifacts:
convert -delay 4 frames/mickey_mustache0{08..74}.png -colorspace rgb -resize 50% -colorspace srgb -quantize lab -fuzz 3% -layers optimize +dither mickey_mustache_small.gif
This command demonstrates the error:
convert -delay 4 frames/mickey_mustache0{08..74}.png -colorspace rgb -resize 94% -colorspace srgb -quantize lab -fuzz 3% -layers optimize +dither mickey_mustache_big.gif
The only difference between those two is the amount of scaling from the 1080p source files (50% vs 94%)
If you don't use -layers optimize, you get a very big, but working, gif:
convert -delay 4 frames/mickey_mustache0{08..74}.png -colorspace rgb -resize 94% -colorspace srgb -quantize lab -fuzz 3% +dither mickey_mustache_big_no-optimize.gif
If you don't use fuzz, you get a fairly big, but extremely corrupted gif:
convert -delay 4 frames/mickey_mustache0{08..74}.png -colorspace rgb -resize 94% -colorspace srgb -quantize lab -layers optimize +dither mickey_mustache_big_no-fuzz.gif
Here is a zip of the resulting gifs: http://www62.zippyshare.com/v/CD2stFbG/file.html
The text was updated successfully, but these errors were encountered: