Forum

Thread tagged as: Problem

Image crop won't work properly

While testing today with my customer I found a image crop error. Have I done something wrong? This example was a portrait photo, landscape works just fine.

This is my code

<perch:content id="Image" type="image" quality="45" crop="true" width="1000" height="600" output="tag"/>

And this is what i got: [https://bildr.no/image/U3BBRFg2.jpeg]

Erick Green

Erick Green 0 points

  • 6 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

The height and width both need to be larger than the size you dictate if you want it to crop.

How large do they both have to be?

Rachel Andrew

Rachel Andrew 394 points
Perch Support

Larger than the size you set in your template. We don't upscale images.

It is. But as you can see it crops the height correct but not the width. The original image is 2125 x 3000px. This seems to happen very randomly. Some portrait photos crop to 1000 x 600, others dont.

Drew McLellan

Drew McLellan 2638 points
Perch Support

When you say randomly, do you mean the same source image will crop different ways without a pattern?

No its not the same source image, its different pictures. Seems like its a problem with some landscapes photos as well, got this screenshot from my customer: https://bildr.no/image/TWhLVTd1.jpeg

I use the output tag for images, could that be the reason instead of place the perch content code inside img src? First time working with Perch so not sure how to debug this.

Drew McLellan

Drew McLellan 2638 points
Perch Support

The crop only crops one dimension. It scales the shorter edge and then crops the longer.