New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only process fixOrientation if the image is jpg/tiff #109
Conversation
Other image formats do not support exif and running fixOrientation() on a PNG image generates an error to the image.
@@ -95,6 +95,10 @@ public function cropResize($width = null, $height = null, $background = 'transpa | |||
*/ | |||
public function fixOrientation() | |||
{ | |||
if (!in_array(exif_imagetype($this->source->getInfos()), array(IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM))) { | |||
return $this; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to throw an unsupported image type exception IMO.
@Gregwar what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm against raising an exception because in my use case I get a list of image manipulation actions in a row, and then execute them all regardless of the file type (I don't know it yet when adding the actions), so returning $this
and continuing execution for me is essential.
I'm surprised PNG image does not support this. What is the error? |
Sample image: Sample code: Image::open('/PATH/6f2a945e-a96f-11e5-977e-facec0c54287.png')
->fixOrientation()
->save('/PATH/out.jpg'); try with the current Image code, and with my PR. You'll see that without the PR, the image is never saved as I'm against raising an exception because in my use case I get a list of image manipulation actions in a row, and then execute them all regardless of the file type (I don't know it yet when adding the actions), so returning |
I'm also against raising an exception. The PR is legit and should be merged! |
This is a receivable argument. But I'm not sure of the best method between silent the method on the library or catch the concerned exception on the project code. @Gregwar what do you think? |
Actually, I don't think this should be an exception since this is not really an error, I mean the fact that calling |
What about a paramater? $abort_on_error with defaul value set to false? |
Any movement on this PR? Would be great to see this merged. Thanks! |
This Issue just hit me down the road while building a webpage in @getgrav. In my oppininion calling a fix* method on something that doesn't need fixing (because its a png without orientation information) shouldn't fail. |
Thanks for contributing |
(And sorry for the delays) |
Other image formats do not support exif and running fixOrientation() on a PNG image generates an error to the image.