forked from ictinnovations/ictcore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtiff2jpg.php
executable file
·31 lines (29 loc) · 1.26 KB
/
tiff2jpg.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
/* * ***************************************************************
* Copyright © 2014 ICT Innovations Pakistan All Rights Reserved *
* Developed By: Nasir Iqbal *
* Website : http://www.ictinnovations.com/ *
* Mail : [email protected] *
* *************************************************************** */
$filename = $_GET["name"];
$path = "file/document/";
$pathThumbs = $path . "thumbs/";
$file = $path . $filename;
try {
// Saving every page of a TIFF separately as a JPG thumbnail
$images = new Imagick($file);
foreach ($images as $i => $thumb) {
// Providing 0 forces thumbnailImage to maintain aspect ratio
$thumb->setResolution(204, 98);
$thumb->resampleImage(98, 98, imagick::FILTER_UNDEFINED, 1);
// $thumb->thumbnailImage(300,0); show full size
$thumb->setImageCompression(imagick::COMPRESSION_JPEG);
$thumb->setImageCompressionQuality(90);
$thumb->writeImage($pathThumbs . $filename . $i . ".jpg");
echo "<center><br/>Page" . ($i + 1) . "<br/><img src='$pathThumbs$filename$i.jpg' alt='images' border=1></img></center>";
}
$images->clear();
$images->destroy();
} catch (Exception $e) {
echo $e->getMessage();
}