0

I am working on watermarking an image and am having a problem with my code. It does create a watermark in the bottom right side corner, but the text is not written.

Can anyone spot what is wrong with the code?

<cfset objImage = ImageRead("#UploadDir2#\#uploadfile#") />
<cfset objImage2 = ImageRead("#UploadDir2#\#uploadfile#") />
<cfset ImageResize(objImage,800,"")>
<cfif form.textonImage NEQ "">
     <cfset objWatermark = ImageNew("",20,20,"rgb","##F0F0F0")/>
     <cfset ImageSetDrawingColor(objWatermark,"##000000") />
     <cfset ImageDrawRect(objWatermark,0,0,(objWatermark.GetWidth() - 1),(objWatermark.GetHeight() - 1)) />
     <cfset ImageSetAntialiasing(objWatermark,"on") />
     <cfset objAttributes = {Font = "Verdana",Size = "8",Style = "bold"} />
     <cfset ImageDrawText(objWatermark,"#form.textonImage#",11,40,objAttributes) />
     <cfset ImageSetDrawingTransparency(objImage,60) />
     <cfset ImagePaste(objImage,objWatermark,(objImage.GetWidth() - objWatermark.GetWidth() - 0),(objImage.GetHeight() - objWatermark.GetHeight() - 0)) />
</cfif>   

<cfset ImageWrite(objImage,"#UploadDir2#\#uploadfile#")>            
<cfset ImageResize(objImage2,#request.pic_th_width#,"")>
<cfif form.textonImage IS NOT "">
    <cfset objWatermark = ImageNew("",#request.pic_th_width#,#request.pic_th_width#,"rgb","##F0F0F0")/>
    <cfset ImageSetDrawingColor(objWatermark,"##000000") />
    <cfset ImageDrawRect(objWatermark,0,0,(objWatermark.GetWidth() - 0),(objWatermark.GetHeight() - 0)) />
    <cfset ImageSetAntialiasing(objWatermark,"on") />
    <cfset objAttributes = {Font = "Verdana",Size = "20",Style = "bold"} />
    <cfset ImageDrawText(objWatermark,"#form.textonImage#",11,40,objAttributes) />
    <cfset ImageSetDrawingTransparency(objImage2,60) />
    <cfset ImagePaste(objImage2,objWatermark,(objImage2.GetWidth() - objWatermark.GetWidth() - 0),(objImage2.GetHeight() - objWatermark.GetHeight() - 0)) />
</cfif>

EDIT:

I answered my own question, so let's delete it or ignore it.

Leigh
  • 28,765
  • 10
  • 55
  • 103
  • 3
    If you add your solution as an answer that would help anyone else with the same problem in the future, and others could suggest potential improvements. It is acceptable to answer your own questions on StackOverflow. – Antony Mar 31 '13 at 09:32
  • i will post the code soon – Gurpreet Singh May 02 '13 at 06:24

0 Answers0