6 Replies Latest reply on May 18, 2009 1:14 PM by tSpark

    cfimage performance issues

    hillbillyfunk
      I'm using cfimage to resize a jpg and paste a png on to that jpg. It is running very slow (more than a minute an image) and I have to process 100 images. I was using the Alagad image component with CF 7 and it was very quick. Now with the same code on CF8 it is very slow...using CFimage or Alagad. I am also getting Java out of memory errors. Attached is a code snippet.

      Any suggestions to increase performance?


        • 1. cfimage performance issues
          Jayesh_Viradiya
          "Now with the same code on CF8 it is very slow...using CFimage or Alagad."

          Let me calrify the above line of yours....Are you saying that CFIMAGE and ALAGAD both are slow on CF8 ?

          Is it slow all the time or only the first time you access this page ?

          Also can you post the error messages encountered ?

          Thanks
          Jayesh Viradiya
          Adobe CF Team
          • 2. Re: cfimage performance issues
            hillbillyfunk Level 1
            quote:

            ..Are you saying that CFIMAGE and ALAGAD both are slow on CF8 ?

            >>correct they are both very slow...it seems around the same speed.

            quote:

            Is it slow all the time or only the first time you access this page ?

            All the time. And, the more I try, the more Java memory errors I get. I'm using CFDynamics as a host, and they have applied the latest hotfixes.
            • 3. Re: cfimage performance issues
              hillbillyfunk Level 1
              Here is the out of memerory error message--

              thanks--
              • 4. Re: cfimage performance issues
                Hi,
                I tried with cfimage(CF8) and alagad(on CF7 and CF8). I have used the same scenario as you mentioned in the code. i.e
                1. To read a jpg image (70kb)
                2. Resizing it.
                3. Pasing a .png file on it
                4. Writing it back to disk

                To process 100 such images both cfimage and alagad are taking less than a minute.
                Here is the code for cfimage:

                <cfset t1 =Now()>
                <cfloop from=0 to=100 index=cf_index step=1>
                <cfset imageToConvert = "C:\ColdFusion8\wwwroot\testbench\test" & "\" & "Sunset.jpg" >
                <cfset imageToWrite = "C:\ColdFusion8\wwwroot\testbench\test" & "\" & "Sunset_resize" & "#cf_index#" & ".jpg">

                <!--- cfimage --->
                <cfset myImage=ImageRead(imageToConvert)>

                <cfset ImageResize(myImage,"1349","1753","HIGHESTPERFORMANCE")>
                <cfimage source="C:\ColdFusion8\wwwroot\testbench\test\test.png" name="topImage">
                <cfset ImagePaste(myImage,topImage,0,0)>

                <!--- output the new image --->
                <cfset ImageWrite(myImage,imageToWrite)>
                </cfloop>
                <cfimage source=#myImage# action = "writeToBrowser">

                <cfset t2 = Now()>
                <cfset t3 = DateDiff("s", t1,t2)>

                <br /><cfoutput>Time taken : <cfdump var = "#t3#"> sec</cfoutput>


                Thanks
                Kunal Saini
                Adobe CF Team
                • 5. Re: cfimage performance issues
                  hillbillyfunk Level 1
                  Thanks for looking into this Kunal. I found out why this was taking very long for me. The PNG I was pasting over the jpgs was at a resolution of 300 dpi. When I changed it to 72, the code ran quickly. So beware, using ImagePaste with an image over 72 dpi will suck up a ton of memory and take a long time. This doesn't seem to be an issue using Alagad's component on CF7, so I'm thinking this is a bug in CF8.

                  -Karl
                  • 6. Re: cfimage performance issues
                    tSpark

                    Thanks Karl.  I changed my image to 72dpi and it did process much faster, but the resulting image was still inverted with colors missing.