-
Notifications
You must be signed in to change notification settings - Fork 346
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
AutoOrient to automatically fix orientation of images based on EXIF orientation flag #140
Conversation
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.
Please, take a look to my comments.
options.Flip = true | ||
break | ||
case 3: | ||
options.Rotate = 180 |
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.
You might consider using bimg.Angle
here. See:
https://github.com/h2non/bimg/blob/master/options.go#L57-L74
@@ -155,6 +157,52 @@ func (i *Image) Flop() ([]byte, error) { | |||
return i.Process(options) | |||
} | |||
|
|||
// AutoOrient automatically flips/flops/rotates the image | |||
// based on EXIF Orientation | |||
func (i *Image) AutoOrient() ([]byte, error) { |
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.
Note that this capability aims to be implemented here:
https://github.com/h2non/bimg/blob/master/resize.go#L501-L537
I think this would be redundant. Perhaps makes more sense to merge code into the existent code.
@h2non Thanks for the feedback, didn't see this func because its not exported. Agreed there may be some redundancy here, but would it not make sense for this feature to behave in the same way the other "convenience" methods? Is your suggestion that there be an -Leo |
The intended default behavior is to process images with auto orientation, unless you explicitly want to disable that behavior via: I agree about exposing that capability as part of the public API. |
In which case, would an My my use case, I need to have the image correctly oriented for later processing, including being able to get the dimensions with that orientation applied. |
This should be already fixed by #183. Feature is now available in |
This PR adds a new func to the bimg.Image type
AutoOrient
which will perform the required processes to correct the orientation of the image based on the EXIF orientation flag.