Page 1 of 1

Convert multi-page PostScript file to animated gif?

Posted: 2012-02-01T04:37:00-07:00
by |Rob|
I currently convert a multi-page postscript file into a series of PNG images using:

Code: Select all

mogrify -format png -page A4 -trim -density 300 -rotate "90<" image.ps
I then use Photoshop to assemble the PNG images into an animated GIF but I was hoping to use ImageMagick to do this instead.

I tried the following:

Code: Select all

convert -delay 15 *.png -loop 0 myanimation.gif
but this results in a completely black image.

Am I missing something obvious?

Cheers

Rob

Re: Convert multi-page PostScript file to animated gif?

Posted: 2012-02-01T05:26:23-07:00
by anthony
Without seeing the png data it is hard to say what is wring with yoru animation.

Note as mogrify is only used for a single input image, you may as well use convert...

Code: Select all

convert -page A4 -density 300 image.ps -trim -rotate "90<" image_%03d.png

Re: Convert multi-page PostScript file to animated gif?

Posted: 2012-02-01T05:35:42-07:00
by |Rob|
Thanks, after narrowing it down a bit it seems that if i omit the density keyword then the animated gif is produced fine.

e.g.

Code: Select all

mogrify -format png -page A4 -trim -rotate "90<" image.ps
If i put the density keyword in, it now fails to produce the animated gif and instead the result is just the first frame of the gif. I've tried different values for the density but that doesn't seem to help.

Re: Convert multi-page PostScript file to animated gif?

Posted: 2012-02-01T05:48:41-07:00
by anthony
That is strange as GIF format ignores density completely!

Re: Convert multi-page PostScript file to animated gif?

Posted: 2012-02-01T05:57:11-07:00
by |Rob|
anthony wrote:That is strange as GIF format ignores density completely!
Is there a simpler way to make the single files I'm producing from the PostScript file larger than the default low-res ones that come out if I omit "-density"?

Re: Convert multi-page PostScript file to animated gif?

Posted: 2012-02-01T16:54:56-07:00
by anthony
You can use -density for the read. Then use +density afterward to remove it.

Though I still don't understand how density could effect GIF output, except perhaps that larger images equal more colors.

GIF was never designed with large images in mind. It was for small 'cartoon' like images with limited size and colors.

To test this out, omit the -density (as that works) but then do a -resize 400% to enlarge the image. See how GIF reacts to that!


Hmm it may also be that -page is not large enough for a higher density. -page A4 is internally fixed to 595x842 pixels which is the size of an A4 page at 72 dpi. But you use a larger density which means the -page size is about 1/4 the size it should be!

try adding -density and omit -page instead.

Re: Convert multi-page PostScript file to animated gif?

Posted: 2012-02-01T17:46:36-07:00
by fmw42
mogrify -format png -page A4 -trim -rotate "90<" image.ps
There may be just a typo here, but I don't see any gif involved and png does not support multi-frame images such as animations. Or perhaps I have just lost context in this thread.

Re: Convert multi-page PostScript file to animated gif?

Posted: 2012-02-02T02:04:26-07:00
by |Rob|
fmw42 wrote:
mogrify -format png -page A4 -trim -rotate "90<" image.ps
There may be just a typo here, but I don't see any gif involved and png does not support multi-frame images such as animations. Or perhaps I have just lost context in this thread.
Maybe I didn't explain it properly.

multi-page postscript -> individual PNG files -> animated gif

The step you posted above was to create the individual frames from the postscript (sometimes I don't want every frame so don't convert postscript straight to animation).

Re: Convert multi-page PostScript file to animated gif?

Posted: 2012-02-02T02:21:39-07:00
by |Rob|
anthony wrote:You can use -density for the read. Then use +density afterward to remove it.

Though I still don't understand how density could effect GIF output, except perhaps that larger images equal more colors.

GIF was never designed with large images in mind. It was for small 'cartoon' like images with limited size and colors.

To test this out, omit the -density (as that works) but then do a -resize 400% to enlarge the image. See how GIF reacts to that!
That simply stretches the low quality GIF as expected.
anthony wrote: Hmm it may also be that -page is not large enough for a higher density. -page A4 is internally fixed to 595x842 pixels which is the size of an A4 page at 72 dpi. But you use a larger density which means the -page size is about 1/4 the size it should be!

try adding -density and omit -page instead.
Omitting -page seems to work and the gif now works from the individual PNG images. The only problem I have left is that -page was included as otherwise the images were cut off at the bottom when converting the postscript to PNG (bounding box issues?)

Thanks

Re: Convert multi-page PostScript file to animated gif?

Posted: 2012-02-02T19:39:45-07:00
by anthony
-page A4 is equivelent to -page 595x842 which is for the default -density72

for -density 300 use something like -page 2480x3508 (pixels in A4 at 300dpi)

Re: Convert multi-page PostScript file to animated gif?

Posted: 2012-02-03T01:15:34-07:00
by |Rob|
anthony wrote:-page A4 is equivelent to -page 595x842 which is for the default -density72

for -density 300 use something like -page 2480x3508 (pixels in A4 at 300dpi)
If I do that and then try to convert to an animated GIF it just fails in the same way, with the GIF being frozen on the first frame.

This seems to work

Code: Select all

mogrify -format png -density 300 -page 500x700 -trim +repage -rotate "90<"  ch4_proxy_201010_v3.2.ps
and still gives a nice quality GIF image (not sure if I need the repage in there).