Page 1 of 1

Need help installing / using ImageMagick with PDF & PHP.

Posted: 2009-01-21T13:22:44-07:00
by Olif
Hi all,

First of all, i'm French, i'm trying to speak English, but please excuse me for this approximative english-speaking ...
Here is my problem : I've installed ImageMagick on a CentOS dedicated server. I've installed PDF support, but it seems having a little issue :
When I call it in PHP, using :
exec("/usr/local/bin/convert -density 300x300 -quality 70 -dither /tmp/phpuhw3Xy JPEG:../../medCatalogue/til.pdf-grande.jpg");
Where phpuhw3Xy is an uploaded (via a multipart form) PDF file, i obtain "1" as return code, which apparently means there was a problem. Although, using the same command, but in SSH, with root account :
/usr/local/bin/convert -density 300x300 -quality 70 -dither /tmp/phpuhw3Xy JPEG:../../medCatalogue/til.pdf-grande.jpg
Is OK, the til.pdf-grande.jpg file is finally created (i put the file phpuhw3Xy manually in the tmp dir, but it is the same than the uploaded file).
If i call the PHP Script, passing a JPG file as parameter, the file til.pdf-grande.jpg is created too.
So, here are the facts i deducted, using my little knowing in Linux :
- If i use "convert" en shell command line, with ROOT account, for processing PDF or JPG to JPG ==> OK.
- If i use "convert" with the PHP script, using the "exec" command, to process JPG to JPG,it is OK, but to process PDF to JPG, it's not ...

If it can help, here is the view of a "convert -list Format" command :

Code: Select all

# convert -list Format
   Format  Module    Mode  Description
-------------------------------------------------------------------------------
        A* RAW       rw+   Raw alpha samples
      ART* ART       r--   PFS: 1st Publisher
           Format originally used on the Macintosh (MacPaint?) and later used
           for PFS: 1st Publisher clip art.  NOT the AOL ART format.
      AVI* AVI       r--   Microsoft Audio/Visual Interleaved
      AVS* AVS       rw+   AVS X image
        B* RAW       rw+   Raw blue samples
      BMP* BMP       rw-   Microsoft Windows bitmap image
     BMP2* BMP       -w-   Microsoft Windows bitmap image v2
     BMP3* BMP       -w-   Microsoft Windows bitmap image v3
        C* RAW       rw+   Raw cyan samples
    CACHE* CACHE     ---   Magick Persistent Cache image format
  CAPTION* CAPTION   r--   Image caption
      CIN* CIN       rw+   Cineon Image File
      CIP* CIP       -w-   Cisco IP phone image format
     CLIP* CLIP      -w+   Image Clip Mask
     CMYK* CMYK      rw+   Raw cyan, magenta, yellow, and black samples
    CMYKA* CMYK      rw+   Raw cyan, magenta, yellow, black, and opacity samples
      CUR* CUR       rw-   Microsoft icon
      CUT* CUT       r--   DR Halo
      DCM* DCM       r--   Digital Imaging and Communications in Medicine image
           DICOM is used by the medical community for images like X-rays.  The
           specification, "Digital Imaging and Communications in Medicine
           (DICOM)", is available at http://medical.nema.org/.  In particular,
           see part 5 which describes the image encoding (RLE, JPEG, JPEG-LS),
           and supplement 61 which adds JPEG-2000 encoding.
      DCX* PCX       rw+   ZSoft IBM PC multi-page Paintbrush
      DNG* DNG       r--   Digital Negative
      DPS  DPS       ---   Display Postscript Interpreter
      DPX* DPX       rw+   SMPTE 268M-2003 (DPX)
           Digital Moving Picture Exchange Bitmap, Version 2.0.
           See SMPTE 268M-2003 specification at http://www.smtpe.org
           
     EPDF  PDF       rw-   Encapsulated Portable Document Format
      EPI  PS        rw-   Encapsulated PostScript Interchange format
      EPS  PS        rw-   Encapsulated PostScript
     EPS2* PS2       -w-   Level II Encapsulated PostScript
     EPS3* PS3       -w+   Level III Encapsulated PostScript
     EPSF  PS        rw-   Encapsulated PostScript
     EPSI  PS        rw-   Encapsulated PostScript Interchange format
      EPT  EPT       rw-   Encapsulated PostScript with TIFF preview
     EPT2  EPT       rw-   Encapsulated PostScript Level II with TIFF preview
     EPT3  EPT       rw+   Encapsulated PostScript Level III with TIFF preview
      FAX* FAX       rw+   Group 3 FAX
           See TIFF format.  Note that FAX machines use non-square pixels which
           are 1.5 times wider than they are tall but computer displays use
           square pixels. FAX images may appear to be narrow unless they are
           explicitly resized using a resize specification of "150x100%".
     FITS* FITS      rw-   Flexible Image Transport System
  FRACTAL* PLASMA    r--   Plasma fractal image
        G* RAW       rw+   Raw green samples
       G3* FAX       rw-   Group 3 FAX
      GIF* GIF       rw+   CompuServe graphics interchange format
    GIF87* GIF       rw-   CompuServe graphics interchange format (version 87a)
 GRADIENT* GRADIENT  r--   Gradual passing from one shade to another
     GRAY* GRAY      rw+   Raw gray samples
HISTOGRAM* HISTOGRAM -w-   Histogram of the image
      HTM* HTML      -w-   Hypertext Markup Language and a client-side image map
     HTML* HTML      -w-   Hypertext Markup Language and a client-side image map
      ICB* TGA       rw+   Truevision Targa image
      ICO* ICON      rw-   Microsoft icon
     ICON* ICON      rw-   Microsoft icon
     INFO  INFO      -w+   The image format and characteristics
      JNG* PNG       rw-   JPEG Network Graphics
           See http://www.libpng.org/pub/mng/ for details about the JNG format.
           The JNG 1.0 specification is available there and at
           ftp://swrinde.nde.swri.edu/pub/mng/documents/.
     JPEG* JPEG      rw-   Joint Photographic Experts Group JFIF format (62)
      JPG* JPEG      rw-   Joint Photographic Experts Group JFIF format
        K* RAW       rw+   Raw black samples
    LABEL* LABEL     r--   Image label
        M* RAW       rw+   Raw magenta samples
      M2V  MPEG      rw+   MPEG Video Stream
      MAP* MAP       rw-   Colormap intensities and indices
      MAT* MAT       r--   MATLAB image format
    MATTE* MATTE     -w+   MATTE format
     MIFF* MIFF      rw+   Magick Image File Format
      MNG* PNG       rw+   Multiple-image Network Graphics (libpng 1.0.6)
           See http://www.libpng.org/pub/mng/ for details about the MNG format.
           The MNG 1.0 specification is available there and at
           ftp://swrinde.nde.swri.edu/pub/mng/documents/.
     MONO* MONO      rw-   Bi-level bitmap in least-significant-byte first order
      MPC* MPC       rw+   Magick Persistent Cache image format
     MPEG  MPEG      rw+   MPEG Video Stream
      MPG  MPEG      rw+   MPEG Video Stream
      MSL* MSL       ---   Magick Scripting Language
      MTV* MTV       rw+   MTV Raytracing image format
      MVG* MVG       rw-   Magick Vector Graphics
     NULL* NULL      rw-   Constant image of uniform color
        O* RAW       rw+   Raw opacity samples
      OTB* OTB       rw-   On-the-air bitmap
      OTF* TTF       ---   Open Type font
       P7* PNM       rw+   Xv thumbnail format
      PAL* UYVY      rw-   16bit/pixel interleaved YUV
     PALM* PALM      rw+   Palm pixmap
      PAM* PNM       -w+   Common 2-dimensional bitmap format
  PATTERN* PATTERN   r--   Predefined pattern
      PBM* PNM       rw+   Portable bitmap format (black and white)
      PCD* PCD       rw-   Photo CD
     PCDS* PCD       rw-   Photo CD
      PCL  PCL       rw-   Printer Control Language
      PCT* PICT      rw-   Apple Macintosh QuickDraw/PICT
      PCX* PCX       rw-   ZSoft IBM PC Paintbrush
      PDB* PDB       rw+   Palm Database ImageViewer Format
      PDF  PDF       rw+   Portable Document Format
      PFA* TTF       ---   Postscript Type 1 font (ASCII)
      PFB* TTF       ---   Postscript Type 1 font (binary)
      PGM* PNM       rw+   Portable graymap format (gray scale)
    PICON* XPM       rw-   Personal Icon
     PICT* PICT      rw-   Apple Macintosh QuickDraw/PICT
      PIX* PIX       r--   Alias/Wavefront RLE image format
    PJPEG* JPEG      rw-   Progessive Joint Photographic Experts Group JFIF
   PLASMA* PLASMA    r--   Plasma fractal image
      PNG* PNG       rw-   Portable Network Graphics (libpng 1.0.6)
           See http://www.libpng.org/ for details about the PNG format.  The
           PNG 1.2 specification is available there and at
           ftp://swrinde.nde.swri.edu/pub/png/documents/.
    PNG24* PNG       rw-   24-bit RGB PNG, opaque only (zlib 1.2.3)
    PNG32* PNG       rw-   32-bit RGBA PNG, semitransparency OK
     PNG8* PNG       rw-   8-bit indexed PNG, binary transparency only
      PNM* PNM       rw+   Portable anymap
      PPM* PNM       rw+   Portable pixmap format (color)
  PREVIEW* PREVIEW   -w-   Show a preview an image enhancement, effect, or f/x
       PS  PS        rw+   PostScript
      PS2* PS2       -w+   Level II PostScript
      PS3* PS3       -w+   Level III PostScript
      PSD* PSD       rw+   Adobe Photoshop bitmap
     PTIF* TIFF      rw-   Pyramid encoded TIFF
      PWP* PWP       r--   Seattle Film Works
        R* RAW       rw+   Raw red samples
      RAS* SUN       rw+   SUN Rasterfile
      RGB* RGB       rw+   Raw red, green, and blue samples
     RGBA* RGB       rw+   Raw red, green, blue, and alpha samples
     RGBO* RGB       rw+   Raw red, green, blue, and opacity samples
      RLA* RLA       r--   Alias/Wavefront image
      RLE* RLE       r--   Utah Run length encoded image
      SCR* SCR       r--   ZX-Spectrum SCREEN$
      SCT* SCT       r--   Scitex HandShake
      SFW* SFW       r--   Seattle Film Works
      SGI* SGI       rw+   Irix RGB image
    SHTML* HTML      -w-   Hypertext Markup Language and a client-side image map
  STEGANO* STEGANO   r--   Steganographic image
      SUN* SUN       rw+   SUN Rasterfile
      SVG* SVG       -w+   Scalable Vector Graphics
     SVGZ* SVG       -w+   Compressed Scalable Vector Graphics
     TEXT* TXT       rw+   Text
      TGA* TGA       rw+   Truevision Targa image
     TIFF* TIFF      rw+   Tagged Image File Format (LIBTIFF, Version 3.5.5)
     TILE* TILE      r--   Tile image with a texture
      TIM* TIM       r--   PSX TIM
      TTC* TTF       ---   TrueType font collection
      TTF* TTF       ---   TrueType font
      TXT* TXT       rw+   Text
      UIL* UIL       -w-   X-Motif UIL table
     UYVY* UYVY      rw-   16bit/pixel interleaved YUV
      VDA* TGA       rw+   Truevision Targa image
    VICAR* VICAR     rw-   VICAR rasterfile format
      VID* VID       rw+   Visual Image Directory
     VIFF* VIFF      rw+   Khoros Visualization image
      VST* TGA       rw+   Truevision Targa image
     WBMP* WBMP      rw-   Wireless Bitmap (level 0) image
      WMF* WMF       ---   Windows Meta File
      WMZ* WMZ       ---   Compressed Windows Meta File
      WPG* WPG       r--   Word Perfect Graphics
      XBM* XBM       rw-   X Windows system bitmap (black and white)
       XC* XC        r--   Constant image uniform color
      XCF* XCF       r--   GIMP image
      XPM* XPM       rw-   X Windows system pixmap (color)
       XV* VIFF      rw+   Khoros Visualization image
        Y* RAW       rw+   Raw yellow samples
    YCbCr* YCbCr     rw+   Raw Y, Cb, and Cr samples
   YCbCrA* YCbCr     rw+   Raw Y, Cb, Cr, and opacity samples
      YUV* YUV       rw-   CCIR 601 4:1:1 or 4:2:2

If you have any idea of the probleme, or even better, of the solution, i'll hear you totally (but, please, speak slowly ;-))

Thanks in advance !
Regards,
Olif.

Re: Need help installing / using ImageMagick with PDF & PHP.

Posted: 2009-01-21T14:10:40-07:00
by Bonzo
I would say its a path problem - I can not help any further - search the forum as it has come up before.

Try:
http://redux.imagemagick.org/discourse- ... it=pdf+php
http://redux.imagemagick.org/discourse- ... it=pdf+php
http://redux.imagemagick.org/discourse- ... it=pdf+php
http://redux.imagemagick.org/discourse- ... it=pdf+php

There are other results these are just the last few that may be of help. I searched the forum for pdf php in the users section.

Re: Need help installing / using ImageMagick with PDF & PHP.

Posted: 2009-01-21T14:40:00-07:00
by Olif
Thanks Very Much ...
The answer was indeed in the second post you found, an issue of path to the GS script in delegate.xml ...
Great, and happy to read from you !
Olif.