From 62f7ae00811dea2aa4b8c6daac2dae3c2a7ae5a5 Mon Sep 17 00:00:00 2001 From: karim-hza Date: Wed, 24 May 2017 18:07:29 +0200 Subject: [PATCH] Use imagecreatefromstring when imagecreatefromjpeg fail For some image the function 'imagecreatefromstring' does'nt work beacause the image is in violation with the jpeg spec. https://stackoverflow.com/questions/35337709/invalid-sos-parameters-for-sequential-jpeg/43271528#43271528 --- src/Intervention/Image/Gd/Decoder.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Intervention/Image/Gd/Decoder.php b/src/Intervention/Image/Gd/Decoder.php index 313e6261..dbb9dce0 100644 --- a/src/Intervention/Image/Gd/Decoder.php +++ b/src/Intervention/Image/Gd/Decoder.php @@ -29,7 +29,10 @@ class Decoder extends \Intervention\Image\AbstractDecoder break; case IMAGETYPE_JPEG: - $core = @imagecreatefromjpeg($path); + $core = @imagecreatefromjpeg($path); + if (!$core) { + $core= @imagecreatefromstring(file_get_contents($path)); + } break; case IMAGETYPE_GIF: