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($con tent);
$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($desi red_width, $desired_height);
imagecopyresampled($new, $im, 0, 0, 0, 0, $desired_width, $desired_height, $x, $y);
header('Content-type: <span class="posthilit">image</s pan>/jpeg' );
imagejpeg($new, null, 75);
imagedestroy($im);
exit;
?>
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",
mysql_select_db("database"
$query2 = mysql_query("SELECT * FROM `main_page_info`");
$pic = $_GET[imagename];
$row = mysql_fetch_array($query2)
$content = $row[$pic];
// Print Picture
$im = imagecreatefromstring($con
$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($desi
imagecopyresampled($new, $im, 0, 0, 0, 0, $desired_width, $desired_height, $x, $y);
header('Content-type: <span class="posthilit">image</s
imagejpeg($new, null, 75);
imagedestroy($im);
exit;
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://support.experts-exchange.com/customer/portal/articles/481419