• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CFIMAGE CFLOOP Performance

Explorer ,
Aug 05, 2010 Aug 05, 2010

Copy link to clipboard

Copied

I have a site I am building that pulls large images from a folder based upon a recordset. I am using cfimage within a cfloop to go through the recordset, resize the images and add a watermark. I am experiencing performance problems. I was thinking that perhaps cfthread might be useful in this scenario, but I have not used that before. Anyone have thoughts on how to solve my performance issues?

FYI...here is my current cfloop/cfimage code for your reference.

<cfloop query="rsProofs">

<!--- Read in the original image. --->

    <cfset objImage = ImageRead( "./proof/#rsProofs.FILENAME#" ) />

    <!--- Read in the Stark Images watermark. --->

    <cfset objWatermark = ImageNew( "./images/logoMain.png" ) />

    <!---Resize main image--->

    <cfimage action = "resize" height = "10%" source = "#objImage#" width = "10%" overwrite = "no" name = "objImageresize">

    <!---Resize watermark image--->

    <cfimage action = "resize" height = "75%" source = "#objWatermark#" width = "75%" overwrite = "no" name = "objWatermarkresize">

    <!---Rotate watermark--->

    <cfimage action = "rotate" angle = "-35" source="#objWatermarkresize#" overwrite="no" name="objWatermarkrotate">

    <!---

        Turn on antialiasing on the existing image

        for the pasting to render nicely.

    --->

    <cfset ImageSetAntialiasing( objImageresize, "on" ) />

    <!---

        When we paste the watermark onto the photo, we don't

        want it to be fully visible. Therefore, let's set the

        drawing transparency to 50% before we paste.

    --->

    <cfset ImageSetDrawingTransparency( objImageresize, 60 ) />

    <!---

        Paste the watermark on to the image. We are going

        to paste this into the bottom, right corner.

    --->

    <cfset ImagePaste( objImageresize, objWatermarkrotate, 50, 0 ) />

<!--- Write it to the browser. --->

    <p><cfimage action="writetobrowser" source="#objImageresize#" /></p>

            <hr />

</cfloop>

Thanks,

Clay

TOPICS
Advanced techniques

Views

579

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Aug 05, 2010 Aug 05, 2010

Copy link to clipboard

Copied

Image manipulation tends to be resource/time intensive any way you look at it. Especially when there is a lot of it occurring, like within a loop. Do you really need to watermark on the fly, or this something that could be done only once?

On a side note, if you are reusing the same watermark each time you should resize / rotate it before you enter the loop. So you are only manipulating it once, not once for each loop.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 06, 2010 Aug 06, 2010

Copy link to clipboard

Copied

I pulled the watermark out. That was a good suggestion. Now...how would I go about looping through the query using threads and then rejoining them?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Aug 06, 2010 Aug 06, 2010

Copy link to clipboard

Copied

Without knowing much about the process, it is hard to say if cfthread will help or harm here. For things like single watermarks or thumbnails, it is often more efficient to perform the operation only once as images are added/uploaded. Rather than repeating them on each request.

However to answer your question, there are some very thorough blog entries on the topic of using cfthread (not image handling specifically).  I would start there.

http://www.coldfusionjedi.com/index.cfm/2009/6/17/CFThread-Example--Creating-and-merging-PDFs

http://www.bennadel.com/blog/743-Learning-ColdFusion-8-CFThread-Part-I-Data-Exchange.htm

http://www.petefreitag.com/item/650.cfm

Message was edited by: -==cfSearching==-

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 08, 2010 Aug 08, 2010

Copy link to clipboard

Copied

LATEST

I am just not getting the thread stuff. So I thought I would try recordset paging. It helps, but not the best. anyone else have any thoughts?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation