Image Resize Bug

19 March 2010 22:37 (EST)
It looks like ColdFusion (version 8.0.1 at least) has a problem resizing images with certain aspect ratio. Look at the code below:

<cfset img = ImageNew("",336,448) />
<cfset ImageResize(img,150,"") />
<cfoutput>#img.width#px</cfoutput>

What should is display? 150px? Nope, it shows 149px. Any ideas how to fix this?

Discussion (2 comments)

JediHomer JediHomer: 19 March 2010 23:53 (EST)

I *think* you do something like

<cfset ImageResize(img,150.1,"") />

It's a slight 1 off error somewhere to do with rounding...

Dmitry Yakhnov Dmitry Yakhnov: 21 March 2010 10:48 (EST)

Your solution seems to be working, thanks a lot!

Add your comment
*
*
*
*
*

Captcha Code Please enter the number on the left.
Sorry for asking you to do so.
Reload image