I was playing with image rotation last night (I know, call me Mr. Excitement), and I found an interesting issue. Consider this code:
<cfset textImage=ImageNew("",200,200,"rgb","white")>
<cfset ImageSetDrawingColor(textImage,"black")>
<cfset attr=StructNew()>
<cfset attr.size=30>
<cfset attr.style="bold">
<cfset attr.font="ArialMT">
<cfset ImageSetAntialiasing(textImage, "on")>
<cfset ImageDrawText(textImage,"Paris",50,75,attr)>
<cfset ImageRotate(textImage,30,2,2)>
<cfimage action="writeToBrowser" source="#textImage#">
I create a new blank image and then draw some black text and then rotate. I end up with this:
Notice the black background? I tried to fix it by using this for my image:
<cfset textImage=ImageNew("",200,200,"rgb","white")>
But it had no impact. Luckily I got some help from Adobe (thank you Hemant!) and he mentioned that if I switch my image type to ARGB instead of RGB, it will work. With that, I got this:
Not bad - but a bit ugly. The imageRotate function takes a 5th argument: interpolation. This basically sets the quality of the rotation. Adobe defaulted to the quickest method, "nearest." Switching to the highest, "bicubic", makes a real pretty rotation, but the leaves some "crud" on the sides:
Of course, I could crop that easily enough, but, still, a bit of a problem. The middle ground interpolation, bilinear, also leaves the same.