Filesize of images with cfimage

Hi,

Following the migration from Adobe Coldfusion to Lucee, we have just noticed that the weight of the images that we create with cfimage resize remain rather high, much more than before. From memory we used imageCR3. On Lucee, for example, resizing a jpg image so that it is 140 pixels by 140 pixels, regardless of whether I set the quality attribute to 0.10 or 0.75, the weight remains around 750 kb. It seems huge for such a small jpg image.

What is fascinating is that changing the quality of 75% to 10%, it barely reduces the file size (ex: 758 KB to 755 KB), but the image quality is reduced drastically. We see large pixels.

I read this thread, but it’s from 2015. It was discussed to remove Lucee’s core image processing to an extension and it was done.

My question is: Is it known that Lucee’s cfimage tag does not compress images well and the weight is high even today?

Thank you for your support!

OS: Windows Server 2016 (10.0) 64bit
Java Version: 1.8.0_181 (Oracle Corporation) 64bit
Tomcat Version: Apache Tomcat/8.5.33
Lucee Version: Lucee 5.3.8.206

Tony, before moving from ACF had you been using the interpolation attribute of cfimage to help control that size/quality? I can’t tell from cfdocs.org if lucee supports that specific attribute/argument. If not, it might even ignore it, if you did have it.

But if it supports it, and you’re not using it, check out if it may help. The default is highestquality, and lowering it can dramatically improve performance and yet not necessarily reduce quality, as I discussed in a post here (gosh, 10 yrs ago, but still holding true for ACF):

My focus there was indeed performance rather than resulting size, but it may still help you.

Hi,

I didn’t use the interpolation attribute on cfimage before. I used imageCR3 and cfimage with just the quality attribute. I saw the attribute interpolation in the documentation, but it look it it doesn’t exists for <cfimage>.

I’ll try to use image.resize instead and come back to let you know.

Hi,

I tried this with differents values for the interpolation attribute, but the file size stay high (over 750 Kb for a 140 pixels by 140 pixels image).

<cfset myImage=imageNew("original-image.jpg")>
<cfset imageResize(myImage,140,140,"mediumQuality")>
<cfset imageWrite(myImage,"resized-image.jpg")>

Am I doing something wrong?

Note : I took a look at the source code of Lucee’s image extension, and the interpolation attribute seems well and truly supported.

Tony,

In your last example, there’s no quality setting in imageWrite.

Hi,

You are right. I added the attribute quality with a value of 0.10. The image is ugly, and the file size still very high. I’m starting to feel there is something wrong with the batch of images I’m trying. I asked the client to send me the original files to figure it out. I’ll try again later with fresh new images.

Maybe color profile or exif data remaining? I tested and my 50KB went to 3KB.

1 Like

Well, do try it on cfimage. It may work and yet not be documented. I’m on a phone as I write, and cfimage is not supported at all on trycf.com. Or sure, try the script alternative (which is why I’d mentioned it being an attribute or an argument).

Let us know how both go.

Hi,

You got it! I opened the file in Photoshop > File > File Info… > Raw Data and boom! Almost 900 Ko of data just there. I’m going to look a solution to remove the data on upload. It’s probably just with ImageWrite and noMetaData attribute. Will look into it tomorrow.

Thank you!

Hi,

Just by doing this, it’s clear the most part of the EXIF data like Blue TRC, Green TRC, Red TRC, and more :

<cfset myImage=imageNew("original-image.jpg")>
<cfset imageWrite(myImage,"new-image.jpg",1,true)>

and the file size becomes reasonable!

All the images files of the client have a lot of Raw Data. The client use a photoshop template to generate all the images and was not using the Save for Web function in Photoshop. So it keeps all the Raw Data on upload. It’s why all the batch of images had this problem. The Raw Data look like it :

<photoshop:DocumentAncestors>
            <rdf:Bag>
               <rdf:li>0030C5DF5FA7462F12E33009D39D63D1</rdf:li>
               <rdf:li>007592703D6E83A8F3FFA4404AD0087B</rdf:li>
               <rdf:li>00A0CFE9F94E621989919F6D2F395765</rdf:li>
               ........ + hundreds of rows

Thank you to all of you! Your help was very useful to me!