Reputation: 6799
The raytracer we're programming generates simple PPM image files. We wrote a little something that generates scene definitions for us, so that we can create an animation with these files.
The initial workflow was opening all files in Photoshop via File > Scripting > Load Files into Stack and exporting the result as a gif. This works well, although the workflow is bumpy. The quality is good, the file size huge.
Now when using ImageMagick to convert from PPM to GIF, the quality of the resulting image is horrible. That is, the quality of single GIF files produced by ImageMagick is already bad. Combining them to a GIF of course does not change that.
Original File (saved as PNG with Photoshop):
GIF (converted from PPM with ImageMagick):
(Especially notice the spots around the point where the light emits)
I just used mogrify -path ../gif -format gif 006.ppm
for that result. I don't really know where to start to tweak this (although I played around with a couple of options from the reference).
(a little animation of the difference between the two files so the issues are easier to see. by Mark Setchell)
Upvotes: 0
Views: 2599
Reputation: 207485
Other Option
Another option may be to convert to MPG format, something like this:
convert -delay 1 a-*png m2v:movie.mpg
or
convert -delay 1 a-*ppm m2v:movie.mpg
Updated Answer
I see - you have to use GIF for your animation, so PNG is not an option. Maybe you can quantize in a different colourspace, e.g. like this for Lab
colorspace:
convert orig.ppm -quantize Lab -colors 256 result.gif
Other options might be YUV
, RGB
- you can get a list of all options with
identify -list colorspace
Original Answer
The problem is that your PPM file has more colours than the GIF format can contain. You can count the colours used like this:
convert orig.ppm -print "%k\n" null:
642
which shows your image has 642 colours.
The GIF format ony allows a palette of 256 colours - reference. Can you use PNG format instead?
Upvotes: 2