Home > Backend Development > PHP Tutorial > PHP converts PDF to PNG format through the imagick library

PHP converts PDF to PNG format through the imagick library

WBOY
Release: 2016-07-25 08:43:12
Original
1236 people have browsed it
  1. function pdf2png($PDF,$Path){
  2. if(!extension_loaded('imagick')){
  3. return false;
  4. }
  5. if(!file_exists($PDF)){
  6. return false;
  7. }
  8. $IM = new imagick();
  9. $IM->setResolution(120,120);
  10. $IM->setCompressionQuality(100);
  11. $IM->readImage($PDF);
  12. foreach ($IM as $Key => $Var){
  13. $Var->setImageFormat('png');
  14. $Filename = $Path.'/'.md5($Key.time()).'.png';
  15. if($Var->writeImage($Filename) == true){
  16. $Return[] = $Filename;
  17. }
  18. }
  19. return $Return;
  20. }
复制代码

转成, imagick, php


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template