-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathtim.php
More file actions
31 lines (25 loc) · 885 Bytes
/
tim.php
File metadata and controls
31 lines (25 loc) · 885 Bytes
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
include('config.php');
function tim($source, $newWidth)
{
global $TIM_QUALITY;
$image = imagecreatefromjpeg($source);
// Get image dimensions
$dimensions = getimagesize($source);
$width = $dimensions[0];
$height = $dimensions[1];
// Calculate ration
$ratio = $width / $height;
$newHeight = $newWidth / $ratio;
// Create an empty image
$resizedImage = imagecreatetruecolor($newWidth, $newHeight);
// Fill it with resized version of original image
imagecopyresampled($resizedImage, $image, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
// Notify the browser that incoming response is an image
header("Content-Type: image/jpeg");
echo imagejpeg($resizedImage, null, $TIM_QUALITY);
// Free the memory
imagedestroy($image);
imagedestroy($resizedImage);
}
tim(hex2bin($_GET["image"]), $TIM_SIZE);