Jump to content

imagecreatefromjpeg() error help


Go to solution Solved by MDCode,

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
Link to comment
https://forums.phpfreaks.com/topic/292007-imagecreatefromjpeg-error-help/
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

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
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.