Siz istediğiniz gibi Image.php olarak kaydedin, bu çalışması gerekir.
<?php
if (array_key_exists('img', $_GET) === true)
{
if (is_file($_GET['img']) === true)
{
$scale = array();
$scale[] = (array_key_exists('width', $_GET) === true) ? $_GET['width'] : null;
$scale[] = (array_key_exists('height', $_GET) === true) ? $_GET['height'] : null;
Image($_GET['img'], implode('*', $scale));
}
}
function Image($image, $scale = null)
{
$type = image_type_to_extension(@exif_imagetype($image), false);
if (function_exists('ImageCreateFrom' . $type) === true)
{
$image = call_user_func('ImageCreateFrom' . $type, $image);
if (is_resource($image) === true)
{
$size = array(ImageSX($image), ImageSY($image));
if (isset($scale) === true)
{
$scale = array_filter(explode('*', $scale), 'is_numeric');
if (count($scale) >= 1)
{
if (empty($scale[0]) === true)
{
$scale[0] = $scale[1] * $size[0] / $size[1];
}
else if (empty($scale[1]) === true)
{
$scale[1] = $scale[0] * $size[1] / $size[0];
}
}
else
{
$scale = array($size[0], $size[1]);
}
}
else
{
$scale = array($size[0], $size[1]);
}
$result = ImageCreateTrueColor($scale[0], $scale[1]);
if (is_resource($result) === true)
{
ImageCopyResampled($result, $image, 0, 0, 0, 0, $scale[0], $scale[1], $size[0], $size[1]);
if (headers_sent() === false)
{
header('Content-Type: image/' . $type);
if ($type == 'gif')
{
return ImageGIF($result, null);
}
else if ($type == 'png')
{
return ImagePNG($result, null, 9);
}
else if ($type == 'jpeg')
{
return ImageJPEG($result, null, 90);
}
}
}
}
}
return false;
}
?>