Page 1 of 1

convert pdf generates corrupt image

Posted: 2017-06-18T02:31:57-07:00
by maqe
I'm using ImageMagick with a docker container. My image looks like this.

FROM alpine:latest
LABEL maintainer "Jessie Frazelle <jess@linux.com>"

RUN apk --no-cache add \
imagemagick \
ghostscript \
--update curl

CMD [ "echo", "Use one of the following commands [ animate | compare | composite | conjure | convert | display | identify | import | mogrify | montage | stream ]" ]

The version of ImageMagick is:

Version: ImageMagick 7.0.5-10 Q16 x86_64 2017-06-05 http://www.imagemagick.org
Copyright: © 1999-2017 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher HDRI Modules
Delegates (built-in): fontconfig freetype gslib jng jpeg lcms ltdl png ps tiff webp xml zlib

When I run the following command ImageMagick produces a corrupt image.

docker run imagemagick convert -verbose http://www.pdf995.com/samples/pdf.pdf[0] - > foo.jpg
/tmp/magick-1-JjeGtapAEMe1 PNG 612x792 612x792+0+0 8-bit sRGB 60787B 0.020u 0:00.020
/tmp/magick-1et9Ro9BFOGOh PDF 612x792 612x792+0+0 16-bit sRGB 60787B 0.000u 0:00.000
http://www.pdf995.com/samples/pdf.pdf[0]=>pdf.pdf PDF 612x792 612x792+0+0 16-bit sRGB 60787B 0.000u 0:00.000

When I try to open the image it produces I get an error that it's corrupt or damaged?

This is a link to the converted image: https://d26dzxoao6i3hh.cloudfront.net/i ... 3I/foo.jpg

Re: convert pdf generates corrupt image

Posted: 2017-06-18T07:34:25-07:00
by snibgo
maqe wrote:convert -verbose http://www.pdf995.com/samples/pdf.pdf[0] - > foo.jpg
Using "-" as the output, you are not telling IM what format to use. So IM uses the same as the input format, in this case PDF. You write that to a file called "foo.jpg", but this isn't JPEG format.

The command you want is:

Code: Select all

convert -verbose http://www.pdf995.com/samples/pdf.pdf[0] foo.jpg

Re: convert pdf generates corrupt image

Posted: 2017-06-18T10:01:22-07:00
by maqe
I use the pipe "-" to output the image to stdout. How can I output to stdout and still tell IM to use jpeg format?

Re: convert pdf generates corrupt image

Posted: 2017-06-18T10:15:52-07:00
by maqe
It seems like jpeg:- works if I want to output the image to stdout. Is it the recommended way to it?

Re: convert pdf generates corrupt image

Posted: 2017-06-18T10:17:51-07:00
by snibgo
Yes. Prefix the output with the required format, eg:

Code: Select all

convert -verbose http://www.pdf995.com/samples/pdf.pdf[0] JPG:-