Creating a simple image upload script and finding that when imageCreateFromJPEG is presented with a large image it reports that the image is not a valid JPEG - even though it is and can be loaded into photoshop.

Have tried loads of combo's including making the jpeg progressive, non-progressive changing dpi etc etc ... in the end it seems to be a combination of dpi of the image and the actual width and height of the image in pixels.

Has anyone found this?

More to the point has anyone found a solution to this? 😉

Thanks

Richard.

    I've never heard of this happening before. I've even used 1600*1200 images before and they work perfectly. Try echoing out the image data without using imagejpeg().

      For those who are interested the image I try to upload is

      2555x3214, 300 dpi around 450k

      R :o)

        Can you post a URL to the image? I'd like to try. Those are pretty high dimensions, I'll try with some images of my own.

        Edit: wait, yours is 450k?! Mine's 31.3 MB! 😛
        Edit #2: Okay, compressed it a bit, 169kb

          I can upload the picture fine through a webform, it's when I try to reduce it down to get a thumbnail, that's when imageCreateFromJPEG fails - it can't seem to read it - thinks it's not a valid JPEG - which as we've proved it is!!

          I'm using FreeBSD, Apache, PHP 4.3.0 GD 2.0

          Thnx

            Here is the script: http://12.218.96.144/test.php
            Here is the code:

            <?php
            include("img/imagefunctions.php");
            $im = imagecreatefromjpeg("big.jpg");
            imagezoom($im,0,0,imagesx($im),imagesy($im),".1");
            imagejpeg($im);
            imagedestroy($im);
            ?>

            The inclusion file is the Leonardo Image Functions Library.

            It works fine for me. Sounds like a problem with your resizing code.

              Looks like a config problem - as this code doesn't work for me - tells me again that the image is an invalid jpeg.

              I'll try it on a different server - see what happens....

              R :o)

                It seems to work on another server I have, the only difference being that this is running Linux - unfortunately it's on a shared server so I can't get hold of the php.ini file to check out what's happening.....

                Thanks for you help!

                R :o)

                  Hmm... it must just be something odd with your configuration, then.
                  Sorry I couldn't help all that much.

                    Write a Reply...