TritonDataCenter / pkgsrc

NetBSD/pkgsrc fork for our binary package repositories
https://pkgsrc.smartos.org/
134 stars 50 forks source link

ghostscript fails to generate a png from a pdf #122

Closed jfqd closed 6 years ago

jfqd commented 6 years ago

I am struggling to generate a png from a given pdf with ghostscript 9.23 (agpl) on SmartOS 2018Q1.

gs -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 -sDevice=pngalpha -dTextAlphaBits=4 -dGraphicsAlphaBits=4 '-r300x300' -dFirstPage=1 -dLastPage=1 -sOutputFile=a.png a.pdf

Outputs:

GPL Ghostscript 9.23 (2018-03-21)
Copyright (C) 2018 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
GPL Ghostscript 9.23: Cannot open X display `(null)'.
**** Unable to open the initial device, quitting.

If I set export GS_DEVICE=display before, I get the following output:

GPL Ghostscript 9.23 (2018-03-21)
Copyright (C) 2018 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
   **** Warning: considering '0000000000 XXXXX n' as a free entry.
   **** Warning: considering '0000000000 XXXXX n' as a free entry.
Processing pages 1 through 1.
Page 1
GPL Ghostscript 9.23: Unrecoverable error, exit code 255

Running the same command on my macOS 10.13 with the brew installed ghostscript works fine:

GPL Ghostscript 9.23 (2018-03-21)
Copyright (C) 2018 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 1.
Page 1
%%BoundingBox: 42 0 399 596
%%HiResBoundingBox: 42.480002 0.000000 398.160015 595.200023

The following packages are installed on the SmartOS vm:

ImageMagick-7.0.7.26 Package for display and interactive manipulation of images
adobe-cidfonts-20000901 Adobe CID-keyed O'Reilly fonts for CJK
adobe-cmaps-20060615 Adobe CMap files for CJK
apr-1.6.3            Apache Portable Runtime
apr-util-1.6.1nb1    Apache Portable Runtime utilities
autogen-5.18.10nb2   The Automated Text and Program Generation Tool
binutils-2.26.1      GNU binary utilities
bmake-20150505       Portable (autoconf) version of NetBSD 'make' utility
boehm-gc-7.6.2nb1    Garbage collection and memory leak detection for C and C++
bootstrap-mk-files-20170802 *.mk files for the bootstrap bmake utility
bsdinstall-20160108  Portable version of the BSD install(1) program
bzip2-1.0.6nb1       Block-sorting file compressor
changepass-1.3.3     Simple tool to set user passwords non-interactively
curl-7.59.0          Client that groks URLs
cwrappers-20180325   pkgsrc compiler wrappers
cyrus-sasl-2.1.26nb7 Simple Authentication and Security Layer
db4-4.8.30           Berkeley DB version 4 from Oracle
dtracetools-1.0      DTraceTools for Joyent SmartMachines
expat-2.2.4nb1       XML parser library written in C
fftw-3.3.7           Collection of fast C routines to compute DFTs
fontconfig-2.13.0nb1 Library for configuring and customizing font access
freetype2-2.9        Font rendering engine and library API
gcc49-4.9.4nb6       The GNU Compiler Collection (GCC) - 4.9 Release Series
gcc49-libs-4.9.4nb6  The GNU Compiler Collection (GCC) support shared libraries
gdbm-1.14.1          The GNU database manager
gettext-lib-0.19.8.1 Internationalized Message Handling Library (libintl)
ghostscript-9.05nb11 Meta-package for installing the preferred ghostscript version
ghostscript-agpl-9.23 Postscript interpreter
ghostscript-cidfonts-20000901nb6 CIDFont resources for Ghostscript
ghostscript-cmaps-20020913nb3 CMap resources for Ghostscript
ghostscript-fonts-8.11nb3 Postscript fonts for Aladdin Ghostscript
giflib-5.1.4         GIF image format library
git-base-2.16.3      GIT Tree History Storage Tool (base package)
gmake-4.1nb3         GNU version of 'make' utility
gmp-6.1.2            Library for arbitrary precision arithmetic
gnupg-1.4.22nb2      GNU Privacy Guard, public-Key encryption and digital signatures
gnutls-3.6.0         GNU Transport Layer Security library
grep-3.1nb1          GNU grep
gsed-4.4             GNU implementation of sed, the POSIX stream editor
guile20-2.0.14nb2    Official extension language for the GNU operating system (2.0 branch)
icu-60.2             Robust and full-featured Unicode services
jbig2dec-0.14        JBIG2 decoder library
jbigkit-2.1          JBIG-KIT lossless image compression library
lcms2-2.8            Little Color Management System - a color management library
libICE-1.0.9nb1      Inter Client Exchange (ICE) library for X
libSM-1.2.2nb1       X Session Management Library
libX11-1.6.5nb1      Base X libraries from modular Xorg X11
libXau-1.0.8nb1      Authorization Protocol for X from X.org
libXdmcp-1.1.2nb1    X Display Manager Control Protocol library from X.org
libXext-1.3.3nb1     X Extension library
libXmu-1.1.2         X Miscellaneous Utilities library
libXt-1.1.5nb1       X Toolkit Intrinsics library
libarchive-3.3.2     Library to read/create different archive formats
libatomic_ops-7.6.2nb1 Multi-platform library of atomic operations by Hans Boehm
libcfg+-0.7.0        Command line and configuration file parsing library
libevent-2.1.8nb1    Asynchronous event notification library
libffi-3.2.1nb4      Foreign function interface
libgcrypt-1.8.2      GNU cryptographic library
libgpg-error-1.28nb1 Definitions of common error values for all GnuPG components
libiconv-1.14nb3     Character set conversion library
libidn-1.33          Internationalized Domain Names command line tool
libidn2-2.0.4        Convert internationalized domain names to/from ASCII Encoding
libjpeg-turbo-1.5.0  Accelerated libjpeg with SIMD instructions
libltdl-2.4.6        Generic shared library support (libltdl abstraction library)
libpaper-1.1.24      Paper size handling library
libpcap-1.8.1        System-independent interface for user-level packet capture
libssh2-1.8.0        SSH2 protocol library
libtasn1-4.12        ASN.1 structure parser library
libunistring-0.9.9   Unicode string library
libuuid-2.31         Generate unique identifiers for objects
libwebp-0.6.1        WebP image format library and tools
libxcb-1.13          X protocol C-language Binding
libxml2-2.9.8        XML parser library from the GNOME project
libxslt-1.1.32       XSLT parser library from the GNOME project
libyaml-0.1.7        YAML 1.1 parser and emitter written in C
lzo-2.10             Portable lossless data compression library
mcookie-2.31         Tool for creating cookies for xauth(1)
mit-krb5-1.14.6      MIT Kerberos 5 authentication system
mozilla-rootcerts-1.0.20180111 Root CA certificates from the Mozilla Project
nawk-20121220nb1     Brian Kernighan's pattern-directed scanning and processing language
nbsed-20120308       NetBSD-current's sed(1)
ncurses-6.0nb5       CRT screen handling and optimization package
ncursesw-6.0nb4      Wide character CRT screen handling and optimization package
nettle-3.4           Cryptographic library
nghttp2-1.31.0       Implementation of HTTP/2 in C
nicstat-1.92         Network traffic statics utility for Solaris and Linux
nodejs-9.8.0         V8 JavaScript for clients and servers
nullmailer-2.1nb1    Simple relay-only mail transport agent
openjpeg-2.3.0       JPEG 2000 library
openldap-client-2.4.45 Lightweight Directory Access Protocol libraries and client programs
openssl-1.0.2o       Secure Socket Layer and cryptographic library
p5-Authen-SASL-2.16nb5 Perl module to handle SASL authentication
p5-Crypt-SSLeay-0.72nb4 Crypt::SSLeay - OpenSSL glue that provides LWP https support
p5-Digest-HMAC-1.03nb7 Perl5 module for HMAC
p5-Email-Valid-1.202nb1 Perl5 module for testing validity of an email address
p5-Encode-Locale-1.05nb3 Determine the locale encoding for Encode
p5-Error-0.17025     Perl extension module for try/throw/catch exception handling
p5-Exporter-Tiny-1.000000nb1 Exporter with the features of Sub::Exporter but only core dependencies
p5-File-Listing-6.04nb6 Perl 5 module providing a directory parser
p5-Filter-1.58       Perl5 classes representing a number of source filters
p5-GSSAPI-0.28nb8    Perl extension providing access to the GSSAPIv2 library
p5-HTML-Parser-3.72nb2 Perl5 module to parse HTML text documents
p5-HTML-Tagset-3.20nb9 Perl5 module of data tables useful in parsing HTML
p5-HTTP-Cookies-6.04 HTTP cookie jars
p5-HTTP-Daemon-6.01nb6 Simple http server class
p5-HTTP-Date-6.02nb6 Perl 5 module providing date conversion routines
p5-HTTP-Message-6.15 Construct HTTP style messages
p5-HTTP-Negotiate-6.01nb6 Negotiate HTTP service parameters
p5-IO-CaptureOutput-1.11.04nb3 Capture STDOUT and STDERR from Perl code, subprocesses, or XS
p5-IO-HTML-1.001nb3  Open an HTML file with automatic charset detection
p5-IO-Socket-INET6-2.72nb3 Perl object interface for AF_INET/AF_INET6 domain sockets
p5-IO-Socket-SSL-2.056 Perl5 SSL socket interface class
p5-LWP-MediaTypes-6.02nb6 Guess media type for a file or a URL
p5-LWP-Protocol-https-6.07nb1 Provide https support for LWP::UserAgent
p5-LWP-UserAgent-Determined-1.07nb3 Perl5 virtual browser that retries errors
p5-List-MoreUtils-0.428 Provide the stuff missing in List::Util
p5-List-MoreUtils-XS-0.428 Provide compiled List::MoreUtils functions
p5-MailTools-2.20    Perl5 modules related to mail applications
p5-Mozilla-CA-20180117 Mozilla's CA cert bundle for Perl
p5-Net-CIDR-0.18nb3  Perl5 module to manipulate IPv4/IPv6 netblocks in CIDR notation
p5-Net-DNS-1.15      Perl5 module for DNS resolution
p5-Net-Domain-TLD-1.75nb1 Work with TLD names
p5-Net-HTTP-6.17     Perl 5 module for low-level HTTP connections (client)
p5-Net-IP-1.26nb5    Perl extension for manipulating IPv4/IPv6 addresses
p5-Net-LibIDN-0.12nb9 Perl bindings for GNU Libidn
p5-Net-SMTP-SSL-1.04nb1 Perl5 module providing SSL support for Net::SMTP
p5-Net-SSLeay-1.85   Perl5 module for using OpenSSL
p5-Net-Server-2.009  Perl5 modules for network services engine
p5-Path-Class-0.37nb1 Cross-platform path specification manipulation
p5-Socket6-0.28nb1   Perl5 module to support getaddrinfo() and getnameinfo()
p5-Switch-2.17nb1    Switch statement for Perl
p5-Text-Balanced-2.03nb3 Extract delimited text sequences from strings
p5-Time-HiRes-1.9758 Perl5 module for high resolution time, sleep, and alarm
p5-TimeDate-2.30nb4  Perl5 TimeDate distribution
p5-Try-Tiny-0.30     Minimal try/catch with proper preservation of $@
p5-URI-1.73          Perl5 Uniform Resource Identifiers class (URI, RFC 2396)
p5-WWW-RobotRules-6.02nb6 Perl 5 module database of robots.txt-derived permissions
p5-libwww-6.33       Perl5 library for WWW access
patch-2.7.6          Patch files using diff output
pcre-8.42            Perl Compatible Regular Expressions library
pcre2-10.30nb1       Perl Compatible Regular Expressions library (major version 2)
perl-5.26.1nb2       Practical Extraction and Report Language
pkg_alternatives-1.6 Generic wrappers for programs with similar interfaces
pkg_install-20180325 Package management and administration tools for pkgsrc
pkg_install-info-4.5nb3 Standalone GNU info file installation utility
pkgconf-1.4.1nb1     API-driven pkg-config replacement
pkgin-0.9.4nb8       Apt / yum like tool for managing pkgsrc binary packages
pkgsrc-gnupg-keys-20170418 GnuPG keys for pkgsrc infrastructure
png-1.6.34           Library for manipulating PNG images
py27-expat-2.7.14    Python interface to expat
py27-pip-9.0.3       Installs Python packages as an easy_install replacement
py27-setuptools-39.0.1 New Python packaging system
py27-sqlite3-2.7.14nb11 Built-in sqlite support for Python 2.5 and up
python27-2.7.14      Interpreted, interactive, object-oriented programming language
readline-7.0         GNU library that can recall and edit previous input
smtools-20160926     Joyent tools relevant to SmartOS and SmartMachines
spiped-1.5.0nb1      Tool for creating symmetrically encrypted and authenticated pipes
sqlite3-3.22.0       SQL Database Engine in a C Library
sudo-1.8.22          Allow others to run commands as root
tcp_wrappers-7.6.4   Monitor and filter incoming requests for network services
tiff-4.0.9nb2        Library and tools for reading and writing TIFF data files
xauth-1.0.10         X authentication utility
xinit-1.4.0          X init program
xmlcatmgr-2.2nb1     XML and SGML catalog manager
xz-5.2.3nb1          XZ utilities
zlib-1.2.11          General purpose data compression library
zoneinit-1.6.9       Joyent Instance initialization toolchain

What am I doing wrong? Are any dependent packages missing? Or is the build broken?

jfqd commented 6 years ago

FYI: ghostscript packages are installed by this mibe: https://github.com/jfqd/mi-qutic-ruby24/blob/master/packages which is based on this mibe: https://github.com/jfqd/mi-qutic-base/blob/master/packages

jperkin commented 6 years ago

I looked at reproducing this, and noticed that your command option -sDevice=pngalpha is spelled incorrectly, it should be -sDEVICE=pngalpha. With that changed it works for me. As for why it works on macOS, this is likely because the Mac will perform case-insensitive matching.

Can you confirm?

jfqd commented 6 years ago

Unbelievable! You are right! Thanks a lot for figuring this out!