7 Replies Latest reply: Oct 12, 2016 3:58 AM by Andre Toerien RSS

    Loading pictures/images

    Andre Toerien

      Hi

       

      I have to load the following as a picture. I have not come across this before

       

      example in attached file. Any ideas?

        • Re: Loading pictures/images
          Adam Davies

          Is that a SQL BLOB or base 64?

          • Re: Loading pictures/images
            Adam Davies

            For BLOBs I used this weird two step process

             

            // As dumb as it is, this is the two step code to load binary images into QV.

             

             

            logos:

            SQL SELECT

              ConfiguredValue as logo_name

              ,image

             

              FROM [DW_XXXXXXXXXXXX].[dbo].[XXXXXXXXXXX_SSRS_CONFIG]

             

              WHERE ConfiguredValueType LIKE 'image%'

             

              ;

             

             

            INFO SELECT

              ConfiguredValue as logo_name

              ,image

             

              FROM [DW_XXXXXXXXXXXXXXXX].[dbo].[XXXXXXXXXXX_SSRS_CONFIG]

             

              WHERE ConfiguredValueType LIKE 'image%'

             

              ;

            • Re: Loading pictures/images
              Marco Wedel

              Hi,

               

              maybe one solution might be:

               

              QlikCommunity_Thread_235800_Pic1.JPG

               

              QlikCommunity_Thread_235800_Pic2.JPG

               

              table1:
              LOAD 'Pic'&RecNo() as PicNo,
                  A
              FROM [https://community.qlik.com/servlet/JiveServlet/download/1139317-249014/Book1.xlsx] (ooxml, no labels, table is Sheet1)
              Where Len(A);
              
              Left Join
              LOAD A,
                  Len(A) as LenPic
              Resident table1;
              
              tabTemp:
              LOAD A,
                  OctetStringToFile(A, 'D:\Temp\'&PicNo&'.yourfileextension') as ResultOctetStringToFile
              Resident table1;
              
              Bundle Info LOAD
                PicNo,
                'D:\Temp\'&PicNo&'.yourfileextension'
              Resident table1;
              

               

               

              QlikCommunity_Thread_235800_Pic3.JPG

               

              Function OctetStringToFile(OctetString, FilePath)
              Const adTypeText = 2
              Const adSaveCreateOverWrite = 2
              
              LenData = Len(OctetString)\2 + Len(OctetString) Mod 2
              set fso = createobject("scripting.filesystemobject")
              set stream = createobject("adodb.stream")
              stream.type = adTypeText
              stream.charset = "windows-1252"
              stream.open
              For i = 0 to LenData-3
                stream.writetext chr(CByte("&h" & Mid(OctetString, i*2+3, 2)))
              Next
              stream.savetofile FilePath, adSaveCreateOverWrite
              stream.close
              OctetStringToFile = "processed"
              End Function
              

               

               

              hope this helps

               

              regards

               

              Marco