1

Hi i got another script to convert a pdf to tiff, this script use imagick library from php, when i execute the next pice of code, got a error, can anyone help me, the code is

<?php
$im2 = new Imagick("file.pdf");
$im2->setImageFormat("tiff");
$im2->setImageColorSpace(5); 
$im2->writeImage("file.tif");
?>

the error

Fatal error: Uncaught exception 'ImagickException' with message 'no decode delegate for this image format `PNG' @ error/constitute.c/ReadImage/504'

please can anyone tell me what is the problem, reading in the web is something with delegate decode, but is not clear for me, the error is in the line one

Thanks in advance

Update:

convert --version execution

Version: ImageMagick 6.9.4-4 Q16 x86_64 2016-05-23 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC OpenMP
Delegates (built-in): bzlib freetype jpeg tiff x zlib

phpinfo() for imagick

ImageMagick number of supported formats: 217

ImageMagick supported formats: 3FR, A, AAI, AI, ART, ARW, AVI, AVS, B, BGR, BGRA, BGRO, 
BMP, BMP2, BMP3, BRF, C, CAL, CALS, CANVAS, CAPTION, CIN, CIP, CLIP, CMYK, CMYKA, CR2, 
CRW, CUR, CUT, DATA, DCM, DCR, DCX, DDS, DFONT, DNG, DPX, DXT1, DXT5, EPDF, EPI, EPS, 
EPS2, EPS3, EPSF, EPSI, EPT, EPT2, EPT3, ERF, FAX, FITS, FRACTAL, FTS, G, G3, GIF, 
GIF87, GRADIENT, GRAY, GROUP4, H, HALD, HDR, HISTOGRAM, HRZ, HTM, HTML, ICB, ICO, 
ICON, IIQ, INFO, INLINE, IPL, ISOBRL, ISOBRL6, JNX, JPE, JPEG, JPG, JPS, JSON, K, 
K25, KDC, LABEL, M, M2V, M4V, MAC, MAGICK, MAP, MASK, MAT, MATTE, MEF, MIFF, MKV, 
MONO, MOV, MP4, MPC, MPEG, MPG, MRW, MSL, MSVG, MTV, MVG, NEF, NRW, NULL, O, ORF, OTB, 
OTF, PAL, PALM, PAM, PANGO, PATTERN, PBM, PCD, PCDS, PCL, PCT, PCX, PDB, PDF, PDFA, 
PEF, PES, PFA, PFB, PFM, PGM, PICON, PICT, PIX, PJPEG, PLASMA, PNM, PPM, PREVIEW, 
PS, PS2, PS3, PSB, PSD, PTIF, PWP, R, RADIAL-GRADIENT, RAF, RAS, RAW, RGB, RGBA, RGBO, 
RGF, RLA, RLE, RMF, RW2, SCR, SCREENSHOT, 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, VIFF, VIPS, VST, 
WBMP, WMV, WPG, X, X3F, XBM, XC, XCF, XPM, XPS, XV, XWD, Y, YCbCr, YCbCrA, YUV

I read the posts, but i don't see the problem, it's the delegate problem, but i don't understand.

pipook
  • 27
  • 1
  • 7
  • Please check [here](http://stackoverflow.com/questions/15279301/imagemagick-supported-formats-no-value) and [http://stackoverflow.com/questions/30005612/imagemagick-no-decode-delegate-for-this-image-format](http://stackoverflow.com/questions/30005612/imagemagick-no-decode-delegate-for-this-image-format) for answers. – codedge Jun 22 '16 at 14:51
  • Update the post with some more info – pipook Jun 22 '16 at 15:09
  • How did you install Imagick and ImageMagick? – Danack Jun 22 '16 at 15:42
  • First ImageMagick and then imagick, the two from tar.gz file, with **make**, and **make install** @Danack – pipook Jun 22 '16 at 15:52
  • It's possible ImageMagick can't find either the PDF delegate or the TIFF delegate. To narrow it down, try converting PDF -> PNG and then PNG -> TIFF - also this is a relatively common problem I think https://stackoverflow.com/questions/37927247/imagick-dont-open-pdf-files-with-failed-to-read-the-file-exception – Danack Jun 22 '16 at 19:17
  • Like i see the problem is other, just putting `$im2 = new Imagick($pdfFile); ` the script show me the error `Uncaught exception 'ImagickException' with message 'no decode delegate for this image format `PNG' @ error/constitute.c/ReadImage/504'` – pipook Jun 22 '16 at 19:41

1 Answers1

0

Finally a solve the problem, I have to uninstall ImageMagick, and install again, the uninstall, and install from source, update to the last version, and install imagick from php, like this page do vultr page

Now got another problem, is that when convert the pdf the cuallity is lost, and I just got the last page from the PDF file, but this other problem, Thanks a lot for the help to all.

pipook
  • 27
  • 1
  • 7