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
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!
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.
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
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'.
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?
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.
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.
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
Don't know - if you are running the latest Cumulative Hot Fix and still see it, the answer would be no.