0

I am trying to convert a base64 string into an image in ColdFusion, but it is not working. From what I have read, this can be done with the ImageReadBase64 function:

<cfset myImage = ImageReadBase64("/9j/4AAQSkZJRgABAQA..............")> 

So I tried retrieving a base64 image string from my database:

<cfquery name="GetSignImage" datasource="#application.ds#">
      select SIGNIMGBINARY 
      from   T_APPT_sign
      where  CHECKINID ='#CHECKINID#'
</cfquery>

<cfif GetSignImage.SIGNIMGBINARY neq "">
    <cfimage source="#ImageReadBase64(GetSignImage.SIGNIMGBINARY)#" name="signImage" action="resize" width="65%" height="55%">
    <cfimage source="#signImage#" action="writeToBrowser">
</cfif>

But I get this error:

The Base64 data is not in proper format. Data should be in the format understood by the <img> tag in HTML, which is "data:image/jpg;base64,[base64 data]"

Can anyone explain what I am doing wrong?

Leigh
  • 28,765
  • 10
  • 55
  • 103
chyman-91
  • 263
  • 3
  • 5
  • 12
  • 2
    What is the error you are getting? – Abhishekh Gupta May 16 '16 at 09:57
  • Ist he Bas64 encoded string returned by the databse complete? Maybe the DB only returned the first 4000 bytes or so. – Bernhard Döbler May 16 '16 at 11:34
  • i get this error The Base64 data is not in proper format. Data should be in the format understood by the <img> tag in HTML, which is "data:image/jpg;base64,[base64 data]" – chyman-91 May 17 '16 at 01:04
  • First check if the source you are specifying is an image. Like this: `` It will help you find the issue. – Pankaj May 17 '16 at 05:14
  • hello, no changes... it still gv me Error Occurred While Processing Request The Base64 data is not in proper format. Data should be in the format understood by the <img> tag in HTML, which is "data:image/jpg;base64,[base64 data]" – chyman-91 May 17 '16 at 08:55
  • Error messages belong [in the question](http://stackoverflow.com/posts/37249390/edit) so they are more visible. – Leigh May 17 '16 at 14:15

0 Answers0