ImageMagick - Convert a GIF to PDF portrait(letter) on half page using convert command
-
28-06-2021 - |
Question
I have a image of dimension 1400x800, which I need to convert to a PDF so that the PDF is in in Portrait form & contains the image in top/bottom half of the page. I need to use ImageMagick 6.4.8 2009-09-21 as that is the only available on my production server. Cannot use Ghostscript.
Image Details
>identify sample.gif
sample.gif GIF 1400x800 1400x800+0+0 8-bit PseudoClass 256c 29.3kb
I have tried all the options that I found out & nothing works. It always converts to a Landscape with the image occupying the complete page.
Here are some of the options that I tried:
convert -bordercolor none -border 100x100 -page Letter -density 72 sample.gif -resize 792x612\! sample.pdf
convert -bordercolor none -border 100x100 -page Letter -density 72 sample.gif -resize 612x792\! sample.pdf
convert -density 72 -size 1400x800 sample.gif -page Letter -density 72 -resize 504x288 -bordercolor none -border 11%x14% sample.pdf
and many such combinations, but nothing works. I use -resize 612x792 so that its letter size, but then the image also gets stretched vertically. Is it possible to achieve what I am trying to, what options am I missing?
Note: I have to do this in a program so need a command based solution using convert.
Solution
My guess is that you are using this to print shipping labels. Either way try this
convert -size 1700x2200 xc:white sample.gif -geometry 1400x800+150+150 -composite -page Letter -quality 100 sample.pdf