Understanding Crop positioning and size

I have a Image with the dimensions of 1024x768, when using the crop() method on it with a specified width, height and crop position, but the result is not what I would expect the result to be.

Code:
echo $imageField()->toFile()->crop(150, 150, 'top right');
Produces:

Code:
echo $imageField()->toFile()->crop(150, 150, 'bottom right');
Produces:

So in both invocations, the same exact image.

Expected behaviour (red=top-right & blue=bottom-right):

If I set the position to a “bottom-left” position the crop position does change, but not as expected:

GD is enabled aswell as the file format is supported.
Imagick is enabled aswell as the file format is supported.
Kirby Version is 4.7.1

I have tried using both im (with specified binary paths)/gd as a driver in the config.

Am I missing something, or misunderstanding the crop() method?
If so, what would be the best way to go about achieving my wished for result?

The image is scaled beforehand so that it covers the crop size in both directions, regardless of whether you use “top right” or “top bottom.” With this setting, only the excess area on the left is cropped.
If you need a true pixel-based crop without scaling (e.g., x=100, y=50, width=150, height=150), you must use your own ImageKit plugin.

1 Like

Alright, thanks for the answer.

I honestly find the Kirby v4 focal point feature to be quite misleading then, since you cant really set a image section to display from the get-go, either way thanks for the info.

There is a plugin for Kirby 3.
I don’t know if it works with K4 :thinking:

Doesnt seem to work, but either way, I try to steer clear of installing plugins since you never know how mantained they are.

Im mostly a bit frustrated because I thought the focal point feature was going to help me in my use case, but in order to make use of it I guess ill have to write a bit of logic around it.

But thanks again for helping me out here.

I agree with you. Once you find a great plug-in, development suddenly comes to a standstill. Bugs aren’t fixed. And after a few Kirby updates, it no longer works. I also feel better using as few plug-ins as possible. Or programming special solutions myself. That also increases the learning factor.

1 Like

If you have ImageMagick available (note: NOT the PHP extension imagick), then you could write your own thumb driver with a method to extract a portion of an image (magick -extract)

1 Like

Sound good, will propably do so - Thanks for the Tip.