php - Error Gd Libraries in Symfony -


i want use gd library symfony have error

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

my script in controller is

if (extension_loaded('gd') && function_exists('gd_info')) {             echo "php gd library enabled in system.";         }         else {             echo "php gd library not enabled on system.";         }          echo phpinfo();          $filename = $this->get('kernel')->getrootdir() . '/../web/logo/logo.png';         $percent = 0.5;  // content type //        header('content-type: image/jpeg');  // new sizes         list($width, $height) = getimagesize($filename);         $newwidth = $width * $percent;         $newheight = $height * $percent;  // load         $thumb = imagecreatetruecolor($newwidth, $newheight);         $source = imagecreatefromjpeg($filename);  // resize         imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);  // output         imagejpeg($thumb);          return new response("foo"); 

in phpinfo can see gd libraries.

i'm using mamp 3.2.1

this known problem gd library , not related symfony. gd strict when comes format of jpeg files, accepts specific jpeg configuration.

there many resources on problem. e.g. http://php.net/manual/de/function.imagecreatefromjpeg.php#55402

if error: "warning: imagecreatefromjpeg(): gd-jpeg: jpeg library reports unrecoverable error" check jpeg files. if saved in cmyk format (instead of rgb) gd fail load them (tested gd 2.0.12)

the dreaded "warning: imagecreatefromjpeg() : '/tmp/filename' not valid jpeg file in /phpfile.php on line xxx"

it seems gd library less tolerant of buggy jpeg files other programs. solution suggested set gd ignore jpeg error's before processing image, this:

ini_set("gd.jpeg_ignore_warning", 1);


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -