[英]Create thumbnail for pdf file using php
I have been working to create thumbnail for pdf file. 我一直在努力为pdf文件创建缩略图。 I have used below link for installation and configuration of ImageMagick installation and configuration of ImageMagick and code I have used below code to for conversion of pdf file to thumbnail 我已使用以下链接进行ImageMagick的安装和配置安装并配置ImageMagick以及代码将以下代码用于将pdf文件转换为缩略图
<?php
exec("C:/ImageMagick-6.8.0-Q16/convert.exe a.pdf -resize 546x274^ -quality 80 temp.jpg 2>&1", $array);
?>
It is not converting but it is converting images. 它不是在转换而是在转换图像。 The code is 该代码是
<?php
exec("C:/ImageMagick-6.8.0-Q16/convert.exe a.jpg -resize 546x274^ -quality 80 temp.jpg 2>&1", $array);
?>
Can any one please help me to create thumbnail for pdf file .Thanks in advance. 谁能帮助我为pdf文件创建缩略图。谢谢。
I use the built in PHP calls on my own server. 我在自己的服务器上使用内置的PHP调用。 This works for me. 这对我有用。
if(!file_exists(THUMBS_DIR . $name . "." . $out_format))
{
$im = new imagick();
$im->setResolution(300,300);
$im->readImage(ABS_PATH . $path);
//$im->setImageColorspace(255);
//$im->adaptiveSharpenImage(2,1);
//$im->setCompression(Imagick::COMPRESSION_JPEG);
$im->setCompressionQuality(100);
$im->resizeImage(700,1000,Imagick::FILTER_LANCZOS,1, TRUE);
$im->setImageFormat($out_format);
$im->writeImage(THUMBS_DIR . $name . "." . $out_format);
$im->clear();
$im->destroy();
}
A free direct download PDF test file with detailed instructions to solve a "PDF Thumbnail Generation Problem" in TYPO3 CMS is available at Smargasy, Inc. " http://www.smargasy.com/fileadmin/media_data/community/Smargasy_PDF-Thumbnail-Compatibility-Test-File.pdf ". 详细的使用说明免费直接下载PDF测试文件,以解决TYPO3 CMS一个“PDF缩略图生成问题”可在Smargasy公司“ http://www.smargasy.com/fileadmin/media_data/community/Smargasy_PDF-Thumbnail- Compatibility-Test-File.pdf ”。 The test file helps isolate the problem on systems that use ImageMagick and GhostScript as the image processing and conversion program in a shared hosting environment. 测试文件有助于在使用ImageMagick和GhostScript作为共享托管环境中的图像处理和转换程序的系统上隔离问题。
This should also help with your problem since the solution is both the Example PHP scripts and using the example standards compliant PDF file for testing. 这也应该有助于解决您的问题,因为解决方案既是示例PHP脚本,又是使用与示例标准兼容的PDF文件进行测试。
Best Regards, Michael Brice 最好的问候,迈克尔·布里斯
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.