-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththumb.php
110 lines (94 loc) · 2.8 KB
/
thumb.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
error_reporting(E_ALL);
require_once("connect.php");
$id=$_REQUEST['id'];
if(!isset($id)||$id=='')
{
echo 'dont joke there is no such id available on our server';
exit;
}
/*get the file name of this id*/
$result=mysql_query("SELECT * FROM `imagelist` WHERE `id`='$id'");
$noofrows=mysql_num_rows($result);
if($noofrows==1)
{
$row=mysql_fetch_array($result);
$filename=$row['filename'];
}
/*end of getting file name from db*/
$localimageurl="c:/xampp/htdocs/xampp/snapheap/uploads/".$filename;
$size = getimagesize($localimageurl);
if($size[0]>$size[1])
{
//need to add the text in bottom and horizontal
$imagetemp = new IMagick($localimageurl);
$image = new Imagick();
//$image->readImage($localimageurl);
$image->newImage($imagetemp->getImageWidth(), $imagetemp->getImageHeight(), new ImagickPixel("white"));
$image->compositeImage($imagetemp, imagick::COMPOSITE_OVER, 0, 0);
$image->adaptiveResizeImage(100,0);
header("Content-Type: image/" . $imagetemp->getImageFormat());
//echo $image;
//horizontal and bottom strip
// Create some objects
//$image = new Imagick();
$draw = new ImagickDraw();
$pixel = new ImagickPixel( 'white' );
//* New image
$image->newImage(100, 12, $pixel);
//* Black text
$draw->setFillColor('black');
//* Font properties
$draw->setFont('DroidSans-Bold.ttf');
$draw->setFontSize( 9 );
//* Create text
$image->annotateImage($draw, 0, 8, 0, 'SnapHeap:'.$id);
//* Give image a format
$image->setImageFormat('png');
//* Output the image with headers
//header('Content-type: image/png');
//echo $image;
$image->resetIterator();
$combined = $image->appendImages(true);
/* Output the image */
$combined->setImageFormat("png");
//header("Content-Type: image/png");
echo $combined;
}
else
{
//need to add the text in right and vertical
$imagetemp = new IMagick($localimageurl);
$image = new Imagick();
//$image->readImage($localimageurl);
$image->newImage($imagetemp->getImageWidth(), $imagetemp->getImageHeight(), new ImagickPixel("white"));
$image->compositeImage($imagetemp, imagick::COMPOSITE_OVER, 0, 0);
$image->adaptiveResizeImage(0,100);
header("Content-Type: image/" . $imagetemp->getImageFormat());
//echo $image;
//vertical and right strip
// Create some objects
$draw = new ImagickDraw();
$pixel = new ImagickPixel( 'white' );
//* New image
$image->newImage(12, 100, $pixel);
//* Black text
$draw->setFillColor('black');
//* Font properties
$draw->setFont('DroidSans-Bold.ttf');
$draw->setFontSize( 9 );
//* Create text
$image->annotateImage($draw, 10, 99, -90, 'SnapHeap:'.$id);
//* Give image a format
$image->setImageFormat('png');
//* Output the image with headers
//header('Content-type: image/png');
//echo $image;
$image->resetIterator();
$combined = $image->appendImages(false);
/* Output the image */
$combined->setImageFormat("png");
//header("Content-Type: image/png");
echo $combined;
}
?>