How to convert from PDF if Ghostscript is not installed

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
idy58
Posts: 2
Joined: 2019-07-31T14:24:25-07:00
Authentication code: 1152

How to convert from PDF if Ghostscript is not installed

Post by idy58 »

I'm trying to convert PDF to JPEG using AWS Lambda service. This means that the server where the command executes doesn't have either Imagemagick or Ghostscript installed and that I need to provide self-contained binary with my code. For certain internal reasons I have to use Imagemagick 6 for this.

I've built the binaries on a vanilla AWS Linux server from the tarballs downloaded from imagemagic.org with all sort of imaginable combinations of

Code: Select all

--prefix=/var/task/imagemagick --enable-shared=no --enable-static=yes --disable-installed --with-gslib=yes
... switches to configure to no avail: unless I have Ghostscript installed my convert commands return the following error:
convert -alpha deactivate -colorspace RGB -geometry 364 -crop 348x640+8+32 /tmp/Nxxx,2019-07-14,A,001.pdf /tmp/Nxxx,2019-07-14,A,001.jpg
convert: NoImagesDefined `/tmp/Nxxx,2019-07-14,A,001.jpg' @ error/convert.c/ConvertImageCommand/3235.
Here's what configure invariably returns:
Delegate Program Configuration:
GhostPCL None pcl6 (unknown)
GhostXPS None gxps (unknown)
Ghostscript None gs (8.70)

Font Configuration:
Apple fonts --with-apple-font-dir=default
Dejavu fonts --with-dejavu-font-dir=default /usr/share/fonts/dejavu/
Ghostscript fonts --with-gs-font-dir=default /usr/share/fonts/default/Type1/
URW-base35 fonts --with-urw-base35-font-dir=default none
Windows fonts --with-windows-font-dir=default none

X11 Configuration:
X_CFLAGS =
X_PRE_LIBS =
X_LIBS =
X_EXTRA_LIBS =

Options used to compile and link:
PREFIX = /var/task/imagemagick
EXEC-PREFIX = /var/task/imagemagick
VERSION = 6.9.10
CC = gcc -std=gnu99 -std=gnu99
CFLAGS = -I/usr/include/libpng12 -fopenmp -g -O2 -Wall -mtune=core-avx2 -fexceptions -pthread -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16
CPPFLAGS = -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16
PCFLAGS =
DEFS = -DHAVE_CONFIG_H
LDFLAGS =
LIBS = -ltiff -ljpeg -lpng12 -lz -lm
CXX = g++
CXXFLAGS = -pthread
FEATURES = DPC Cipher OpenMP
DELEGATES = mpeg jng jpeg png ps tiff zlib
So I guess the real question here is: how to add PDF support without installing Ghostscript?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to convert from PDF if Ghostscript is not installed

Post by fmw42 »

So I guess the real question here is: how to add PDF support without installing Ghostscript?
You cannot. Ghostscript is needed/used by ImageMagick to read PDF files. ImageMagick will write PDF files without it.
idy58
Posts: 2
Joined: 2019-07-31T14:24:25-07:00
Authentication code: 1152

Re: How to convert from PDF if Ghostscript is not installed

Post by idy58 »

Thanks fmw42. If that's the final answer then I know what to do, I'll just have to provide Ghostscript binaries as well. Problem is, the size allotted for Lambda functions is very limited. That's why I was hoping for something more compact than that.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to convert from PDF if Ghostscript is not installed

Post by fmw42 »

Unfortunately, ImageMagick delegates reading of PDF files to Ghostscript. ImageMagick can created PDF files without it, but needs it to read PDF files.
Post Reply