Possible Duplicate:
Why should I resize an image in Coldfusion if the file size doen't decrease and the quality of the image suffers?
I must be doing something wrong here... using Coldfuison8
I have a product search which is pulling in images from external servers, so I need to set images on runtime.
Say I have a jpg 500x500px 111kb, which I'm grabbing from the external server.
Right now I'm doing this:
<cfimage name="myImage" source="#bildpfad##bilddateiname#" action="read" />
<cfif IsImage(myImage) is true>
<cfscript>
ImageSetAntialiasing(myImage,"on");
variables.breite = 400;
ImageScaleToFit(myImage, variables.breite,"", "highestPerformance");
</cfscript>
<cfxml variable="imageXml">
<cfimage action="writetobrowser" source="#myImage#" />
</cfxml>
<cfoutput><div class="resultsImgWrap">#imageXml#</div></cfoutput>
This displays the image allright, but when I check the filesize, I have
400x400px 111.2kB
If I use IrfanView for example and just reduce the filesize and save the image, I'm already at 65kb.
Question: How can I make CFIMAGE reduce the file size if I'm resizing the image? If the size stays at 111kb, why use CFIMAGE at all and not simply add the image as plain HTML.
**EDIT'':
The variables Bildpfad and Bilddateiname will be something like:
bildpfad (path to image): http://www.some-server.com/images/
bilddateiname (filename): some_image123.jpg
Specify the quality
attribute in <cfimage>
. I'm not sure if it works with action="writeToBrowser"
, but it should. Otherwise, file a bug report.
Resize and Compression are different things. :)
UPDATE
Good news, there's an undocumented way to get it working! See: http://www.bennadel.com/blog/2405-Using-The-Quality-Attribute-With-The-CFImage-WriteToBrowser-Action.htm
<!--- Write out as a JPG at 20% (using "quality" attribute). --->
<cfimage
action="writeToBrowser"
source="#png#"
format="jpg"
quality=".2"
/>