I've got this issue that is driving me batty.

 

I have a random rotating watermarked image as the masthead on my site. I
have all of the images that can be used in a single directory. I query that
directory to get the list of images then pick a random one to use.

 

Once I have the image, the fun begins.

 

I load that image into an object with imageRead(), then I load a small PNG
watermark into another object with imageRead() (ive tried imageRead() and
imagenew().

 

Then, with a basic imagepaste(), I put the watermark on the image and use
imageGetBlob() and cfcontent to display it. Sounds simple enough right?

 

So now I have a .cfm template that watermarks a random image on the fly and
serves it up. So in my style sheet, I just did something like:

 

#masthead {background: url(/images/masthead.cfm) no-repeat;}

 

 

There is an image in this article that shows an example of the bug I'm
getting with this process (and maybe any detail I've left out):

http://acoderslife.com/index.cfm/blog/Mast-head-image-bug

 

It is also the site with the masthead in question as well so you may very
well see the issue first hand with enough refreshing.

 

 

Here is the entire code for the image processing template:

 

<cfdirectory name="variables.mastImages" action="list"
directory="#expandPath('/images/mastimages/')#" filter="*.jpg" />

 

<cfset variables.mastImg = randRange(1,variables.mastImages.recordcount) />

 

<cfset variables.objImage = imageRead(expandPath('/images/mastimages/' &
variables.mastImages['name'][variables.mastImg])) />

 

<cfset variables.objWatermark =
imageNew(expandPath('/images/watermark.png')) />

 

<cfset imageSetAntialiasing(variables.objImage,"on") />

 

<cfset imageSetDrawingTransparency(variables.objImage,40) />

 

<cfset imagePaste(variables.objImage, variables.objWatermark,
(variables.objImage.getWidth() - (variables.objWatermark.getWidth() + 5)),
(variables.objImage.getHeight() - (variables.objWatermark.getHeight() + 5)))
/>

 

<cfcontent type="image/jpg" reset="true"
variable="#imageGetBlob(variables.objImage)#" />

 

If I remove the imagePaste() line, the image loads fine every time, but
then, I don't get the dynamic watermark that I'm rather partial to. 

 

 

A couple other things worth noting are

 - I only see the issue if I do a normal refresh (control+r) but if I do a
"hard" refresh (contorl+shift+r), I never see the issue.

- I never see the issue if I got to the template directly. It only happens
when it is in the layout through the CSS template.

 

Here is the URL directly to the image template:

http://acoderslife.com/images/masthead.cfm

 

You will notice some serious pixilation in some of the images. I've tried
lowering the image quality in order to make the file size smaller in hopes
that it might help. It did not.

 

Has anyone else run into this or have any ideas for a solution?  I like the
dynamic watermarking and would rather not put it in the images permanently
if I can avoid it.

 

Thanks for any input or assistance you can offer on this.

 

 

 





~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:334214
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to