Jump to content
sasori

imagecreatefromjpeg() error help

Recommended Posts

Hi, 

 

before posting this problem, I already tried googling and tried those possible solutions that could help but still failed.

I am having a problem with that PHP function

imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error:

based from what i found in google, some say, use

ini_set("gd.jpeg_ignore_warning", 1);

failed.

 

some say, use

init_set("memory_limit", -1)

still failed

 

I am sure that I am passing .jpg image, how come i keep on getting that error ?

any suggestions of what to do?

Edited by sasori

Share this post


Link to post
Share on other sites

How are you "sure that I am passing .jpg image"?  Are you checking it? Are you checking the mime? Are you checking the extension?  Are you sure it isn't a script that has been faked as an image?

Basically, show us the code.

Share this post


Link to post
Share on other sites

it's not a script..i have a alot of random images in my local storage that i usually use for testing ... here's the part of the code

                $fext = pathinfo($url, PATHINFO_EXTENSION);
                $tmp_name = date('His') . rand() . "." . $fext;
                $filename = $path .'/'. $tmp_name;
                $cont = @file_get_contents($url);
                $op = @fopen($filename, 'w+');
                @fwrite($op, $cont);
                @fclose($op);
                chmod($filename, 0777);
                $orientation = 999;
                $exif = null;
                if (strtolower($fext) == 'jpg' || strtolower($fext) == 'jpeg') {
                    try {
                        $exif = @exif_read_data($filename);
                    } catch (Exception $e) {
                        Yii::log($e->getMessage());
                    };
                    if (!empty($exif) && !empty($exif['Orientation'])) {
                        $orientation = $exif['Orientation'];
                    }
                    $img = imagecreatefromjpeg($filename);
Edited by sasori

Share this post


Link to post
Share on other sites

Check the headers of the file.  The extension can be jpeg, but the headers are what gets checked.

Share this post


Link to post
Share on other sites

Check the headers of the file.  The extension can be jpeg, but the headers are what gets checked.

it's a jpeg image...how come other jpegs are being read without problems at all?

 

here are the two images, the baby apparel is ok, but the knitted hat is causing that error I mentioned in this thread..

 

i'm not sure if this forum modified those files that i just attached in this reply

post-66825-0-20945000-1414080619_thumb.jpg

post-66825-0-25251300-1414080665_thumb.jpg

Edited by sasori

Share this post


Link to post
Share on other sites

the thing that has caused the issue is the white space in the image name...to fix the issue.. the sencha front-end code is now encoding the url being passed to me :D 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

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.