fast-image-size
fast-image-size copied to clipboard
Image size issue for images with wrong extension.
Hello. I've faced an issue when image size can't be obtained for images with wrong extension (for example jpeg image format with PNG extension). Yes, I know it is not normal to have image with wrong extension, but sometimes it happens.
I found this issue parsing "Lullabot\AMP" issue (laravel). It doesn't convert "img" tag to "amp-img" when image size is undefined. So I have a solution, but I think there could be better one.
So my simple solution is for class "FastImageSize", function "getImageSize" you can add this to end of else statement:
if(!(sizeof($this->size) > 1)) { $this->data = ''; $this->getImagesizeUnknownType($file); }
Thanks.