使用php的imagick将PDF文件转换为TIFF

时间:2016-06-22 14:32:28

标签: php pdf tiff imagick

嗨我有另一个脚本将pdf转换为tiff,这个脚本使用php中的imagick库,当我执行下一个代码时,出现错误,任何人都可以帮助我,代码是

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

错误

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

请有人能告诉我是什么问题,在网上阅读是代理解码的东西,但对我来说不清楚,错误是在第一行

提前致谢

更新:

convert --version执行

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

我看了帖子,但我没有看到问题,这是代表问题,但我不明白。

1 个答案:

答案 0 :(得分:0)

最后解决问题,我必须卸载ImageMagick,再次安装,卸载,从源代码安装,更新到最新版本,然后从php安装imagick,就像这个页面做vultr page

现在又遇到了另一个问题,就是当转换pdf时,cuallity会丢失,而我只是从PDF文件中得到了最后一页,但是另一个问题,非常感谢所有人的帮助。