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

Use cover method from Intervention #419

Open
wants to merge 7 commits into
base: 3.x
Choose a base branch
from

Conversation

deluxetom
Copy link

@deluxetom deluxetom commented Jan 2, 2025

Intervention v3 has a cover method that works as intended for the fit=crop parameter.
https://image.intervention.io/v3/modifying/resizing#cropping--resizing-combined

@deluxetom deluxetom changed the title Use cover method from Intervention Use cover method from Intervention Jan 2, 2025
@deluxetom deluxetom changed the title Use cover method from Intervention #420 - Use cover method from Intervention Jan 6, 2025
@deluxetom deluxetom changed the title #420 - Use cover method from Intervention Use cover method from Intervention Jan 6, 2025
@deluxetom
Copy link
Author

@ADmad I've been using this update with a project already, the documentation for glide could also be updated to add fit=cover

@ADmad
Copy link
Collaborator

ADmad commented Jan 6, 2025

the documentation for glide could also be updated to add fit=cover

Sounds good to me, would you like to take care of that?

@deluxetom
Copy link
Author

the documentation for glide could also be updated to add fit=cover

Sounds good to me, would you like to take care of that?

I think I can get started on the 3.0 docs, it looks like its not done yet

@ADmad
Copy link
Collaborator

ADmad commented Jan 6, 2025

Docs for 3.0 already exist and should be up to date unless I missed something https://github.com/thephpleague/glide/tree/3.x/docs/3.0

@deluxetom
Copy link
Author

Docs for 3.0 already exist and should be up to date unless I missed something https://github.com/thephpleague/glide/tree/3.x/docs/3.0

my bad, I was looking at the master branch :) I'll update the docs for the fit parameter

@deluxetom
Copy link
Author

@ADmad this is ready for review


In addition to the crop position, you can be more specific about the exact crop position using a focal point. This is defined using two offset percentages: `crop-x%-y%`.

~~~ html
<img src="kayaks.jpg?w=300&h=300&fit=crop-25-75">
<img src="kayaks.jpg?w=300&h=300&fit=cover-25-75">
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this be crop-25-75. For numeric values for position we use runCropReize() right?

- `fill`: Resizes the image to fit within the width and height boundaries without cropping or distorting the image, and the remaining space is filled with the background color. The resulting image will match the constraining dimensions.
- `fill-max`: Resizes the image to fit within the width and height boundaries without cropping but upscaling the image if it's smaller. The finished image will have remaining space on either width or height (except if the aspect ratio of the new image is the same as the old image). The remaining space will be filled with the background color. The resulting image will match the constraining dimensions.
- `stretch`: Stretches the image to fit the constraining dimensions exactly. The resulting image will fill the dimensions, and will not maintain the aspect ratio of the input image.
- `crop`: Resizes the image to fill the width and height boundaries and crops any excess image data. The resulting image will match the width and height constraints without distorting the image. See the [crop](api/crop/) page for more information.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should keep the crop option stating it's an alias for cover.

@ADmad
Copy link
Collaborator

ADmad commented Jan 7, 2025

Just to confirm using fit=crop or fit=crop-<string>-<string> would still work right? Internally runCoverResize() would be used.

runCropReize() would be used only fit=crop-<numeric>-<numeric> is used, right?

@deluxetom
Copy link
Author

Just to confirm using fit=crop or fit=crop-<string>-<string> would still work right? Internally runCoverResize() would be used.

runCropReize() would be used only fit=crop-<numeric>-<numeric> is used, right?

that's correct, crop and crop-$position will use runCoverResize() now, they're aliases of cover and cover-position.
crop-<numeric>-<numeric> remains the same

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.

2 participants