Jozsef Posted October 16 Share Posted October 16 The site is displaying a list of full body portraits that I'd like to crop with a focus on the face/shoulders. No focus has been set on the images and it's hundreds of them so I want a sensible default. This is the code below but it still crops from the top of the image, or the actual center (50%,50%). Is it a bug or I'm doing something wrong? $image = $gallery_page->images->first()->size(540,404,array("cropping" => array('50%','35%'), "quality" => 80))->webp->url; It's based on the latest API reference I've found: https://processwire.com/api/ref/pageimage/size/ It's very late but is it something I can't spot here? Should it work? Link to comment Share on other sites More sharing options...
Sanyaissues Posted October 16 Share Posted October 16 $image = $gallery_page->images->first()->size(540, 404, [ "cropping" => ['50%', '35%'], "quality" => 80, "focus" => false ])->webp->url; Maybe it is auto detecting a focus presset. Try disabling it. 1 Link to comment Share on other sites More sharing options...
Jozsef Posted October 17 Author Share Posted October 17 Thanks, it is not the problem, it would be cropped from the centre then. Interestingly, if the focus point is not set the images are cropped from North, not centre. No matter what I tried, it doesn't work with percentages in the size options. I ended up setting the focus position for the image and it achieved the results. if (!$image->hasFocus) $image->focus(35,50); $resized = $image->size($w,$h)->webp->url; Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now