Skip to content
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

Implemented extra functionality for specifying fit direction #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

theRoughCode
Copy link

Currently, there is no flexibility in the way Image fit is done. The decoded image is centred around the middle of the original image by default. This PR implements 4 additional ImageOpsSizeMethods: ImageOpsFitTopLeft, ImageOpsFitTopRight, ImageOpsFitBottomLeft, ImageOpsFitBottomRight. These gives the user more flexibility on how they want to align their image respective to the original image. The reason why there aren't more options like ImageOpsFitTopMiddle is because the cropping only happens in one direction, never in both the X and y axis. So, ImageOpsFitTopLeft and ImageOpsFitTopRight will accomplish the same thing if done in a scenario where the height is cropped (i.e. aligned to top half).

I've also updated the README to reflect these changes and give readers a better idea of how to resize their images.

@majuansari
Copy link

This looks like a very good option . Can we merge this ?

@theRoughCode Is there anyway i can use this feature by extending the package ?

@theRoughCode
Copy link
Author

@majuansari I would ask @brian-armstrong-discord as he's the code owner of this repository! :)

@rroller
Copy link

rroller commented Dec 18, 2018

I also have a use case for this. Would be nice to have this merged in.

@@ -193,12 +197,28 @@ func (f *Framebuffer) Fit(width, height int, dst *Framebuffer) error {
}

var left, top int
left = int(float64(f.width-widthPostCrop) * 0.5)
switch fitDir {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option would be to allow the top/left to be specified. Then we can crop around any given x/y we want.

@brian-armstrong-discord
Copy link
Contributor

brian-armstrong-discord commented Feb 5, 2019

Hey @theRoughCode Sorry for the radio silence on my end. This does actually look interesting, would you mind cleaning up the recent conflicts with master?
Thank you!

@brian-armstrong-discord
Copy link
Contributor

As far as how the options should work, I tried to mirror PIL since that's what inspired this project, so I would say let's do what PIL does for these sorts of ops.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants