selective-php / image-type

Image type (format) detection for PHP
MIT License
7 stars 4 forks source link

Throw exception when it's unrecognized image #2

Closed peter279k closed 5 years ago

peter279k commented 5 years ago

I found that ImageTypeDetector class will return null if the image cannot be recognized.

I think we throw exception and message is Unrecognized image file: /path/to/image/file.

This can let users know that image is invalid or broken.

And it can also let us know whether image is recognized correctly.

odan commented 5 years ago

The method getImageTypeFromFile already throws an ImageTypeException exception. But I renamed it to ImageTypeDetectorException.

peter279k commented 5 years ago

@odan, thanks.

I've noticed that it will throw ImageTypeException if the $type is null in parseType method.

Thank you for your explanation.