Re: Re: resizing images comming out of blobs

From: Date: Fri, 05 Jul 2002 12:57:42 +0000
Subject: Re: Re: resizing images comming out of blobs
References: 1 2 3  Groups: php.db 
Request: Send a blank email to php-db+get-20338@lists.php.net to get a copy of this message
David, If you feel better about re-sizing it on the server side, you can do that easily with the ImageCopyResized() command.. and a novice will usually do just that. My system is not big by any means, and I only have about 27,000 images on file. But I did not hack when I decided to do the stretch on the client side. I had to send a lot of images so speed was a BIG concern. You can get really poor looking images if you send very small images and increase it too much, so send the clarity you need. But this happens if you increase the size on the client or the server. Problem is, if you increase the size on the server and then send it, it takes more time. For example, if you increase the size by 300 pixels per side, that is 300 X 300 or 90,000 extra pixels you have to send. In essence you stretched it on the server side and then sent all that data instead of sending the smaller image and stretching it on the client side. Also since the image is the same each time they ask for a larger or smaller image, the image is already cached on the client and it only has to refresh it with a different size. Re-sized on the server side will require that it be sent each time they ask for a different size. Every system is unique. If you only have a few images to send, then what you do don't matter as much. And if you are interested in image clarity, and in some cases I am, then indeed you do have to do more elaborate image processing on the server side. But from what I understand from the question, is could they re-size an existing image, and if that is all they are interested in, this is the best way. ================================================================= David Russell wrote:
Hi Dan, Forgive me if I have missed something, but this is not actually doing anything to the image. the *same* image is being sent to the client, and it is up to the client browser to resize the image in the size you specify. Therefore, no matter what image size is specified, the same image is sent to the client. This could have the effect of stretching the image (if a large number was chosen), or shrinking it - on the client while the same file size is sent down the wire. Surely there is a better way to do this - preferably on the server side so that the correct image size is always sent... I do not know GD at all, and thus cannot really contribute to teh correct way to do this, but I think your way os a bit of a poor mans hack. Cheers David R Dan Koken wrote:
Andy, Yes I do it all the time. In this example, I do this with a window that has buttons across the top of a image representing size from 1 to 10. Depending on the button they select they get a image displayed from small to large. Here is a snip of code that displays the sized images. ---------------------------- The button name is $s. They select from 1 to 10, but can be any increment.
$hi = $s * 100;    // size in 100 pixels. (but can be any increment)
echo " <TABLE BORDER='15' CELLPADDING='0' CELLSPACING='0'><TR><TD> <image src='ft_image.php?imno=$image_num' BORDER=0 ALIGN='TOP' height=$hi></TD></TR></TABLE> "; Note: in the 'image src' you give it a program name, not the image, and pass some way for it to read the image from the DB. In this case the program is ft_image.php and it passes imno. To didplay the photo in ft_image.php, execute the following:
        header("Content-type:  image/jpeg");
        print(mysql_result($result, 0, "photo_image"));
photo_image is name of blob field from the DB --------------------------------- HTH.. Good luck.. Dan. =========================================================== Andy wrote:
Hi there, I am wondering how to resize an image which is stored in a mysql blob field. With files this workes just fine, but how to do this with the image comming from blob? Has anybody done this already? Thank you for any help on that, andy


« previous php.db (#20338) next »