image icon indicating copy to clipboard operation
image copied to clipboard

JFIF File sometimes throws error

Open JeroenBoesten opened this issue 6 years ago • 2 comments

Hello,

When using jfif image as a source to manipulate using Intervention it's not unambiguous in whether an error is thrown or not.

The encoder does not support jfif mime type but it seems like sometimes it recognizes the image as a jpeg and it that case it does the manipulation without errors. But sometimes it doesn't recognizes it as jpeg and then the expected behaviour of throwing the NotSupportedException occurs.

I'm unable to pinpoint the reason why or how this random behaviour happens.

Thanks in advance!

JeroenBoesten avatar Nov 25 '19 10:11 JeroenBoesten

In my case, I am having this issue on an email template builder plugin which is using this library to resize the image. But unfortunately, it doesn't recognize the jfif mime type which is basically a JPEG file interchange format as per which I edited the AbstractEncoder file exactly here as

....
            case 'jpg':
            case 'jpeg':
        .   case 'jfif':
            case 'image/jpg':
            case 'image/jpeg':
            case 'image/pjpeg':
           case 'image/jfif':
                $this->result = $this->processJpeg();
                break;
...

and it worked for me :) Hope this helps

monishdeb avatar Oct 06 '20 12:10 monishdeb

I just created a PR with your fix :)

https://github.com/Intervention/image/pull/1081

squiaios avatar Apr 13 '21 09:04 squiaios