Convert multi-page PostScript file to animated gif?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
|Rob|
Posts: 6
Joined: 2012-02-01T04:28:08-07:00
Authentication code: 8675308

Convert multi-page PostScript file to animated gif?

Post 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
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

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

Post 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
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
|Rob|
Posts: 6
Joined: 2012-02-01T04:28:08-07:00
Authentication code: 8675308

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

Post 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.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

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

Post by anthony »

That is strange as GIF format ignores density completely!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
|Rob|
Posts: 6
Joined: 2012-02-01T04:28:08-07:00
Authentication code: 8675308

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

Post 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"?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

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

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
|Rob|
Posts: 6
Joined: 2012-02-01T04:28:08-07:00
Authentication code: 8675308

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

Post 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).
|Rob|
Posts: 6
Joined: 2012-02-01T04:28:08-07:00
Authentication code: 8675308

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

Post 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
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

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

Post 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)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
|Rob|
Posts: 6
Joined: 2012-02-01T04:28:08-07:00
Authentication code: 8675308

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

Post 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).
Post Reply