Jump to content

ljones

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

ljones's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for the reply lightningstrike, Just so I have this straight, the reason is because jpgs are compressed and when imagecreatefromjpeg() is run it needs a huge amount of memory to unpack the jpg and resample it, depending on the original size. Is there a way to dynamically check the amount of memory needed? Thanks again.
  2. I put this line in at the beginning: ini_set("memory_limit","50M"); and it does the trick, is this the good way to go?
  3. Could one of you kind folks have a look at this and give me some insight as to why, when the uploaded image is say greater than 3.5 mb, the lowRes image does not get created? A temp dir is created, the uploaded file gets moved there (no matter it's size), the doResize function gets called pointing back to the temp dir and file to create the thumbnail, this works (no matter it's size). Now the problem, when the doResize is called to create the lowRes image, if the file is below 3.5mb, it works, but when it's above, it does not. The obvious thing is there is a max limit of some sort, but here's the kicker, the file (no matter it's size) is has already been moved to the temp dir and resides on the server. Now if the function is just pointing to the file already residing on the server, why won't it create the lowRes? Thanks in advance, any help would be greatly appreciated. $temp_file_dir = "./temp_file/"; $file_dir = "../fscommand/media/images/images/"; $resize_Image = 800; $imageQuality = 90; $thumb_dir ="../fscommand/media/images/thumbnails/"; $resize_Thumbnail = 100; $thumbQuality = 75; //create the directory if doesn't exists (should have write permissons) if(!is_dir($temp_file_dir)) mkdir($temp_file_dir, 0666); //////////// function doResize($srcDirectory, $targetDirectory, $targetSize, $targetQuality) { $img = imagecreatefromjpeg($srcDirectory); $width = imagesx($img); $height = imagesy($img); //////////////////////////////////////////// if($width>$height){ $new_width = $targetSize; $new_height = floor( $height * ( $targetSize / $width ) ); }else if($height>$width){ $new_width = floor( $width * ( $targetSize / $height ) ); $new_height = $targetSize; }else if($height==$width){ $new_width = $targetSize; $new_height = $targetSize; } // create a new temporary image $image_resized = imagecreatetruecolor( $new_width, $new_height ); // copy and resize old image into new image imagecopyresampled( $image_resized, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height ); imagejpeg($image_resized, $targetDirectory, $targetQuality); // free memory used imagedestroy($image_resized); imagedestroy($img); } //move the uploaded file move_uploaded_file($_FILES['Filedata']['tmp_name'], $temp_file_dir.$_FILES['Filedata']['name']); // doResize($temp_file_dir.$_FILES['Filedata']['name'], $thumb_dir.$_FILES['Filedata']['name'], $resize_Thumbnail); doResize($temp_file_dir.$_FILES['Filedata']['name'], $file_dir.$_FILES['Filedata']['name'], $resize_Image);
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.