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

Crop Area with focus point #1241

Open
Suranex opened this issue Jan 30, 2024 · 5 comments
Open

Crop Area with focus point #1241

Suranex opened this issue Jan 30, 2024 · 5 comments

Comments

@Suranex
Copy link

Suranex commented Jan 30, 2024

Hello,

I am trying to combine the crop area of #551 (comment) with a focus point. The crop itself can handle gravity values like ce and nowe, but for the focus point, more parameters are required. When I combine crop and gravity, the gravity seems to be ignored and only used by the crop parameter.

.../crop:399.36:399.0053285968:ce:880.64:93.35701598579/gravity:fp:0.0007390625:0.00030836787053483/...

No matter what values gravity:fp takes, the gravity of the crop is used.

I hope you can help me with this problem.

Greetings

@DarthSim
Copy link
Member

Hey @Suranex!

crop uses the gravity option value only when its own gravity argument is not specified. Actually, I can't understand what you're trying to achieve by using two gravities. Could you elaborate?

@Suranex
Copy link
Author

Suranex commented Jan 31, 2024

i don't want to use two gravities, but currently i have to set it to the crop option to use the 4th and 5th crop argument. And exactly here is my problem. i want to use the focus point argument as gravity, which i can only pass to the gravity option.

@DarthSim
Copy link
Member

Why do you need the 4th and 5th crop arguments if you're going to use the fp gravity? Offsets can't be set for the fp gravity.

@Suranex
Copy link
Author

Suranex commented Feb 1, 2024

Background to my question: I am trying to replace TYPO3's internal image rendering. I want to do this because TYPO3 creates the images on the current page request and not sluggishly when the image is needed. In TYPO3 you can set a crop area and a focus area.

image

I have replaced the focus area by calculating the centre point for it und use the focus point. But for cropping the crop area is needed, for which I need the 4th and 5th parameter of /crop.

I hope it is now understandable what my use case is 🙈

@DarthSim
Copy link
Member

DarthSim commented Feb 1, 2024

Ok, I guess now I get it. I'm absolutely not familiar with TYPO3, but from what I've read on the internet, you're doing almost everything right. Correct me if I'm wrong:

  1. The crop area is the area that is cropped no matter what. In other words, you don't want to use the parts of the image that are outside of the crop area. That's exactly what the crop option does, but you're using it a little bit wrong. You should use the nowe gravity type with offsets given to you by TYPO3. By the way, both crop size and offsets can be set as relative values (0.0 - 1.0 range).

  2. The focus area is the area you want to keep when you resize the image to fill the provided size and you need to cut off some of its parts. This is what the gravity option is meant for. You're using it right, but I'm not sure if TYPO3 gives you coordinates relative to the crop area or the whole area of the image. if it gives you coordinates relative to the whole area of the image, you need to make a little bit more calculations to translate the coordinates to the crop area space. Basically: (focus_point_x - crop_area_left) * image_width / crop_area_width. Same for the vertical coordinate.

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

No branches or pull requests

2 participants