GraphicsMagick: Cannot convert pdf to jpeg - pdf

I am trying to convert a pdf document ( 95 pages ) to multiple JPEG files, but getting error:
$gm convert -verbose -density 300 TESTIO.pdf +adjoin FOO-%02d.jpg
[ghostscript library] "-q" "-dBATCH" "-dSAFER" "-dMaxBitmap=50000000" "-dNOPAUSE" "-sDEVICE=pnmraw" "-dTextAlphaBits=4" "-dGraphicsAlphaBits=4" "-r300x300" "-sOutputFile=/tmp/gm2BfrxJ" "--" "/tmp/gmWNsJU0" "-c" "quit"Error: /ioerror in --showpage--
Operand stack:
1 true
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1862 1 3 %oparray_pop 1861 1 3 %oparray_pop 1845 1 3 %oparray_pop --nostringval-- --nostringval-- 24 1 95 --nostringval-- %for_pos_int_continue --nostringval-- --nostringval-- 1745 0 9 %oparray_pop --nostringval-- --nostringval--
Dictionary stack:
--dict:1154/1684(ro)(G)-- --dict:1/20(G)-- --dict:76/200(L)-- --dict:76/200(L)-- --dict:106/127(ro)(G)-- --dict:286/300(ro)(G)-- --dict:22/25(L)-- --dict:4/6(L)-- --dict:22/40(L)--
Current allocation mode is local
Last OS error: 28
GPL Ghostscript 8.70: Unrecoverable error, exit code 1
gm convert: Unexpected end-of-file (/tmp/gm2BfrxJ).
Here is the config for GraphicsMagick:
$gm version
GraphicsMagick 1.3.25 2016-09-05 Q8 http://www.GraphicsMagick.org/
Copyright (C) 2002-2016 GraphicsMagick Group.
Additional copyrights and licenses apply to this software.
See http://www.GraphicsMagick.org/www/Copyright.html for details.
Feature Support:
Native Thread Safe yes
Large Files (> 32 bit) yes
Large Memory (> 32 bit) yes
BZIP no
DPS no
FlashPix no
FreeType no
Ghostscript (Library) yes
JBIG no
JPEG-2000 no
JPEG yes
Little CMS no
Loadable Modules no
OpenMP yes (200805)
PNG no
TIFF yes
TRIO no
UMEM no
WebP no
WMF no
X11 no
XML no
ZLIB no
Host type: x86_64-unknown-linux-gnu
Configured using the command:
./configure '--prefix=/usr/local' '--with-modules=yes' '--with-libtiff' '--with-jpeg' '--with-gslib'
Final Build Parameters:
CC = gcc -std=gnu99
CFLAGS = -fopenmp -g -O2 -Wall -pthread
CPPFLAGS =
CXX = g++
CXXFLAGS = -pthread
LDFLAGS =
LIBS = -ltiff -ljpeg -lgs -lm -lgomp -lpthread
also:
$ gs -version
GPL Ghostscript 9.20 (2016-09-26)
Copyright (C) 2016 Artifex Software, Inc. All rights reserved.

Firstly, you are using an ancient version of Ghostscript in your GraphicsMagick. I know that version has returned 9.20, but if you look in the error log you posted you will see "GPL Ghostscript 8.70: Unrecoverable error, exit code 1". So your GraphicsMagick installation is using 8.70.
This looks to me like its caused by the fact that all the output files are being sent to the same filename. The switch -sOutputFile=/tmp/gm2BfrxJ will write all the pages to a single file. If you want them to go to multiple files then you need to specify multiple page output, eg -sOutputFile=/tmp/gm2BfrxJ-%d or similar.
I suspect the problem is simply that GraphicsMagick isn't set up to deal with multiple page files like this. Do the conversion one page at a time. Or have Ghostscript render the pages to JPEG for you.

Related

Am I doing something wrong in gswin64c sDEVICE=pdfwrite?

I've been using Ghostscript in the command line with
gswin64c sDEVICE=pdfwrite -o out.pdf in.pdf
for a long time now with great success. Ghostscript's location is added to the Path variable setting in Windows 10. And today all of a sudden it stopped to work giving the following error message:
GPL Ghostscript 9.55.0 (2021-09-27)
Copyright (C) 2021 Artifex Software, Inc. All rights reserved.
This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:
see the file COPYING for details.
Error: /undefinedfilename in (sDEVICE=pdfwrite)
Operand stack:
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push
Dictionary stack:
--dict:762/1123(ro)(G)-- --dict:0/20(G)-- --dict:75/200(L)--
Current allocation mode is local
Last OS error: No such file or directory
GPL Ghostscript 9.55.0: Unrecoverable error, exit code 1
What I've tried so far
update Ghostscript from 9.54 to 9.55.0
different input file
rename input file
different folder containing the input file
copying the input file to the \gs9.55.0\bin\ folder
running the command line with admin privs
running windows logged in as admin
All to no success and always giving me the same error message. All the files tried are being displayed correctly in any pdf viewer.
What am I doing wrong here? And why suddendly?
Easily done but read the error undefinedfilename in (sDEVICE=pdfwrite)
Whilst not very clear, it thinks you are asking for that file to be processed.
However you should have just like for the -o output file switch added the switch - signal.
Then if there is no IN file the message changes
gswin64c -sDEVICE=pdfwrite -o out.pdf in.pdf
GPL Ghostscript 9.55.0 (2021-09-27)
Copyright (C) 2021 Artifex Software, Inc. All rights reserved.
This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:
see the file COPYING for details.
Error: /undefinedfilename in (in.pdf)
Operand stack:
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push
Dictionary stack:
--dict:764/1123(ro)(G)-- --dict:0/20(G)-- --dict:75/200(L)--
Current allocation mode is local
Last OS error: No such file or directory
GPL Ghostscript 9.55.0: Unrecoverable error, exit code 1
Just a side note that it can sometimes reduce later issues if you get into the habit of using
gswin64c -sDEVICE=pdfwrite -o"out.pdf" -f"in.pdf"

convert: no images defined for making a PDF thumbnail in CentOS

When converting a PDF to a jpg thumbnail, this error occurs:
/usr/bin/convert '/large/sourcefolder/1383f07adadae238d4f27f188c3a0496/a_named_file.pdf' qqq.jpg
convert: Postscript delegate failed `[ghostscript library 9.25] -sstdout=%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pngalpha' -dTextAlphaBits=4 -dGraphicsAlphaBits=4 '-r72x72' '-sOutputFile=/tmp/magick-31299555NM5LlPyTO%d' '-f/tmp/magick-31299wBWMEYcB31Fp' '-f/tmp/magick-31299VUJc3QY8sCs0'': Error: /undefined in 1f7424cb60beea75a472e08293b2ff51a:7:
Operand stack:
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 2047 1 3 %oparray_pop 2046 1 3 %oparray_pop 2026 1 3 %oparray_pop 1884 1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval--
Dictionary stack:
--dict:956/1684(ro)(G)-- --dict:0/20(G)-- --dict:77/200(L)--
Current allocation mode is local
Current file position is 36
GPL Ghostscript 9.25: Unrecoverable error, exit code 1
# error/ghostscript-private.h/InvokeGhostscriptDelegate/171.
convert: no images defined `qqq.jpg' # error/convert.c/ConvertImageCommand/3235.
Sometimes it does convert, and other times not, it is rather fuzzy.
Ghostscript is found, as it is in the same path as convert.
The used OS is Centos 7.
uname -av
Linux my.example.com 4.15.18-15-pve #1 SMP PVE 4.15.18-40 (Tue, 21 May 2019 17:43:20 +0200) x86_64 x86_64 x86_64 GNU/Linux

Ghostscript merge pdf font error: How to define fallback font

How do you give tell ghostscript to use a "fallback" font if a font can't be found?
When executing this Ghostscript command:
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=/output.pdf /input_pdf_with_missing_font.pdf
I am receiving this error:
Error: /undefined in findresource Operand stack: --dict:9/18(L)-- C2_0 1 --dict:6/6(L)-- --dict:6/6(L)-- ArialUnicodeMS --dict:11/12(ro)(G)-- --nostringval-- CIDFontObject --dict:8/8(L)-- --dict:8/8(L)-- Adobe-Identity Execution stack: %interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1862 1 3 %oparray_pop 1861 1 3 %oparray_pop 1845 1 3 %oparray_pop --nostringval-- --nostringval-- 2 1 3 --nostringval-- %for_pos_int_continue --nostringval-- --nostringval-- --nostringval-- --nostringval-- %array_continue --nostringval-- false 1 %stopped_push --nostringval-- %loop_continue --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- %array_continue --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- %loop_continue Dictionary stack: --dict:1149/1684(ro)(G)-- --dict:1/20(G)-- --dict:75/200(L)-- --dict:75/200(L)-- --dict:106/127(ro)(G)-- --dict:286/300(ro)(G)-- --dict:22/25(L)-- --dict:4/6(L)-- --dict:26/40(L)-- Current allocation mode is local Last OS error: 2 GPL Ghostscript 8.70: Unrecoverable error, exit code 1
You need a newer version of Ghostscript (it would help with these sorts of questions if you would state the version in use).
You appear to be using version 8.70 which is now more than 7 years old, the current version is 9.20. The current version ships with a default CIDFont (your PDF file fails to embed a CIDFont, not a Font).
You will have to check the documentation supplied with Ghostscript 8.70 to see how to define substitute resources (see the Ghostscript installation folder and then the 'doc' subfolder), I don't recall if the current method works with such an archaic version. However the current version documentation on CIDFont substitution can also be found here
I took #KenS's advice and installed Ghostscript to 9.20 (I wanted to keep the old version in place for other legacy projects)
Here are the steps (I followed these instructions):
Locate the source package of GS: https://github.com/ArtifexSoftware/ghostpdl-downloads/releases
In my case: https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs920/ghostscript-9.20.tar.gz
Run the following commands:
cd /tmp
wget
https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs920/ghostscript-9.20.tar.gz
tar xzf ghostscript-9.20.tar.gz
cd ghostscript-9.20
./configure --prefix=/usr/bin/gs9
make
sudo make install
And to run the new version:
/usr/bin/gs9/bin/gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=/some/target/file.pdf /some/source/file.php
And no more font issues!!

Installing SCIP on OSX: outdated libisl?

I'm trying to install SCIP on OSX mavericks. I've downloaded the tarball here, extracted it, and have tried to compile it using
make scipoptlib GMP=false ZLIB=false READLINE=false SHARED=true
This gives me error 1 below. My interpretation of error 1 is that /usr/local/lib/libisl.10.dylib does not exist. That's correct: I have isl.0.14.1, located at /usr/local/Cellar/isl/0.14.1. And in fact I can't install isl.0.10.1, because the compiler options it expects don't work with the current version of gcc (I think; see error 2 below).
Can I tell SCIP to use isl.0.14.1, and if so, how?
**error 1:**
** Extracting SoPlex archive "/Applications/scipoptsuite-3.2.0/soplex-2.2.0.tgz".
** Extracting ZIMPL archive "/Applications/scipoptsuite-3.2.0/zimpl-3.3.3.tgz".
** Extracting SCIP archive "/Applications/scipoptsuite-3.2.0/scip-3.2.0.tgz".
** compile libraries statically with compiler flag -fPIC
rm -rf obj/O.darwin.x86_64.gnu.normal.opt/* bin/zimpl-3.3.3.darwin.x86_64.gnu.normal.opt lib/libzimpl-3.3.3.darwin.x86_64.gnu.opt.a lib/libzimpl-3.3.3.darwin.x86_64.gnu.opt.dbl.a lib/libzimpl.darwin.x86_64.gnu.opt.a bin/zimpl.darwin.x86_64.gnu.opt bin/zimpl
** Creating directory "/Applications/scipoptsuite-3.2.0/scip-3.2.0/lib".
** Creating directory "/Applications/scipoptsuite-3.2.0/scip-3.2.0/lib/zimplinc".
** Building SoPlex library "/Applications/scipoptsuite-3.2.0/soplex-2.2.0/lib/libsoplex.darwin.x86_64.gnu.opt.a".
-> compiling obj/O.darwin.x86_64.gnu.opt/lib/changesoplex.o
dyld: Library not loaded: /usr/local/lib/libisl.10.dylib
Referenced from: /usr/local/Cellar/gcc/4.9.1/libexec/gcc/x86_64-apple-darwin13.2.0/4.9.1/cc1plus
Reason: image not found
g++: internal compiler error: Trace/BPT trap: 5 (program cc1plus)
make[4]: *** [obj/O.darwin.x86_64.gnu.opt/lib/changesoplex.o] Abort trap: 6
make[3]: [makelibfile] Error 2 (ignored)
-> compiling obj/O.darwin.x86_64.gnu.opt/lib/changesoplex.o
dyld: Library not loaded: /usr/local/lib/libisl.10.dylib
Referenced from: /usr/local/Cellar/gcc/4.9.1/libexec/gcc/x86_64-apple-darwin13.2.0/4.9.1/cc1plus
Reason: image not found
g++: internal compiler error: Trace/BPT trap: 5 (program cc1plus)
make[4]: *** [obj/O.darwin.x86_64.gnu.opt/lib/changesoplex.o] Abort trap: 6
make[3]: [all] Error 2 (ignored)
** ZIMPL support disabled.
** Creating necessary soft-links.
** Building SCIP libraries and executable.
-> generating necessary links
- Current settings: LPS=spx OSTYPE=darwin ARCH=x86_64 COMP=gnu SUFFIX= ZIMPL=false ZIMPLOPT=opt IPOPT=false IPOPTOPT=opt EXPRINT=cppad GAMS=false
* SCIP needs some softlinks to external programs, in particular, LP-solvers.
* Please insert the paths to the corresponding directories/libraries below.
* The links will be installed in the 'lib' directory.
* For more information and if you experience problems see the INSTALL file.
-> "spxinc" is the path to the SoPlex "src" directory, e.g., "../../soplex/src".
-> "libsoplex.*" is the path to the SoPlex library, e.g., "../../soplex/lib/libsoplex.darwin.x86_64.gnu.opt.a"
-> compiling obj/O.darwin.x86_64.gnu.opt/lib/scip/branch_allfullstrong.o
dyld: Library not loaded: /usr/local/lib/libisl.10.dylib
Referenced from: /usr/local/Cellar/gcc/4.9.1/libexec/gcc/x86_64-apple-darwin13.2.0/4.9.1/cc1
Reason: image not found
gcc: internal compiler error: Trace/BPT trap: 5 (program cc1)
make[4]: *** [obj/O.darwin.x86_64.gnu.opt/lib/scip/branch_allfullstrong.o] Abort trap: 6
make[3]: *** [makesciplibfile] Error 2
make[2]: *** [scipbinary] Error 2
make[1]: *** [scipbinary] Error 2
make: *** [scipoptlib] Error 2
error 2, produced by running ./configure in libisl.10 directory:
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by isl configure 0.10, which was
generated by GNU Autoconf 2.68. Invocation command line was
$ ./configure
## --------- ##
## Platform. ##
## --------- ##
hostname = dhcp-143-183.caltech.edu
uname -m = x86_64
uname -r = 13.4.0
uname -s = Darwin
uname -v = Darwin Kernel Version 13.4.0: Wed Mar 18 16:20:14 PDT 2015; root:xnu-2422.115.14~1/RELEASE_X86_64
/usr/bin/uname -p = i386
/bin/uname -X = unknown
/bin/arch = unknown
/usr/bin/arch -k = unknown
/usr/convex/getsysinfo = unknown
/usr/bin/hostinfo = Mach kernel version:
Darwin Kernel Version 13.4.0: Wed Mar 18 16:20:14 PDT 2015; root:xnu-2422.115.14~1/RELEASE_X86_64
Kernel configured for up to 4 processors.
2 processors are physically available.
4 processors are logically available.
Processor type: i486 (Intel 80486)
Processors active: 0 1 2 3
Primary memory available: 16.00 gigabytes
Default processor set: 327 tasks, 1905 threads, 4 processors
Load average: 4.32, Mach factor: 0.47
/bin/machine = unknown
/usr/bin/oslevel = unknown
/bin/universe = unknown
PATH: /Users/madeleine/anaconda/bin/
PATH: /usr/local/bin
PATH: /usr/bin
PATH: /bin
PATH: /usr/sbin
PATH: /sbin
PATH: /usr/local/bin
PATH: /opt/X11/bin
PATH: /usr/local/go/bin
PATH: /usr/texbin
PATH: /usr/bin
PATH: /bin
PATH: /usr/sbin
PATH: /sbin
PATH: /opt/local/bin
PATH: /opt/local/sbin
PATH: /Applications/spark-0.9.1-bin-hadoop2/bin
PATH: /Applications/Julia-0.3.8.app/Contents/Resources/julia/bin
## ----------- ##
## Core tests. ##
## ----------- ##
configure:2762: checking for a BSD-compatible install
configure:2830: result: /usr/bin/install -c
configure:2841: checking whether build environment is sane
configure:2891: result: yes
configure:3032: checking for a thread-safe mkdir -p
configure:3071: result: ./install-sh -c -d
configure:3084: checking for gawk
configure:3114: result: no
configure:3084: checking for mawk
configure:3114: result: no
configure:3084: checking for nawk
configure:3114: result: no
configure:3084: checking for awk
configure:3100: found /usr/bin/awk
configure:3111: result: awk
configure:3122: checking whether make sets $(MAKE)
configure:3144: result: yes
configure:3287: checking for gcc
configure:3303: found /usr/local/bin/gcc
configure:3314: result: gcc
configure:3543: checking for C compiler version
configure:3552: gcc --version >&5
gcc (Homebrew gcc 4.9.1) 4.9.1
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
configure:3563: $? = 0
configure:3552: gcc -v >&5
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/4.9.1/libexec/gcc/x86_64-apple-darwin13.2.0/4.9.1/lto-wrapper
Target: x86_64-apple-darwin13.2.0
Configured with: ../configure --build=x86_64-apple-darwin13.2.0 --prefix=/usr/local/Cellar/gcc/4.9.1 --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-4.9 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-cloog=/usr/local/opt/cloog --with-isl=/usr/local/opt/isl --with-system-zlib --enable-version-specific-runtime-libs --enable-libstdcxx-time=yes --enable-stage1-checking --enable-checking=release --enable-lto --disable-werror --with-pkgversion='Homebrew gcc 4.9.1' --with-bugurl=https://github.com/Homebrew/homebrew/issues --enable-plugin --disable-nls --enable-multilib
Thread model: posix
gcc version 4.9.1 (Homebrew gcc 4.9.1)
configure:3563: $? = 0
configure:3552: gcc -V >&5
gcc: error: unrecognized command line option '-V'
gcc: fatal error: no input files
compilation terminated.
configure:3563: $? = 1
configure:3552: gcc -qversion >&5
gcc: error: unrecognized command line option '-qversion'
gcc: fatal error: no input files
compilation terminated.
configure:3563: $? = 1
configure:3583: checking whether the C compiler works
configure:3605: gcc conftest.c >&5
dyld: Library not loaded: /usr/local/lib/libisl.10.dylib
Referenced from: /usr/local/Cellar/gcc/4.9.1/libexec/gcc/x86_64-apple-darwin13.2.0/4.9.1/cc1
Reason: image not found
gcc: internal compiler error: Trace/BPT trap: 5 (program cc1)
./configure: line 3607: 9063 Abort trap: 6 $CC $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5
I can't see where or why the SCIP Optimization Suite would be using isl. To be precise, in your case not SCIP fails to compile but SoPlex. Have you checked whether you can compile SoPlex alone? Just go into the subdirectory and type make or make SHARED=true GMP=false ZLIB=false to match the original command.
Have you compiled some other code with your compiler? It may also be that your gcc itself is broken.
I have the impression that the C++ compiler itself is broken:
dyld: Library not loaded: /usr/local/lib/libisl.10.dylib
Referenced from: /usr/local/Cellar/gcc/4.9.1/libexec/gcc/x86_64-apple-darwin13.2.0/4.9.1/cc1plus
Maybe try a simple (hello-world) C++ program first to test that the compiler itself is ok.

Ghostscript ERROR: /undefined in --get--

I'm trying to use Ghostscript in CentOS. When trying to issue the following Ghostscript command ghostscript -sDEVICE=pcx256 -r150x150 -sOutputFile=OUTPUT_FILE INPUT_PDF I am getting the following error:
ESP Ghostscript 815.02 (2006-04-19)
Copyright (C) 2004 artofcode LLC,
Benicia, CA. All rights reserved.
This software comes with NO WARRANTY:
see the file PUBLIC for details.
Processing pages 1 through 1. Page 1
ERROR: /undefined in --get-- Operand
stack: --dict:8/8(L)--
--dict:8/11(L)-- CS0 --dict:10/10(ro)(G)-- CS0 Execution stack: %interp_exit .runexec2
--nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1 3 %oparray_pop
1 3 %oparray_pop 1 3
%oparray_pop --nostringval--
--nostringval-- 2 1 1 --nostringval-- %for_pos_int_continue
--nostringval-- --nostringval-- --nostringval-- --nostringval-- %array_continue --nostringval--
false 1 %stopped_push
--nostringval-- %loop_continue --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- Dictionary stack: --dict:1121/1686(ro)(G)-- --dict:0/20(G)-- --dict:107/200(L)-- --dict:107/200(L)-- --dict:104/127(ro)(G)-- --dict:241/347(ro)(G)-- --dict:20/24(L)-- --dict:4/6(L)-- --dict:21/32(L)-- --dict:1/1(ro)(G)-- --dict:3/5(L)-- --dict:1/1(ro)(G)-- --dict:1/1(ro)(G)-- --dict:1/1(ro)(G)-- --dict:8/11(L)-- Current allocation mode is local Last
OS error: 2 ESP Ghostscript 815.02:
Unrecoverable error, exit code 1
Any help is supper appreciated! I've been Googling all weekend for an answer.
Solved it! I had an older version running and I assumed that yum would automatically get the latest n greatest. Removed old version, installed the most current version by building and installing from source. Done.