I have the following code in a file that is called using the href= in an <img>.
It works most of the time but a few images don't show up and don't show any errors if I put the full href in the address bar. I can't see any difference in the images that will and won't show.
eg.
image-DSC0001.JPG works and
image-IMG-002.JPG doesn't.
I'm totally stumped.
<?php
if ($src) ImageDestroy($src);
if ($dst) ImageDestroy($dst);
if ($_GET['size'] == "large")
{
if (!$max_width)
$max_width = 550;
if (!$max_height)
$max_height = 530;
}
else
{
if (!$max_width)
$max_width = 150;
if (!$max_height)
$max_height = 100;
}
$size = GetImageSize("/var/www/vhosts/url.com/httpdocs/New Site/Images/Users Gallery/".$_GET["image"])or die("Could not get image size");
$width = $size[0];
$height = $size[1];
$x_ratio = $max_width / $width;
$y_ratio = $max_height / $height;
if (($width <= $max_width) && ($height <= $max_height))
{
$tn_width = $width;
$tn_height = $height;
}
elseif (($x_ratio $height) < $max_height)
{
$tn_width = $max_width;
$tn_height = ceil($x_ratio $height);
}
else
{
$tn_width = ceil($y_ratio * $width);
$tn_height = $max_height;
}
$src = ImageCreateFromJpeg("/var/www/vhosts/url.com/httpdocs/New Site/Images/Users Gallery/".$_GET["image"])or die("Could not create from Jpeg");
$dst = ImageCreateTrueColor($tn_width, $tn_height)or die("Could not create new image");
ImageCopyResized($dst, $src, 0,0,0,0, $tn_width, $tn_height, $width, $height)or die("Could not copy resized");
header('Content-type: image/jpg');
imagejpeg($dst, null, 100);
?>