craygo Posted January 3, 2007 Share Posted January 3, 2007 It's been a while since I have had to post a question here. ;D I guess that's a good thing.well I have a function that resizes a picture. I do not want to create a new picture I just want to resize it and display it. Problem I am having is that it does the first picture and stops there. I want to use this in a loop when I get the picture names from the database. It was not working so I took out the loop and just tried to put 2 pictures in manually and i get the same thing[code]<?phpheader('Content-type: image/jpeg');function resampimagejpg($forcedwidth, $forcedheight, $sourcefile, $destfile, $imgcomp=0) { $g_imgcomp=100-$imgcomp; $g_srcfile=$sourcefile; $g_dstfile=$destfile; $g_fw=$forcedwidth; $g_fh=$forcedheight; if(file_exists($g_srcfile)) { $g_is=getimagesize($g_srcfile); if(($g_is[0]-$g_fw)>=($g_is[1]-$g_fh)) { $g_iw=$g_fw; $g_ih=($g_fw/$g_is[0])*$g_is[1]; } else { $g_ih=$g_fh; $g_iw=($g_ih/$g_is[1])*$g_is[0]; } $img_src=imagecreatefromjpeg($g_srcfile); $img_dst=imagecreatetruecolor($g_iw,$g_ih); imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $g_iw, $g_ih, $g_is[0], $g_is[1]); imagejpeg($img_dst,'',90); imagedestroy($img_dst); imagedestroy($img_src); return true; } else return false; }resampimagejpg("100", "100", "images/TEST.jpg", "");resampimagejpg("100", "100", "images/SHOback_jpg.jpg", "");?>[/code]I tried it with and without the header and get the same thing. I have the $destfile variable in there because I used this for an upload script to create thumbnails and it works great. So I just took out the destination so I can just view it in the browser.ThanksRay Link to comment https://forums.phpfreaks.com/topic/32701-solved-problem-with-function/ Share on other sites More sharing options...
printf Posted January 3, 2007 Share Posted January 3, 2007 Your going to have to call it from a image tag <img src='script.php?next=xxx'> in a different script! Because once you dump the first image, the browser waits for the EOF flag, once it's returned it stops reading, so you can't loop more than (1) image per (1) Content-Type header. So the browser only allows one content read up to EOF for any one Content-Type header.printf Link to comment https://forums.phpfreaks.com/topic/32701-solved-problem-with-function/#findComment-152183 Share on other sites More sharing options...
craygo Posted January 3, 2007 Author Share Posted January 3, 2007 Thanks that worked out great. Was not aware you could not do that with images.Ray Link to comment https://forums.phpfreaks.com/topic/32701-solved-problem-with-function/#findComment-152206 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.