11 Replies Latest reply on Dec 3, 2010 9:11 AM by jav_ssii

    CFImage bug?

    hans blix
      I'm having a problem with CFImage where it seems to be locking the image file it is using, making it unable to be deleted (even in windows file explorer).

      Here is the scenario:
      I upload an image file using cffile action=upload

      I read the file in using cfimage

      I resize the file (using imageResize()) and write it to disk using CFImage action="write" with a new file name.

      I then try to delete the original uploaded file, and get an error:
      ColdFusion could not delete the file d:\inetpub\wwwroot\site\cfml\images\listingimages\1998\000_0202.jpg for an unknown reason.

      The reason appears to be that ColdFusion had locked the file. It only seems to happen with files over 300K in size.

      I've tried everything I can think of to delete the file. Some have stayed locked and unable to delete until I restart the CF services.

      I'm running CF8.0.1 on Win2003 server. Thanks for any help you can give.
        • 1. Re: CFImage bug?
          TKirstein Level 1
          We have noticed the same issue in the same type environment (CF8.0.1 on Win2003 server).

          For us, it seems to lock the source image no matter the size of the jpg. After the file is uploaded, we try to resize it and then write the image back out to the same filename (with overwrite="true"). This causes an error. Resizing to a different filename works.

          For us it seems any JPG image that is used as the source in a cfimage resize will be left locked.

          We have tried using cfimage with source and destination set (as the same JPG file name with OS path) and Overwrite set to true (RESULT: Errors out with "Ensure that the destination directory exists and that Coldfusion has permission to write to the given path or file. cause : java.io.FileNotFoundException").

          We have tried resizing the image into memory then tried to cffile delete the source file... wanting to write the image back to the drive from memory (RESULT: errors out saying the file cannot be deleted)

          What we have done for now is to rename the file to a XXXXX_TEMP.JPG temp file and resize it to the needed destination. Works perfectly but leaves behind _TEMP.JPG files that cannot be deleted due to a file lock.

          As Administrator on the server we cannot delete or rename the source file for about 30-45 minutes after the resize is completed (or we restart the ColdFusion service)

          Any work around or fixes to this issue would be greatly appreciated.

          • 2. Re: CFImage bug?
            DefconRhall Level 1
            We have this same issue. It seems to happen with every image now.

            I believe it has something to do with a recent CF update that one of our customer's hosting providers has applied, however they do not know which it is.

            I was thinking of a fix involving uploading the new file to the CFTemporary directory. However I was wondering if and how often the CFTemp directory is purged automatically.
            • 3. Re: CFImage bug?
              hans blix Level 1
              We came up with a workaround since the issue seems to be a bug. We are now uploading to a directory, reading the file and resizing, then saving it to a different directory (leaving us with 2 files). This way the original file can stay locked because we never write to it. To get rid of the original files in that directory, we run the attached code nightly as a scheduled task to purge any images from that upload directory that haven't been accessed in the last 30 minutes. The files seem to unlock after a period of time, so deleting them hasn't been a problem. So far this workaround has done the job.

              Please post back if you found a better solution or a fix.
              • 4. Re: CFImage bug?
                DefconRhall Level 1
                That's pretty much what we were going to do, except with using the CF Temp directory to try and handle the auto delete. I don't see any other way to work around this.
                • 5. Re: CFImage bug?
                  TKirstein Level 1
                  This is definitely a bug. We first noticed it after the CF 8.0.1 update but we didn't really do too much/any resizing before the last few weeks.

                  Anyone know how to submit a bug to the ColdFusion dev team? I see how for Flex but not for CF.
                  • 7. Re: CFImage bug?
                    DefconRhall Level 1
                    I submitted the bug report. Now I just realized that I should have mentioned this thread in that report.

                    If anyone else is going to submit one, include a link to this thread in the report as well.

                    • 9. Re: CFImage bug?
                      -==cfSearching==- Level 4
                      Ken Smith wrote:
                      Try Patch for CFImage and Image functions in ColdFusion 8.0.1 (kb403411)

                      Thanks. I installed the patch and it seems to have fixed the file locking issues.

                      Another image issue raised by hans blix is a Missing Huffman code table entry error that occurs with some images. Do you know if this exception is caused by a problem with the image files themselves or an issue with updater 1?
                      • 10. Re: CFImage bug?

                        Originally posted by: ksmith
                        Try Patch for CFImage and Image functions in ColdFusion 8.0.1 (kb403411)

                        The patch worked! Thanks.

                        • 11. Re: CFImage bug?

                          I had the same problem and the patch worked also for me. Thank you!