Resizing image with php works with small images but not large

This is a discussion on Resizing image with php works with small images but not large within the PHP General forums, part of the PHP Programming Forums category; Here is my problem If I upload a picture using a picture at 1024x768 at 112k the image is uploaded ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-17-2007
cbielich@yahoo.com
 
Posts: n/a
Default Resizing image with php works with small images but not large

Here is my problem

If I upload a picture using a picture at 1024x768 at 112k the image is
uploaded fine and the thumbnail is generated fine.

If I upload a picture at 2333x1750 at 2mg the original file is
uploaded fine but the thumbnail is not created. Anyone know why?

My php is set to upload files at a max of 8 megs so Im not sure as to
why the thumbnail on the larger image wont generate.

<? include ('connect.php'); ?>
<? session_start(); ?>
<?
if ((isset($user_logged) && $user_logged != "") || (isset($spassword)
&& $spassword != "")) {
$userloggedin = true;
}
if (isset($userloggedin)) {
$mktime = mktime();
$idir = "/pics/member_images/$user_id$mktime"; // Path To Images
Directory

$copy = copy($_FILES['imagefile']['tmp_name'], "$idir" .
$_FILES['imagefile']['name']); // Move Image From Temporary Location
To Permanent Location
// Specify your file details
$current_file_nodir = $user_id.$mktime.$_FILES['imagefile']
['name'];
$current_file = "$idir" . $_FILES['imagefile']['name'];
$max_width = '500';
// Get the current info on the file
$current_size = getimagesize($current_file);
$current_img_width = $current_size[0];
$current_img_height = $current_size[1];
$image_base = explode('.', $current_file);
// This part gets the new thumbnail name
$image_basename = $image_base[0];
$image_basename_explode = explode('/', $image_basename);
$image_basename_after_explode = $image_basename_explode[6];
$image_ext = $image_base[1];
$thumb_image_name = $image_basename_after_explode.'-th.'.
$image_ext;
$thumb_name = $image_basename.'-th.'.$image_ext;
// Determine if the image actually needs to be resized
// and if it does, get the new height for it
if ($current_img_width > $max_width)
{
$too_big_diff_ratio = $current_img_width/$max_width;
$new_img_width = $max_width;
$new_img_height = round($current_img_height/$too_big_diff_ratio);
// Convert the file
$make_magick = exec("convert -geometry $new_img_width x
$new_img_height $current_file $thumb_name", $retval);
// Did it work?
if (!($retval))
{
$sql = "INSERT INTO memberimages VALUES
('','$user_id','','$thumb_image_name','$current_fi le_nodir')";
$result = mysql_db_query($db,$sql,$cid);
echo '<script type=""text/javascript"">history.go(-1);</script>';
}
else
{
session_register("error");
$error = "Unable to Upload the Image, Please try again.";
echo '<script type=""text/javascript"">history.go(-1);</script>';
}
}
else
{
echo '<script type=""text/javascript"">history.go(-1);</script>';
}
} else {
session_register("error");
$error = "You need to be logged in to upload your avatar.";
echo '<script type=""text/javascript"">history.go(-1);</script>';
}
?>

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:02 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0