我正在为图像添加水印并且我的代码有问题。它确实在右下角创建了一个水印,但没有写入文本。
谁能发现代码有什么问题?
<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>
编辑:
我回答了我自己的问题,所以让我们删除它或忽略它。