SieRobin Posted April 26, 2006 Author Share Posted April 26, 2006 I did view source, the IMG tag looks like this for my picture.<img src='image.php?img=userimages/me.jpg' border='0'>Other then that, I'm not sure what you mean, sorry :\ Quote Link to comment https://forums.phpfreaks.com/topic/8329-image-resize/page/2/#findComment-31051 Share on other sites More sharing options...
kenrbnsn Posted April 26, 2006 Share Posted April 26, 2006 Ok, you want to put debug statements into the image.php file. But those statements can't write to the screen. They should write to a file.What type of platform are you using? Windows or Unix (linux)Here's how I would do it:[code]<?phpfunction write_debug($fp,date('Y-m-d G:i:s') . $str) { f write($fp,$str . "\n");}session_start();$dbg = (isset($_GET['dbg']))?true:false;if ($dbg) { $fp = f open('image_debug.txt','a'); write_debug($fp,' -- Entering image.php'); write_debug($fp,' -- $_GET --'); write_debug($fp,print_r($_GET,true)); f close($fp);}if (isset($_GET['img'])) {// $img_name = "userimages/$pstats3[uimage]"; // <--- this statement is wrong -- my mistake sorry $img_name = $_GET['img'];$max_width = 150;$max_height = 150;$size=getimagesize($img_name);$width_ratio=($size[0] / $max_width);$height_ratio =($size[1] / $max_height);if($width_ratio>=$height_ratio){ $ratio=$width_ratio;}else{ $ratio=$height_ratio;}$new_width=($size[0] / $ratio);$new_height=($size[1] / $ratio);header("Content-Type: image/jpeg");$src_img = imagecreatefromjpeg($img_name);$thumb = imagecreatetruecolor($new_width,$new_height);imagecopyresampled($thumb, $src_img, 0,0,0,0,($new_width-1),($new_height-1),$size[0],$size[1]);imagejpeg($thumb);imagedestroy($src_img);imagedestroy($thumb);exit();}?>[/code]While I was added the debug code to your image.php I noticed what the problem is. See the comment above with the "<---" in it.The next line is the corrected line.If changing that line works, you don't have to put in the debugging lines.In the debug area I had to write the file functions with a space in them.Ken Quote Link to comment https://forums.phpfreaks.com/topic/8329-image-resize/page/2/#findComment-31059 Share on other sites More sharing options...
SieRobin Posted April 26, 2006 Author Share Posted April 26, 2006 ahha, it works :] Thank ya! Quote Link to comment https://forums.phpfreaks.com/topic/8329-image-resize/page/2/#findComment-31063 Share on other sites More sharing options...
SieRobin Posted April 26, 2006 Author Share Posted April 26, 2006 Just one more question, I'm pretty sure it's easy to answer.. well since the only thing the code seems to accept is JPEG is there a way to allow GIF and PNG? Quote Link to comment https://forums.phpfreaks.com/topic/8329-image-resize/page/2/#findComment-31070 Share on other sites More sharing options...
SieRobin Posted April 27, 2006 Author Share Posted April 27, 2006 How exactly can I make it also accept GIF files and not just JPEG? Because, right now it will only display if it's in JPEG format. Quote Link to comment https://forums.phpfreaks.com/topic/8329-image-resize/page/2/#findComment-31194 Share on other sites More sharing options...
darga333 Posted April 27, 2006 Share Posted April 27, 2006 forgive me if i am wrong but i would think you would just need to modify this lineheader("Content-Type: image/jpeg");i dont know the syntax but i would make it something like thisheader("Content-Type: image/jpeg/JPEG/GIF/gif/PNG/png");does that work?? Quote Link to comment https://forums.phpfreaks.com/topic/8329-image-resize/page/2/#findComment-31214 Share on other sites More sharing options...
SieRobin Posted April 27, 2006 Author Share Posted April 27, 2006 My server is down right now but, I don't think that'd work since, it's asking it to createfromjpeg.. now if I were to put createfromgif it would allow all GIF extensions, but I can try it, never hurt to try. Quote Link to comment https://forums.phpfreaks.com/topic/8329-image-resize/page/2/#findComment-31314 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.