I am using the convert
version of ImageMagick 6.6.2-6 2011-03-16, and I would like to use it to create an A4 PDF with an image where the image will be unscaled and centered,
I run the following (as a modification of Overlaying Images with ImageMagick ):
# generate a 100x100 JPG with just red color convert -size 100x100 xc:red red.jpg # generate PDF from JPG convert -page A4 xc:white red.jpg -gravity center -composite -format pdf out.pdf
... but basically shows nothing? The same thing happens for the png image ...
note that
- Only "
convert -page A4 red.jpg out.pdf
" works, but the image is not centered; ( -gravity center
makes the image not show) - If the image png, '
convert -page A4 -gravity center red.png out.pdf
' really works fine
... however, I would like convert
embed the contents of the JPEG stream directly - hence, I would not want to convert JPG to PNG first.
So, is it possible to use convert
to center a JPG image on a PDF PDF page directly?
Thanks a lot in advance for any answers,
Hurrah!
EDIT2: @John Keyes is responsible for the example above; where the image is "smaller" than the size of the PDF, however, if the image is larger, for example:
$ convert -size 1228x1706 -background \
... then it will fail. However, it turns out: " if you change -extent to 50x50, and then play with -gravity, you will see the changes " - with the exception of the question: to what extent will you change the image of the image or the final PDF file?
Well, it turns out this is the size of the final PDF ... To find this size, as convert
sees it, check the page: Magick :: Geometry - however, note that "Postscript page size specifications" such as " A4+43+43>
"unfortunately convert
fail in this context ... But at least the corresponding numbers for the size (595x842) can be copied from the page; and finally it works:
convert -page A4 -gravity center -resize 595x842 -extent 595x842 red.jpg out.pdf
... and in fact, the -extent
part -extent
not needed - the -resize
part is important for displaying a large image.
However, the problem is that the included image seems to be oversampled - however, I just wanted to show it scaled to fit the page, but otherwise I would like the original JPG stream to be inserted into the file .. Therefore, I think that the question is still partially open :)
EDIT: Related: