Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with thumbnail function

Status
Not open for further replies.

sharapov

MIS
May 28, 2002
106
US
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(&quot;Content-type: image/jpeg&quot;);

$image = &quot;1.jpg&quot;;
$defaultimg =&quot;noimages.jpg&quot;;

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&quot; <img src=&quot;;
echo&quot; $image&quot;;
echo&quot; onmouseover=\&quot;this.style.border='2px solid blue';\&quot;&quot;;
echo&quot; onmouseout=\&quot;this.style.border='2px solid black';\&quot;&quot;;
print&quot; alt=&quot;;
echo&quot; Click to Enlarge&quot;;
echo&quot; >&quot;;}


else {

echo&quot; <img src=&quot;;
echo&quot; $defaultimg &quot;;

echo&quot; onmouseover=\&quot;this.style.border='2px solid blue';\&quot;&quot;;
echo&quot; onmouseout=\&quot;this.style.border='2px solid black';\&quot;&quot;;
echo&quot; >&quot;;}

?>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top