• Ogłoszenie:

Creating pdf thumbnail in php and caching it

Wszystko odnośnie tworzenia grafiki - obróbka, problemy, oceny.
Tworzenia Stron internetowych - HTML, PHP, MySQL...

Creating pdf thumbnail in php and caching it

Postprzez MahishTanzon 03 Lut 2023, 06:33

reklama
I'm using a generic PHP based CMS, i wanted to create a script which read the pdf created a thumbnail and cached it. There were lots of different answers, and i did have a fair few problems with different versions of imagick, but this is script which worked for me.

some people might find it useful and maybe omegle shagle voojio someone could advice me if it is optimised?

<?php

$loc = *the file location*;
$pdf = *the file name*;
$format = "jpg";
$dest = "$loc$pdf.$format";

if (file_exists($dest))
{
$im = new imagick();
$im->readImage($dest);
header( "Content-Type: image/jpg" );
echo $im;
exit;
}
else
{
$im = new imagick($loc.$pdf.'[0]');
$im->setImageFormat($format);

$width = $im->getImageheight();
$im->cropImage($width, $width, 0, 0);
$im->scaleImage(110, 167, true);

$im->writeImage($dest);

header( "Content-Type: image/jpg" );
echo $im;
exit;
}

?>
MahishTanzon
~user
 
Posty: 28
Dołączenie: 29 Gru 2022, 15:04



Powróć do Grafika & Webmastering

Kto jest na forum

Użytkownicy przeglądający to forum: Brak zarejestrowanych użytkowników oraz 2 gości