Add images in existing pdf file from command line

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
and
Posts: 5
Joined: 2017-08-06T23:15:17-07:00
Authentication code: 1151

Add images in existing pdf file from command line

Post by and »

Hello!

I must add images to the end of an existing PDF file.
Tried using the command:
convert 1.jpg -adjoin 1.pdf.

The file is rewrite with only one this image.
Is it possible to do this at all with the command line?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Add images in existing pdf file from command line

Post by fmw42 »

You need an output image and an input image and the extra page image. So if you have 1.pdf and want to add 1.jpg, you would do

Code: Select all

convert 1.pdf 1.jpg 1.pdf
But Imagemagick will rasterize your pdf. So any vector data will not be preserved. Also you may need to specify the density for decoding your input pdf.

Code: Select all

convert -density XXX 1.pdf 1.jpg 1.pdf

Please, always provide your IM version and platform when asking questions, since syntax may differ.

See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at viewtopic.php?f=1&t=9620

For novices, see

viewtopic.php?f=1&t=9620http://http://w ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
and
Posts: 5
Joined: 2017-08-06T23:15:17-07:00
Authentication code: 1151

Re: Add images in existing pdf file from command line

Post by and »

Both commands lead to an error.

D:\Projects\01_Digitizer\11_Usable\ImageMagic\ImageMagick-7.0.6-4-portable-Q16-x
86>convert 1.pdf 1.jpg 1.pdf
convert: FailedToExecuteCommand `"gswin32c.exe" -q -dQUIET -dSAFER -dBATCH -dNOP
AUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=
pngalpha" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" "-sOutputFile=C:/Us
ers/VELGAN~1/AppData/Local/Temp/magick-4456wVRL28w5MGQB%d" "-fC:/Users/VELGAN~1/
AppData/Local/Temp/magick-4456iOaLzm191n5n" "-fC:/Users/VELGAN~1/AppData/Local/T
emp/magick-44567wxTnrZfMIPY"' (Can not find the specified file.
) @ error/delegate.c/ExternalDelegateCommand/460.
convert: PDFDelegateFailed `Can not find the specified file.
' @ error/pdf.c/ReadPDFImage/793.

We use IM: 7.0.6-4;
Windows 7 x64. SP1.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Add images in existing pdf file from command line

Post by snibgo »

IM is trying to run Ghostscript, and failing. Perhaps GS isn't installed. You can install it from https://www.ghostscript.com/download/gsdnld.html
snibgo's IM pages: im.snibgo.com
Post Reply