Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDF with links converted to JPGs get black border around them on Alpine linux #571

Open
carestad opened this issue Nov 30, 2022 · 8 comments

Comments

@carestad
Copy link

carestad commented Nov 30, 2022

Working on my local machine (Pop OS) and using the PHP Imagemagick extension (PHP v8.1.13, Imagick v3.7.0), I try to convert a PDF to JPGs. The PDF has links in it multiple places, and when I run my PHP script in a docker container with Alpine linux (3.16), the links get a thin black border around them. On my local machine, I do not get this.

The PDF in question is this.

Trying to convert the first page locally, I get this:

this

In my docker container I get this:

this

The output is the same as above if I use convert file.pdf[0] foo.jpg in the terminal.

The difference is probably in how the imagemagick or the PHP imagemagick extension is installed locally vs. in the php:8.1.13-alpine3.16 docker image. Locally I use the deb.sury.org repo and just install the php8.1-imagick package. In docker I have tried both apk add php81-pecl-imagick and pecl install -o -f imagick, to no difference in the output generated I'm afraid.

The OS packages for imagemagick differ a little bit though, being newer in the docker container (ImageMagick 6.9.12-65 beta Q16 x86_64 17481 vs. ImageMagick 6.9.11-60 Q16 x86_64 2021-01-25 locally).

Debug related info

policy.xml file used both places:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policymap [
  <!ELEMENT policymap (policy)*>
  <!ATTLIST policymap xmlns CDATA #FIXED ''>
  <!ELEMENT policy EMPTY>
  <!ATTLIST policy xmlns CDATA #FIXED '' domain NMTOKEN #REQUIRED
    name NMTOKEN #IMPLIED pattern CDATA #IMPLIED rights NMTOKEN #IMPLIED
    stealth NMTOKEN #IMPLIED value CDATA #IMPLIED>
]>
<policymap>
  <policy domain="resource" name="memory" value="256MiB"/>
  <policy domain="resource" name="map" value="512MiB"/>
  <policy domain="resource" name="width" value="16KP"/>
  <policy domain="resource" name="height" value="16KP"/>
  <policy domain="resource" name="area" value="128MP"/>
  <policy domain="resource" name="disk" value="1GiB"/>
  <policy domain="delegate" rights="none" pattern="URL" />
  <policy domain="delegate" rights="none" pattern="HTTPS" />
  <policy domain="delegate" rights="none" pattern="HTTP" />
  <!-- in order to avoid to get image with password text -->
  <policy domain="path" rights="none" pattern="@*"/>
  <!-- Only allow specific formats -->
  <policy domain="coder" rights="none" pattern="*" />
  <policy domain="coder" rights="read|write" pattern="{GIF,JPG,JPEG,PNG,WEBP,PDF,PAM}" />
</policymap>
Imagemagick related output from php -i locally:
imagick module => enabled
imagick module version => 3.7.0
imagick classes => Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator, ImagickKernel
Imagick compiled with ImageMagick version => ImageMagick 6.9.11-60 Q16 x86_64 2021-01-25 https://imagemagick.org
Imagick using ImageMagick library version => ImageMagick 6.9.11-60 Q16 x86_64 2021-01-25 https://imagemagick.org
ImageMagick copyright => (C) 1999-2021 ImageMagick Studio LLC
ImageMagick release date => 2021-01-25
ImageMagick number of supported formats:  => 247
ImageMagick supported formats => 3FR, 3G2, 3GP, AAI, AI, APNG, ART, ARW, AVI, AVIF, AVS, BGR, BGRA, BGRO, BIE, BMP, BMP2, BMP3, BRF, CAL, CALS, CANVAS, CAPTION, CIN, CIP, CLIP, CMYK, CMYKA, CR2, CR3, CRW, CUR, CUT, DATA, DCM, DCR, DCX, DDS, DFONT, DJVU, DNG, DOT, DPX, DXT1, DXT5, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, EPT, EPT2, EPT3, ERF, EXR, FAX, FILE, FITS, FRACTAL, FTP, FTS, G3, G4, GIF, GIF87, GRADIENT, GRAY, GRAYA, GROUP4, GV, H, HALD, HDR, HEIC, HISTOGRAM, HRZ, HTM, HTML, HTTP, HTTPS, ICB, ICO, ICON, IIQ, INFO, INLINE, IPL, ISOBRL, ISOBRL6, J2C, J2K, JBG, JBIG, JNG, JNX, JP2, JPC, JPE, JPEG, JPG, JPM, JPS, JPT, JSON, K25, KDC, LABEL, M2V, M4V, MAC, MAGICK, MAP, MASK, MAT, MATTE, MEF, MIFF, MKV, MNG, MONO, MOV, MP4, MPC, MPG, MRW, MSL, MSVG, MTV, MVG, NEF, NRW, NULL, ORF, OTB, OTF, PAL, PALM, PAM, PANGO, PATTERN, PBM, PCD, PCDS, PCL, PCT, PCX, PDB, PDF, PDFA, PEF, PES, PFA, PFB, PFM, PGM, PGX, PICON, PICT, PIX, PJPEG, PLASMA, PNG, PNG00, PNG24, PNG32, PNG48, PNG64, PNG8, PNM, POCKETMOD, PPM, PREVIEW, PS, PS2, PS3, PSB, PSD, PTIF, PWP, RADIAL-GRADIENT, RAF, RAS, RAW, RGB, RGBA, RGBO, RGF, RLA, RLE, RMF, RW2, SCR, SCT, SFW, SGI, SHTML, SIX, SIXEL, SPARSE-COLOR, SR2, SRF, STEGANO, SUN, SVG, SVGZ, TEXT, TGA, THUMBNAIL, TIFF, TIFF64, TILE, TIM, TTC, TTF, TXT, UBRL, UBRL6, UIL, UYVY, VDA, VICAR, VID, VIDEO, VIFF, VIPS, VST, WBMP, WEBM, WEBP, WMF, WMV, WMZ, WPG, X, X3F, XBM, XC, XCF, XPM, XPS, XV, XWD, YCbCr, YCbCrA, YUV

Directive => Local Value => Master Value
imagick.allow_zero_dimension_images => 0 => 0
imagick.locale_fix => 0 => 0
imagick.progress_monitor => 0 => 0
imagick.set_single_thread => 1 => 1
imagick.shutdown_sleep_count => 10 => 10
imagick.skip_version_check => 1 => 1
Imagemagick related output from php -i on alpine 3.16 (when installed with php81-pecl-imagick):
imagick module => enabled
imagick module version => 3.7.0
imagick classes => Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator, ImagickKernel
Imagick compiled with ImageMagick version => ImageMagick 7.1.0-31 Q16-HDRI x86_64 19966 https://imagemagick.org
Imagick using ImageMagick library version => ImageMagick 7.1.0-50 beta Q16-HDRI x86_64 20489 https://imagemagick.org
ImageMagick copyright => (C) 1999 ImageMagick Studio LLC
ImageMagick release date => 2022-10-08
ImageMagick number of supported formats:  => 252
ImageMagick supported formats => 3FR, 3G2, 3GP, AAI, AI, APNG, ART, ARW, ASHLAR, AVI, AVIF, AVS, BAYER, BAYERA, BGR, BGRA, BGRO, BMP, BMP2, BMP3, BRF, CAL, CALS, CANVAS, CAPTION, CIN, CIP, CLIP, CMYK, CMYKA, CR2, CR3, CRW, CUBE, CUR, CUT, DATA, DCM, DCR, DCRAW, DCX, DDS, DFONT, DNG, DOT, DPX, DXT1, DXT5, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, EPT, EPT2, EPT3, ERF, FARBFELD, FAX, FF, FILE, FITS, FL32, FLV, FRACTAL, FTP, FTS, FTXT, G3, G4, GIF, GIF87, GRADIENT, GRAY, GRAYA, GROUP4, GV, HALD, HDR, HEIC, HEIF, HISTOGRAM, HRZ, HTM, HTML, HTTP, HTTPS, ICB, ICO, ICON, IIQ, INFO, INLINE, IPL, ISOBRL, ISOBRL6, JNG, JNX, JPE, JPEG, JPG, JPS, JSON, JXL, K25, KDC, KERNEL, LABEL, M2V, M4V, MAC, MAP, MASK, MAT, MATTE, MEF, MIFF, MKV, MNG, MONO, MOV, MP4, MPC, MPEG, MPG, MRW, MSL, MSVG, MTV, MVG, NEF, NRW, NULL, ORA, ORF, OTB, OTF, PAL, PALM, PAM, PANGO, PATTERN, PBM, PCD, PCDS, PCL, PCT, PCX, PDB, PDF, PDFA, PEF, PES, PFA, PFB, PFM, PGM, PGX, PHM, PICON, PICT, PIX, PJPEG, PLASMA, PNG, PNG00, PNG24, PNG32, PNG48, PNG64, PNG8, PNM, POCKETMOD, PPM, PS, PS2, PS3, PSB, PSD, PTIF, PWP, QOI, RADIAL-GRADIENT, RAF, RAS, RAW, RGB, RGB565, RGBA, RGBO, RGF, RLA, RLE, RMF, RSVG, RW2, SCR, SCT, SFW, SGI, SHTML, SIX, SIXEL, SPARSE-COLOR, SR2, SRF, STEGANO, STRIMG, SUN, SVG, SVGZ, TEXT, TGA, THUMBNAIL, TIFF, TIFF64, TILE, TIM, TM2, TTC, TTF, TXT, UBRL, UBRL6, UIL, UYVY, VDA, VICAR, VID, VIFF, VIPS, VST, WBMP, WEBM, WEBP, WMV, WPG, X, X3F, XBM, XC, XCF, XPM, XPS, XV, XWD, YAML, YCbCr, YCbCrA, YUV

Directive => Local Value => Master Value
imagick.allow_zero_dimension_images => 0 => 0
imagick.locale_fix => 0 => 0
imagick.progress_monitor => 0 => 0
imagick.set_single_thread => 1 => 1
imagick.shutdown_sleep_count => 10 => 10
imagick.skip_version_check => 0 => 0
Imagemagick related output from php -i on alpine 3.16 (when installed with pecl):
imagick module => enabled
imagick module version => 3.7.0
imagick classes => Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator, ImagickKernel
Imagick compiled with ImageMagick version => ImageMagick 6.9.12-65 beta Q16 x86_64 17481 https://legacy.imagemagick.org
Imagick using ImageMagick library version => ImageMagick 6.9.12-65 beta Q16 x86_64 17481 https://legacy.imagemagick.org
ImageMagick copyright => (C) 1999 ImageMagick Studio LLC
ImageMagick release date => 2022-10-08
ImageMagick number of supported formats:  => 231
ImageMagick supported formats => 3FR, 3G2, 3GP, AAI, AI, APNG, ART, ARW, AVI, AVS, BGR, BGRA, BGRO, BMP, BMP2, BMP3, BRF, CAL, CALS, CANVAS, CAPTION, CIN, CIP, CLIP, CMYK, CMYKA, CR2, CR3, CRW, CUR, CUT, DATA, DCM, DCR, DCX, DDS, DFONT, DNG, DOT, DPX, DXT1, DXT5, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, EPT, EPT2, EPT3, ERF, FAX, FILE, FITS, FRACTAL, FTP, FTS, G3, G4, GIF, GIF87, GRADIENT, GRAY, GRAYA, GROUP4, GV, H, HALD, HDR, HISTOGRAM, HRZ, HTM, HTML, HTTP, HTTPS, ICB, ICO, ICON, IIQ, INFO, INLINE, IPL, ISOBRL, ISOBRL6, JNG, JNX, JPE, JPEG, JPG, JPS, JSON, K25, KDC, LABEL, M2V, M4V, MAC, MAGICK, MAP, MASK, MAT, MATTE, MEF, MIFF, MKV, MNG, MONO, MOV, MP4, MPC, MPEG, MPG, MRW, MSL, MSVG, MTV, MVG, NEF, NRW, NULL, ORF, OTB, OTF, PAL, PALM, PAM, PANGO, PATTERN, PBM, PCD, PCDS, PCL, PCT, PCX, PDB, PDF, PDFA, PEF, PES, PFA, PFB, PFM, PGM, PGX, PICON, PICT, PIX, PJPEG, PLASMA, PNG, PNG00, PNG24, PNG32, PNG48, PNG64, PNG8, PNM, POCKETMOD, PPM, PREVIEW, PS, PS2, PS3, PSB, PSD, PTIF, PWP, RADIAL-GRADIENT, RAF, RAS, RAW, RGB, RGBA, RGBO, RGF, RLA, RLE, RMF, RW2, SCR, SCT, SFW, SGI, SHTML, SIX, SIXEL, SPARSE-COLOR, SR2, SRF, STEGANO, SUN, SVG, SVGZ, TEXT, TGA, THUMBNAIL, TIFF, TIFF64, TILE, TIM, TTC, TTF, TXT, UBRL, UBRL6, UIL, UYVY, VDA, VICAR, VID, VIDEO, VIFF, VIPS, VST, WBMP, WEBM, WEBP, WMV, WPG, X3F, XBM, XC, XCF, XPM, XPS, XV, YCbCr, YCbCrA, YUV

Directive => Local Value => Master Value
imagick.allow_zero_dimension_images => 0 => 0
imagick.locale_fix => 0 => 0
imagick.progress_monitor => 0 => 0
imagick.set_single_thread => 1 => 1
imagick.shutdown_sleep_count => 10 => 10
imagick.skip_version_check => 0 => 0
Other packages installed in the docker container:
$PHPIZE_DEPS \
    bash \
    chromium \
    freetype-dev \
    git \
    imagemagick6 \
    imagemagick6-dev \
    less \
    libjpeg-turbo-dev \
    libpng-dev \
    libwebp-dev \
    libzip-dev \
    nodejs \
    npm \
    nss \
    unzip \
    zip
PHP code in question:
<?php

use Imagick;

$path = 'file.pdf';
$imagick1 = new Imagick();
$imagick1->setResolution(100, 100);
$imagick1->setColorspace(Imagick::COLORSPACE_SRGB);
$imagick1->readImage($path . '[0]');
$imagick1->setBackgroundColor('white');
$imagick1->setImageAlphaChannel(11);
$imagick1->setImageBackgroundColor('white');
$imagick1->setImageFormat('JPG');
$imagick1->writeImage('foo1.jpg');

Any help to pinpoint where the problem lies would be highly appreciated

@Danack
Copy link
Collaborator

Danack commented Nov 30, 2022

Any help to pinpoint where the problem lies would be highly appreciated

The error could be in ghostscript, which is probably doing the conversion from PDF to a pixel based format.

Can you try doing the conversion manually, by invoking ghostscript with something like:

gs -sstdout=%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pngalpha' -dTextAlphaBits=4 -dGraphicsAlphaBits=4 '-r72x72' '-sOutputFile=gs_output.png' '-fTestImage.pdf'

And see if that shows the same problem on the alpine box, and works as expected locally?

Also, can you then say which ghostscript version you're using?

You may be able to get a better version of Ghostscript from https://ghostscript.com/releases/gsdnld.html

@carestad
Copy link
Author

Thanks for the quick reply!

The error could be in ghostscript, which is probably doing the conversion from PDF to a pixel based format.

Can you try doing the conversion manually, by invoking ghostscript with something like:

gs -sstdout=%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pngalpha' -dTextAlphaBits=4 -dGraphicsAlphaBits=4 '-r72x72' '-sOutputFile=gs_output.png' '-fTestImage.pdf'

And see if that shows the same problem on the alpine box, and works as expected locally?

That seems to generate a (quite large) PNG file without any borders, so that is one step closer at least 😄 Does Imagemagick use Ghostscript to convert to PNG first, then JPG?

Also, can you then say which ghostscript version you're using?

gs --help tells me it has version GPL Ghostscript 9.56.1 on the alpine box. Locally I have GPL Ghostscript 9.55.0 (2021-09-27) installed

@carestad
Copy link
Author

carestad commented Nov 30, 2022

You may be able to get a better version of Ghostscript from https://ghostscript.com/releases/gsdnld.html

Tried this now (both the x86_64 and just x86 versions) and when trying to execute the gs-1000-linux-x86_64 executable that comes with the tarballs I get a No such file or directory error for some reason. Tried moving the file to /usr/local/bin/gs as well, but the same error occurs. Might be some missing shared libraries or something?

@Danack
Copy link
Collaborator

Danack commented Nov 30, 2022

Does Imagemagick use Ghostscript to convert to PNG first, then JPG?

It should be, both to avoid image quality loss in using JPG and also to preserve transparency in the image.

Can you run your test script through strace with a command similar to:

strace -f -s 256 php debug.php > strace_output_with_follow.txt 2>&1

That will produce a lot of info. In it there should be an invocation of ghostscript. Can you find that and paste the exact thing it's running?

when trying to execute the gs-1000-linux-x86_64

Er, you're invoking it as ./gs-1000-linux-x86_64 in the same directory that it's in?

Actually, if running it by hand generates a correct image, you don't need to worry about finding a better version of ghostscript, probably. Just need to find why it's not producing the right image through ImageMagick.

@carestad
Copy link
Author

Thanks!

I ran the strace and attached it here. I tried browsing through it myself but it wasn't clear to me how it executes ghostscript to generate the PNG and then the JPEG file.

This was generated on an instance where the imagick extension was installed via pecl btw. I could generate one from an instance where it has been installed with the apk package instead if that is needed?

@Danack
Copy link
Collaborator

Danack commented Nov 30, 2022

I tried browsing through it myself but it wasn't clear to me how it executes ghostscript

It apparently doesn't; apparently it is possible to compile ImageMagick with the option:

 --with-gslib            enable Ghostscript library support

set to almost certainly compile against Ghostscript as a library, not a delegate, so there is no command line invocation. Which is slightly unfortunate as it means you can't just replace the version of Ghostscript on your machine.

Out of interest, can you dump the result of Imagick::getConfigureOptions() here? would be interesting to see if that was set.

However to address your issue....I probably won't be able to fix it, as it's out of my control.

I think you have two options

i. Go to report a bug against https://pkgs.alpinelinux.org/package/v3.3/main/x86/imagemagick and ask them to use a less buggy version of Ghostscript and hopefully fix it there.

ii. Just install a known working version of Ghostscript on your image processing box, and invoke it with exec().

@carestad
Copy link
Author

carestad commented Dec 1, 2022

Out of interest, can you dump the result of Imagick::getConfigureOptions() here? would be interesting to see if that was set.

Sure! Among the configure options there is a --with-gslib set. Locally this is not the case.

Imagick::getConfigureOptions() output
(
    [CC] => gcc
    [CFLAGS] => -I/usr/include/libxml2    -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16  -I/usr/include/librsvg-2.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -pthread -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2  -I/usr/include/libpng16    -I/usr/include/freetype2 -I/usr/include/libpng16  -I/usr/include/freetype2 -I/usr/include/libpng16    -fopenmp -Wall -Os -fomit-frame-pointer -mtune=sandybridge -fexceptions -pthread -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16
    [CODER_PATH] => /usr/lib/ImageMagick-6.9.12/modules-Q16/coders
    [CONFIGURE] => ./configure  '--build=x86_64-alpine-linux-musl' '--host=x86_64-alpine-linux-musl' '--program-suffix=-6' '--prefix=/usr' '--sysconfdir=/etc' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--disable-docs' '--disable-static' '--with-threads' '--without-x' '--without-perl' '--with-tiff' '--with-png' '--with-rsvg' '--with-gslib' '--with-gs-font-dir=/usr/share/fonts/Type1' '--with-modules' '--with-xml' 'build_alias=x86_64-alpine-linux-musl' 'host_alias=x86_64-alpine-linux-musl' 'CC=gcc' 'CFLAGS=-Os -fomit-frame-pointer' 'CPPFLAGS=-Os -fomit-frame-pointer' 'CXX=g++' 'CXXFLAGS=-Os -fomit-frame-pointer'
    [CONFIGURE_PATH] => /etc/ImageMagick-6/
    [COPYRIGHT] => Copyright (C) 1999 ImageMagick Studio LLC
    [CPPFLAGS] => -I/usr/include/ImageMagick-6
    [CXX] => g++
    [CXXFLAGS] => -Os -fomit-frame-pointer -pthread
    [DEFS] => -DHAVE_CONFIG_H
    [DELEGATES] => bzlib fontconfig freetype gslib jng jpeg lcms lzma png ps rsvg tiff webp xml zlib zstd
    [DISTCHECK_CONFIG_FLAGS] => 'CC=gcc' 'CFLAGS=-Os -fomit-frame-pointer' 'CPPFLAGS=-Os -fomit-frame-pointer' 'CXX=g++'  --disable-deprecated  --with-quantum-depth=16  --with-jemalloc=no  --with-umem=no  --with-autotrace=no  --with-fftw=no  --with-fontpath=  --with-gs-font-dir=/usr/share/fonts/Type1  --with-perl=no 
    [DOCUMENTATION_PATH] => /usr/share/doc/ImageMagick-6
    [EXEC-PREFIX] => /usr
    [EXECUTABLE_PATH] => /usr/bin
    [FEATURES] => DPC Cipher OpenMP Modules
    [FILTER_PATH] => /usr/lib/ImageMagick-6.9.12/modules-Q16/filters
    [GIT_REVISION] => 17481
    [HOST] => x86_64-alpine-linux-musl
    [INCLUDE_PATH] => /usr/include/ImageMagick-6
    [LDFLAGS] => -L/usr/lib 
    [LIB_VERSION] => 0x69C
    [LIB_VERSION_NUMBER] => 6,9,12,65
    [LIBRARY_PATH] => /usr/lib/ImageMagick-6.9.12
    [LIBS] =>  -llcms2  -lfreetype     -lxml2   -lfontconfig -lfreetype      -lbz2 -L/lib -lz   -lltdl  -lm    -lpthread  -lgomp
    [NAME] => ImageMagick
    [PCFLAGS] => -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16
    [PREFIX] => /usr
    [QuantumDepth] => 16
    [RELEASE_DATE] => 2022-10-08
    [SHARE_PATH] => /usr/share/ImageMagick-6
    [SHAREARCH_PATH] => /usr/lib/ImageMagick-6.9.12/config-Q16
    [TARGET_CPU] => x86_64
    [TARGET_OS] => linux-musl
    [TARGET_VENDOR] => alpine
    [VERSION] => 6.9.12
    [WEBSITE] => https://legacy.imagemagick.org
)

I think you have two options

i. Go to report a bug against https://pkgs.alpinelinux.org/package/v3.3/main/x86/imagemagick and ask them to use a less buggy version of Ghostscript and hopefully fix it there.

ii. Just install a known working version of Ghostscript on your image processing box, and invoke it with exec().

Would one option be to re-compile the extension without the gslib flag? I thought maybe that would be doable with pecl? Or is this imagemagick as a whole that has been compiled with the --with-gslib flag and that would need to be re-compiled?

Either way I have started looking into option 2 and have gotten good results by just running ghostscript directly. But I'll be happy to report this upstream to Alpine as well.

@Danack
Copy link
Collaborator

Danack commented Dec 2, 2022

Or is this imagemagick as a whole that has been compiled with the --with-gslib flag and that would need to be re-compiled?

Yes, sorry I should have listed that. You would need to recompile ImageMagick, and then recompile Imagick from source to link against the newly built ImageMagick. Imagick can be compiled either through pecl or downloading the source and then:

phpize
./configure
make install

Either way I have started looking into option 2 and have gotten good results by just running ghostscript directly.

Yeah....tbh although it's having everything 'just work' in one method call, the stack of software needed to load PDFs and then edit then as images is such a tall stack, that it shouldn't be too surprising it falls over.

Using the precise tool to convert PDFs to PNGs, and then if necessary doing any processing afterwards is not only more likely to work, it's so much easier to debug if something breaks.

There is a very strong argument that I should divert people away from using Imagick for processing PDFs....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants