Perch not compressing images that are not resized

  • I can only assume this is intended behaviour but I've found that if I upload an image that does NOT need to be resized, Perch seemingly will NOT compress the image when generating a version of it.

    e.g. if I upload a file at 4000px by 1460px, and I have the Perch image tag as `<perch:content id="image" type="image" width="4000" height="1460" crop="true" quality="60" />`, Perch will simply copy and rename the image so I'll have two files that are exactly the same size:

    - some-image-w4000h1460.png (same size as `some-image.png`)

    - some-image.png

    What I would expect to happen is that Perch would compress the image while copying it, as per the quality="60" setting, so that `some-image-w4000h1460.png` would be a smaller size than `some-image.png`

    If clients upload an image at the correct size I'd like Perch to compress the image.

    Is this an oversight by any chance?

  • Jay, I would suggest the following. Notice the addition of Quality which reduces the size and quality of the image and density and sharpen help the image still look good at a smaller size and on Retina displays. Everything I learned regarding compressing images in Perch came from this tutorial.…lates/compressive-images/

    I hope this helps.

    1. <img src="<perch:content type="image" id="image" label="Image" help="Upload or select an image" bucket="pagePics" width="1200" density="2" quality="30" sharpen="2" />" alt="<perch:content type="text" id="alt" label="Description" required="true" help="Description of this image" />" />
  • Sorry about that, but I have not run into that issue, even while uploading the file at the correct size. You might also consider using the Tinify app

    It will either compress images on upload or you can set a cron job (I highly recommend the cron job). This would allow that program to compress the image after the upload if the system is doing something quirky. Also Tinify gives you a much larger amount of free uses per month.

  • The quality is only used when resizing a file, because that's the only time the image gets recompressed. We don't recompress images that aren't being resized, as in most cases that would result in an unintentional quality loss. A side effect of this is we don't currently have an option for intentional quality loss.

  • Hmmm ok, most of the time I _do_ want a compressed version though since I can never rely on clients to do so.

    Good to know what I'm dealing with though—thanks.

    Someone in the Slack group suggested that I set the resize dimensions slightly off e.g. '395' rather than '400' to reduce the chances of the client uploading the correct image size.

    I'll use this tip together with an image compression library like Matt suggested.