Forum

Thread tagged as: Question

Image cropping

My images aren't cropping.

I have set my image size in image.html and in post.html (see below)

I dont have gd or image magic installed - but I thought it would crop down without it?

Is there somewhere else it should be set?

I'm uploading the images in blog posting and they are coming in at 1110x800 etc so definitely not cropping.

NB I have tried following the video : Upload, crop and resize. The Perch documentation folder Template/Template Tag Attributes doesnt seem to contain Image(image upload attributes) any more?

post.html : <perch:if exists="image"> <img src="<perch:blog id="image" type="image" width="320" height="240" crop="true" label="Main Image" suppress="true"/>" alt="<perch:blog id="postTitle" suppress="true"/>" />

image.html <img src="<perch:content type="image" id="image" label="Image" width="320" height="240" crop="true" />" alt="<perch:content type="text" id="alt" label="Description" required="true" help="e.g. Photo of MD John Smith with his best wig on" title="true" />" />

cow shed

cow shed 0 points

  • 5 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

You need either GD or ImageMagick to do any cropping or other processing of images.

Where do I install those. On my server? Does Perch need them in a specific place?

Rachel Andrew

Rachel Andrew 394 points
Perch Support

They are part of the PHP install, so you would need to ask your host.

Thanks - does it matter which one I use - and if I get one added do I need to tell Perch which one I have used, or will it just know?

Rachel Andrew

Rachel Andrew 394 points
Perch Support

You don't need to tell Perch anything, and no it doesn't matter. Once it is installed you will be able to see by loading your Diagnostics Report that it is available.

If you need any further help remember we need your Diagnostics Report with every post to the forum.

I checked with my hosting co and GD is installed (I then checked my diagnostics report which shows it too).

What should I do to make the image crop work? Is it image.php or post.php I should be adding the crop sizes to? I thought it used to be image.php but this is in the content not blog section so I guess it must be the post.php. The code I have in post.php is :

<perch:if exists="image">
<img src="<perch:content id="image" type="image" width="320" height="240" crop="true"  label="Main Image" suppress="true"/>" alt="<perch:blog id="postTitle" suppress="true"/>"   />
</perch:if>
<perch:if exists="image2">
<img src="<perch:content id="image2" type="image" width="100" height="62" crop="true" label="Image 2" suppress="true"/>" alt="<perch:blog id="postTitle" suppress="true"/>"  />
</perch:if>
SUMMARY INFORMATION

Perch: 2.8.29, PHP: 5.6.3, MySQL: 5.5.40, with PDO
Server OS: Linux, apache2handler
Installed apps: content (2.8.29), assets (2.8.29), categories (2.8.29), perch_blog (5.0), perch_forms (1.8.3), perch_gallery (2.8.6), perch_backup (1.2)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_blog', 'perch_gallery', 'perch_forms', );
PERCH_LOGINPATH: /perch
PERCH_PATH: /home/plant/ukplantgroup.co.uk/htdocs/perch
PERCH_CORE: /home/plant/ukplantgroup.co.uk/htdocs/perch/core
PERCH_RESFILEPATH: /home/plant/ukplantgroup.co.uk/htdocs/perch/resources
Image manipulation: GD
PHP limits: Max upload 100M, Max POST 100M, Memory: 128M, Total max file upload: 100M
F1: 2edba60ed1f613d6dd804feb202456a2
Resource folder writeable: Yes
HTTP_HOST: www.ukplantgroup.co.uk
DOCUMENT_ROOT: /home/plant/ukplantgroup.co.uk/htdocs
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
Drew McLellan

Drew McLellan 2638 points
Perch Support

You've got a mixture of perch:content and perch:blog tags in your template. Which app is this template for? They should all be one or the other.

Ah yes - I was trying every permutation. Its a blog thing - I just tried content in there because of the image.html which seems to only be for content? Anyway, I've put it all back to blog now.

Its still not resizing the first image (but the second is ok). I can probably get round it by renaming image - but where is image getting set? Is it in image.html? or in post.php?

Thanks

Rachel Andrew

Rachel Andrew 394 points
Perch Support

post.html is the Master template.

It needs to contain all versions of the image you want, in each size. You can then reuse them in other templates.

This is my post.html (I mistyped it as post.php). It's huge because there are so many images!! The first Image is defined in here (as 320x240 - it's near the top) but the first image isn't getting cropped. I assumed image was also set somewhere else.

Rachel Andrew

Rachel Andrew 394 points
Perch Support

What I would do in that situation is to debug the issue by removing all of the images except one, checking that works and then adding things back in one at a time until you discover which element causes the issue.

You need to take a step by step methodical approach to finding where the issue is, as the likely issue is a problem with your template.

Rachel Andrew

Rachel Andrew 394 points
Perch Support

There is a good article here on creating a reduced test case https://css-tricks.com/reduced-test-cases/

This is essentially what you need to do when something isn't working correctly whether it is front-end code or a Perch template.

Thanks I will try that

Turned out I needed to refer to the cropped size wherever I refered to the image (I thought it cropped it when the resource was added and was then always the cropped size)

ie <img src="<perch:blog id="image10" type="image" width="780" height="490" crop="true" />" />

rather than <img src="<perch:blog id="image10" type="image" class="img-responsive" />" />

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, that's correct.