ImageScaleToFit Bug

I just ran into an interesting imageScaleToFit bug. I was writing some code to handle scaling an uploaded image when I got this error:

For gray scale images the interpolation argument must be one of: NEAREST | BILINEAR | BICUBIC | HIGHESTQUALITY | HIGHQUALITY | MEDIUMQUALITY | HIGHESTPERFORMANCE | HIGHPERFORMANCE | MEDIUMPERFORMANCE

According to the docs, the default interpolation is highestQuality so I don't quite get what CF is thinking I'm using. Specifying the interpolation made the error go away of course and then works just fine for grayscale or non-grayscale images. (I filed a bug report for this already.)

Archived Comments

Comment 1 by James Edmunds posted on 10/25/2007 at 7:00 PM

Ray, I filed a bug report on this a couple of days ago, and I also added comments about it in the LiveDocs.

Note also that when you specify the interpolation, you must use the relative descriptors (as detailed in the error message you cited) like "highestQuality" rather than the algorithm descriptor like "lanczos," etc. (This is also noted in the Live Docs comment I had added.)

That all being said, what an extraordinarily useful tag!

Comment 2 by Raymond Camden posted on 10/25/2007 at 7:04 PM

Hmpth. I thought cfquickdocs used to show livedocs comments. I glanced quickly and didn't see it so I didn't bother to check the real site.

Comment 3 by Mat Evans posted on 10/25/2007 at 7:32 PM

I too have seen this happen, only a couple of days ago. Didn't really have time to investigate it a lot, but it was very random. It happened on an image I have been manipulating for thumbs etc, but it only happened once out of many processes.

Mat

Comment 4 by Rupesh kumar posted on 10/25/2007 at 10:28 PM

You will get this error only when the image is an 8-bit gray image. For scaleToFit, unless specified, we always try to use lanczos algorithm, as it provides the best quality but that bombs for 8-bit gray image because of a bug in Java. The only workaround is, as you said, always use the function that takes algorithm name and set the algorithm name as 'bestquality'.

Comment 5 by Raymond Camden posted on 10/25/2007 at 10:32 PM

Rupesh: So 1) this is a doc bug, agreed? 2) I can see why you would use the 'best' by default, but it seems like it would be better to use the algorithm that works for more images. Ie, pick the one that covers the most images and has the best quality. That's just my opinion though. Do I need to file another bug for the doc issue?

Comment 6 by Rupesh kumar posted on 10/25/2007 at 10:38 PM

I did not say it is not a bug :)
We take care of it for 'resize' but some how we missed scaleToFit. We will fix that.
I don't think we need a doc bug for this.

Comment 7 by Raymond Camden posted on 10/25/2007 at 10:42 PM

How is it not a doc bug though? THe docs say the default is highestquality, not lanczos. If they mean the same thing - that is fine - but the docs should still say lanczos.

Comment 8 by John Cranston posted on 8/30/2008 at 7:26 AM

Is there a hotfix to this yet? I just got the error message:

For gray scale images the interpolation argument must be one of
NEAREST|BILINEAR|BICUBIC|HIGHESTQUALITY|HIGHQUALITY|MEDIUMQUALITY|HIGHESTPERFORMANCE|HIGHPERFORMANCE|MEDIUMPERFORMANCE

Comment 9 by Raymond Camden posted on 8/30/2008 at 6:14 PM

Don't know - if you are running the latest Cumulative Hot Fix and still see it, the answer would be no.