adrianTNT Posted October 4, 2006 Share Posted October 4, 2006 Hello, I thought it should be something easy but I cannot find a simple sample code for this...I have more images that are saved as 250x250px on server and I need to display them on some page as lower size, e.g 125x125px.I do not need to physically store them at the new size.I thought it should be an easy way like:<img src=" <? GD_resize('my_image.jpg',125,125);?> " width="250" height="187">But I could not find a sample like this. Is there a way to resize an image like above?Thank you.- Adrian. Quote Link to comment https://forums.phpfreaks.com/topic/23028-resizing-an-image-by-gd-or-imagemagick/ Share on other sites More sharing options...
brendandonhue Posted October 4, 2006 Share Posted October 4, 2006 No, you can't mix outputting images and HTML like that. You can use imagecopyresampled() if you want to resize an image. Quote Link to comment https://forums.phpfreaks.com/topic/23028-resizing-an-image-by-gd-or-imagemagick/#findComment-104009 Share on other sites More sharing options...
printf Posted October 4, 2006 Share Posted October 4, 2006 you have to call a remote script that dumps the resized image to the browser, you can't do it in the same page! A image is binary data, a web page is not! Create a page that takes a $_GET / $_REQUEST, then grabs the original image, resizes it, then dumps it to the browser! If the image doesn't exist, send a default image!me! Quote Link to comment https://forums.phpfreaks.com/topic/23028-resizing-an-image-by-gd-or-imagemagick/#findComment-104011 Share on other sites More sharing options...
adrianTNT Posted October 4, 2006 Author Share Posted October 4, 2006 by the above solutions is it required that the new image be physically saved on server?What should the external script contain (if is a short code block).Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/23028-resizing-an-image-by-gd-or-imagemagick/#findComment-104016 Share on other sites More sharing options...
printf Posted October 5, 2006 Share Posted October 5, 2006 [quote]by the above solutions is it required that the new image be physically saved on server?[/quote]NO// make your <img> tag like so[code]<img src='/images.php?image=my_image.jpg' alt='' />[/code]Download the the example [b]ZIP[/b] file, I attachedme![attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/23028-resizing-an-image-by-gd-or-imagemagick/#findComment-104041 Share on other sites More sharing options...
adrianTNT Posted October 5, 2006 Author Share Posted October 5, 2006 Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/23028-resizing-an-image-by-gd-or-imagemagick/#findComment-104048 Share on other sites More sharing options...
simcoweb Posted October 12, 2006 Share Posted October 12, 2006 I came across this thread while looking for some relief regarding image resizing. I downloaded sprintf's 'example' script and it works great if you're calling a single pic.What I'm doing is running a 'while' loop through the mysql results to display multiple profiles in some html. I was previously using a call like this:[code]while ($a_row = mysql_fetch_array($results)){echo "<div align='center'> <table border='0' cellpadding='0' style='border-collapse: collapse' width='530'> <tr> <td colspan='2'> <img border='0' src='images/top.gif' width='530' height='35'></td> </tr> <tr> <td style='padding-left: 10px;' height='15' colspan='2'> <h2>". $a_row['firstname'] ." ". $a_row['lastname'] . "</h2> </td> </tr> <tr> <td style='padding-left: 10px; padding-right: 10px; padding-top:5px; padding-bottom:5px' width='210' valign='top'><img src='images/photo/" . $a_row['photo'] . "' width='200' height='225'></td>[/code]etc. etc.And it worked fine through the array. However, i'm using standard HTML tags for the image resizing which, of course, makes the pics all whacky. Therefore i'm desperately looking for a way to resize each image on the fly and came across your script. Now, I've tried a couple of ways to produce the same results using your script like these:[code]<img src='/image_f.php?image=$photo' alt='' />[/code]and[code]<img src='/images/photo/" . $a_row['photo'] . "' />[/code]The second works fine but only displays the first pic or some of the pics but fails on many of them. Here's an example:[url=http://www.plateauprofessionals.com/display-page-a.php?page=3]http://www.plateauprofessionals.com/display-page-a.php?page=3[/url]Question is can this resize script be adapted to work in this enviroment where it's pulling multiple pics from the same folder, resizing them, and displaying them properly?Thanks for the help! Quote Link to comment https://forums.phpfreaks.com/topic/23028-resizing-an-image-by-gd-or-imagemagick/#findComment-108018 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.