Hello,
I am using the following function to create thumbnail images on the fly. The image is created fine however I can't do any manipulation with it afterwards. For example I want to change image border when I put mouse cursor over it. The default image which is not converted from big image has this functionality. Also I can't see the source code of the page with thumbnail. Finally, The new thumbnail imege (which should be smller then original 4 times) is not created. Us there error in the code, or I am doing something wrong? Please help.
Here is code I use:
<?
Header("Content-type: image/jpeg"
$image = "1.jpg";
$defaultimg ="noimages.jpg";
if (file_exists($image)){
$img_orig = ImageCreateFromJpeg($image);
$new_width = imagesx($img_orig) / 4;
$new_height = imagesy($img_orig) / 4;
$img_sub = ImageCreateTrueColor($new_width,$new_height);
ImageCopyResampled($img_sub,$img_orig,0,0,0,0,$new_width,$new_height,imagesx($img_orig),imagesy($img
_orig));
ImageJPEG($img_sub, '', 100);
ImageDestroy($img_orig);
ImageDestroy($img_sub);
echo" <img src=";
echo" $image";
echo" onmouseover=\"this.style.border='2px solid blue';\"";
echo" onmouseout=\"this.style.border='2px solid black';\"";
print" alt=";
echo" Click to Enlarge";
echo" >";}
else {
echo" <img src=";
echo" $defaultimg ";
echo" onmouseover=\"this.style.border='2px solid blue';\"";
echo" onmouseout=\"this.style.border='2px solid black';\"";
echo" >";}
?>
I am using the following function to create thumbnail images on the fly. The image is created fine however I can't do any manipulation with it afterwards. For example I want to change image border when I put mouse cursor over it. The default image which is not converted from big image has this functionality. Also I can't see the source code of the page with thumbnail. Finally, The new thumbnail imege (which should be smller then original 4 times) is not created. Us there error in the code, or I am doing something wrong? Please help.
Here is code I use:
<?
Header("Content-type: image/jpeg"
$image = "1.jpg";
$defaultimg ="noimages.jpg";
if (file_exists($image)){
$img_orig = ImageCreateFromJpeg($image);
$new_width = imagesx($img_orig) / 4;
$new_height = imagesy($img_orig) / 4;
$img_sub = ImageCreateTrueColor($new_width,$new_height);
ImageCopyResampled($img_sub,$img_orig,0,0,0,0,$new_width,$new_height,imagesx($img_orig),imagesy($img
_orig));
ImageJPEG($img_sub, '', 100);
ImageDestroy($img_orig);
ImageDestroy($img_sub);
echo" <img src=";
echo" $image";
echo" onmouseover=\"this.style.border='2px solid blue';\"";
echo" onmouseout=\"this.style.border='2px solid black';\"";
print" alt=";
echo" Click to Enlarge";
echo" >";}
else {
echo" <img src=";
echo" $defaultimg ";
echo" onmouseover=\"this.style.border='2px solid blue';\"";
echo" onmouseout=\"this.style.border='2px solid black';\"";
echo" >";}
?>