5 Replies Latest reply on Mar 14, 2017 9:09 AM by WolfShade

    BLOB image to browser WITHOUT using CFIMAGE?

    WolfShade Level 4

      Hello, all,

       

      I am trying to re-write part of an application that loads images from a database into a carousel.

       

      Currently, the logic grabs the BLOBs from the database, saves them to a folder, and then displays the images.

       

      I'd like to grab the BLOBs and directly display them on the page without saving them to a folder.  However, after all the Google search attempts, I have not found a solution - they all want to use CFIMAGE action="writeToBrowser".

       

      Unfortunately, the directory that these images are saved to with writeToBrowser action is blocked by network admins and the people who control the CF server.  So I _can't_ use CFIMAGE.

       

      Is there a way to take the BLOB images direct from database to browser without using CFIMAGE??

       

      V/r,

       

      ^_^

       

      UPDATE: We need to be able to support IE9+, possibly IE8, and FireFox v42+.

        • 1. Re: BLOB image to browser WITHOUT using CFIMAGE?
          haxtbh Level 4

          You could use BinaryEncode to convert the binary to base64. Then use this base64 in the src of the image.

           

          There were some limitations with older browsers and base64 images. They could only be so large before the browser didnt load them.

           

          I would just ask for the temp dir to be unblocked by the admins though ^^

          • 2. Re: BLOB image to browser WITHOUT using CFIMAGE?
            WolfShade Level 4

            haxtbh  wrote

            I would just ask for the temp dir to be unblocked by the admins though ^^

            I'm a federal contractor.  The DoD won't even hear me asking.  Not happening.

             

            Thanks for the suggestions, but will that work with A) IE8 or IE9, and B) with large images (4-8M)?  You're referring to the "data:" method, right?

             

            V/r,

             

            ^_^

            • 3. Re: BLOB image to browser WITHOUT using CFIMAGE?
              haxtbh Level 4

              Its technically supported but the size limit is where the issue will lie. You will have to test it.

               

              The other option to read the file and then save it to a dir you do have access to then use this to display the image. So save it to /images/ for example and the image src just points to that folder.

               

              Without access to certain things you will be limited.

               

              You might be able to do it with cfcontent.

               

              Use something like:

               

              <cfcontent reset="Yes" type="image/jpg" variable="#QueryName.BlobColumn#"/>
              

               

              This would go in separate page that you pass the required vars you need for the query (i.e. the id). You could save this as getMyImage.cfm then call it from the src of the image you want to show.

               

              <img src="getMyImage.cfm?queryID=1234">
              

               

              Never tried it myself, but could work.

              • 4. Re: BLOB image to browser WITHOUT using CFIMAGE?
                WolfShade Level 4

                haxtbh  wrote

                 

                Never tried it myself, but could work.

                Actually, there is an older project, here, where that is being done.  I didn't realize (until now) that the previous developer did that because of the CFIMAGE problem.  Seems 'hackish', to me, but now I see that it is totally necessary in this environment.  Sadly.

                 

                Thank you for your help.  I'll give that a shot and report back.

                 

                V/r,

                 

                ^_^

                • 5. Re: BLOB image to browser WITHOUT using CFIMAGE?
                  WolfShade Level 4

                  Yep, yep, that worked. 

                   

                  In the application.cfc, there is a conditional that states if more than a minute has passed since the last images refresh, it will pull the images from the database and assign them to application variables.  The page in question will then load the carousel with the images from the application variable.  Most of the images are between 400 and 600k in size; many are just under 1Meg; a few are between 1.5Meg and 8Meg.  The 1.5Meg images load in about 250ms, so that's quite nice.

                   

                  The "display.cfm" page is so simple, it kills me.  I param a URL parameter (position of the application variable array) to 1, check to make sure that the URL parameter is a single digit - if not, set the URL parameter to 1.  Then CFHEADER and CFCONTENT using the binary located in the indexed position.  Voila.  Still seems hackish, to me, but it works and it doesn't use CFIMAGE. 

                   

                  Thanks, again, for the suggestion, haxtbh.

                   

                  V/r,

                   

                  ^_^