0

i am uploading image to s3 server and by php i am making a copy of that image on server , if i upload an image of 2.3 mb than the width of image is not coming but if i upload less size image like 26kb than it is showing the width of image so it is able to create the copy .

here is my code of php :

$s3 = new S3(awsAccessKey, awsSecretKey);

        $thumbId = uniqid();
        $thumbId .= ".jpg"; 
        $img = '';

        if($imgType == "image/jpeg"){
            $img = imagecreatefromjpeg($sourceUrl);
        }else if($imgType == "image/png"){
            $img = imagecreatefrompng($sourceUrl);
        }else if($imgType == "image/gif"){
            $img = imagecreatefromgif($sourceUrl);
        }else{
            $img = imagejpeg($sourceUrl);
        }

    echo    $width = imagesx( $img );
        echo $height = imagesy( $img );

please tell me what is the problem with size of image..

regards

rahul

XMen
  • 29,384
  • 41
  • 99
  • 151

2 Answers2

2

I can be wrong, but I am fairly sure this is a memory issue that doesn't get displayed because some aspect of error reporting is turned off.

Either that, or the 2.3 MB image is broken or in a format that GD can't read - make sure you try it with various images.

If it's a memory issue, here is a related question.

Community
  • 1
  • 1
Pekka
  • 442,112
  • 142
  • 972
  • 1,088
  • i have tried less than 1024 kb that is wokring fine and php.ini memory limit is 160M -- then what may be the problem – XMen Oct 30 '10 at 11:14
  • @Rahul what physical dimensions do the image files have? The file size is irrelevant with JPG, the width x height is important. Also, you are still not telling *what* happens exactly. What values go you get with a large image? – Pekka Oct 30 '10 at 11:17
  • blank values are coming with big images – XMen Oct 30 '10 at 11:19
  • the big image 2.3 mb is of size 1024x768 and small image of 0.9 mb is 4351x3000 – XMen Oct 30 '10 at 11:19
  • @Rahul what does "blank values" mean exactly. Is anything output at all? What happens if you add a `echo "test";`? Did you try my `ini_set` suggestion from above? – Pekka Oct 30 '10 at 11:20
  • yeah i have tried ini_set('display_errors', true) also no error comes – XMen Oct 30 '10 at 11:21
1

Read this link: PHP rebuilding images: memory usage

As riky said, set the memory limit higher if you can. Also realize that the dimensions are more important than the file size (as the file size is for a compressed image). When you open an image in GD, every pixel gets 3-4 bytes allocated to it, RGB and possibly A. Thus, your 4912px x 3264px image needs to use 48,098,304 to 64,131,072 bytes of memory, plus there is overhead and any other memory your script is using.

Community
  • 1
  • 1
CliffPR
  • 11
  • 2