Reputation: 15581
I have a function which should resize all images in given folders (I don't know exactly how much, but I guess 2500+) and save them to a diffrent folder:
<CFSET base = expandpath("./images") />
<CFSET folders = listtoarray("folder1,folder2") />
<CFLOOP array="#folders#" index="folder">
<CFDIRECTORY name="qImages" directory="#base#/#folder#/big/" action="list" listinfo="name" type="file" filter="*.jpg" />
<CFLOOP query="qBilder">
<CFIMAGE action="resize" height="" width="320" source="#base#/#folder#/big/#name#" destination="#base#/#folder#/#name#" overwrite="yes" />
</CFLOOP>
</CFLOOP>
I wonder how to do this more efficient than I do?! I read that in CF there are 17 different algorithms for resizing images. Which would be the most performant one with a good mix of image quality and speed?
Upvotes: 1
Views: 1208
Reputation: 8314
Set your interpolation to "highestPerformance" for images <= 100x100 pixels and "highestQuality" or "lanczos" for the rest. If you are creating .jpgs the default quality is 0.75 which means 75%. For tiny images, drop this to 0.5 or less for quick low quality images.
If you want a proportional resize, provide imageResize() with a width or height, but not both.
http://cfquickdocs.com/cf9/#imageresize
Upvotes: 1
Reputation: 32905
You may test the performance of imageResize()
first. As jan said, play with the "interpolation parameter" to get your quality vs speed. If it is proven too slow / too ugly for you, use ImageMagik
Upvotes: 1