Link to home
Start Free TrialLog in
Avatar of StarThunder
StarThunder

asked on

PHP Picture Resize Limit?

Ok, I have the following code to take an image from a blob and resize the image, then it passes the image to the parent file as an HTML image.
This works great because if I have a file like 1MB it changes the file you see to smaller like 300k. And it doesn't slow the browsers down by sending too much data.

The problem is, I got a routine working that will allow me to save large files, up to 20MB if I wanted to. But when I try to Retrieve the picture that is over 1.5MB and make it say... 200px wide, it displays nothing. But if I retrieve the raw picture in an HTML image it displays fine, it's huge, but it's fine.

This solution seems to be the standard one for resizing pics. Is there a size limit to some of the functions? I really need it to display what I give it because the Customer isn't very computer savy, and would get confused resizing pics.


<?php
            // Connect to server and select database
            $conn2 = mysql_connect("localhost", "user", "password");
            mysql_select_db("database", $conn2) or die(mysql_error());
            
            $query2 = mysql_query("SELECT * FROM `main_page_info`");
            
$pic = $_GET[imagename];
$row = mysql_fetch_array($query2);
$content = $row[$pic];

// Print Picture
$im = imagecreatefromstring($content);
$x = imagesx($im);
$y = imagesy($im);

if( $_GET[pwidth] == "F")
{
      $desired_width = $x;
}
else
{
      $desired_width = $_GET[pwidth];
}
$desired_height = $y/($x/$desired_width);

$new = imagecreatetruecolor($desired_width, $desired_height);
imagecopyresampled($new, $im, 0, 0, 0, 0, $desired_width, $desired_height, $x, $y);

header('Content-type: <span class="posthilit">image</span>/jpeg');
imagejpeg($new, null, 75);

imagedestroy($im);
exit;
?>
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
When you don't engage in any dialog and mark a grade down, it requires an explanation.  Please explain.
http://support.experts-exchange.com/customer/portal/articles/481419