rosell-dk / webp-convert

Convert jpeg/png to webp with PHP (if at all possible)
MIT License
576 stars 101 forks source link

Serve original file even if it is not a JPG/PNG #327

Closed jherry closed 2 years ago

jherry commented 2 years ago

I got a case where the original/source file was already in webp format, it throws an error which is correct but there was an error serving the original file because it is not a JPG or PNG. I think we can serve the orinigal as long as it is an image. I don't know if I fixed it the way it should but at least it's a solution. Thank you for this great library anyway!

rosell-dk commented 2 years ago

Actually, we do not need this line:

InputValidator::checkMimeType($source, ['image/jpeg','image/png','image/webp','image/gif']);

as MimeType::getMimeTypeDetectionResult($source); detects if it is a known image type (it returns false if it is not an image type)

I shall do the correction