简体   繁体   English

Yii用ImageMagick创建PDF缩略图

[英]Yii create PDF Thumbnail with ImageMagick

如果我上载PDF,我想创建自动缩略图,然后我将保存该路径,并使用yii框架构建网站,并尝试使用ImageMagick Any Body Help..Thx进行捕获。

I am also using Yii framework to generate the image file. 我也使用Yii框架生成图像文件。 It is pretty simple and straight forward. 这非常简单直接。 I am using window XP/apache and php 5.4 我正在使用Windows XP / apache和php 5.4

  1. Download and install the imagemagick http://www.imagemagick.org/script/download.php 下载并安装imagemagick http://www.imagemagick.org/script/download.php
  2. Download and install php extension for imagemagic http://pecl.php.net/package/imagick 下载并安装用于imagemagic的php扩展程序http://pecl.php.net/package/imagick
  3. Download and install the ghostscript because image magic use the ghost script to convert the pdf to images http://www.ghostscript.com/download/ 下载并安装ghostscript,因为图像魔术师使用ghost脚本将pdf转换为图像http://www.ghostscript.com/download/
  4. Write a method in your model class to handle conversion 在模型类中编写一个方法来处理转换

    use command : command format OR 使用命令: 命令格式

    use library : php manual 使用库: php手册

  5. Call the method after your form submission. 提交表单后,调用该方法。

check if the image is saved at the desired location. 检查图像是否保存在所需位置。 I hope that help. 希望对您有所帮助。 Let me know if you face any issue. 让我知道您是否遇到任何问题。

I know you asked about ImageMagick but maybe you could use GD instead to accomplish such simple operation. 我知道您问过ImageMagick,但也许您可以使用GD来完成这种简单的操作。 It's available virtually on every hosting. 它实际上可在每个主机上使用。

Examples in comments below docs. 文档下方评论中的示例。

http://php.net/manual/en/book.image.php http://php.net/manual/zh/book.image.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM