rendered paste body<?php
function res($newfile, $old, $maxWidth, $maxHeight) {
file_put_contents($newfile, file_get_contents($old));
$im = imagecreatefrompng($newfile);
$width_o = imagesx($im);
$height_o = imagesy($im);
$ratio = $maxHeight / $height_o;
$width = $width_o * $ratio;
$height = $maxHeight;
if($width > $maxWidth) {
$ratio = $maxWidth / $width;
$height = $height * $ratio;
$width = $maxWidth;
}
$ni = imagecreatetruecolor($width, $height);
imagealphablending($ni, false);
imagesavealpha($ni, true);
$trans = imagecolorallocatealpha($ni, 255, 255, 255, 127);
imagefilledrectangle($ni, 0, 0, $width, $height, $trans);
imagecopyresampled($ni, $im, 0, 0, 0, 0, $width, $height, $width_o, $height_o);
imagepng($ni, $newFile, 100);
}
header("Content-Type: image/png");
$image = $_GET['im'];
$filename = "cache/thumb_".basename($image);
res($filename, $image, 100, 80);
echo file_get_contents($filename);
?>