Skip to main content
Inspiring
December 5, 2008
Answered

ImageGetBlob with GIFs

  • December 5, 2008
  • 3 replies
  • 1755 views
I'm trying to insert a gif file into a blob field in a database. I can insert it fine if the image is a jpg type. When I try a gif, it give me an error. Can you not insert a gif into a blob field?

Detail Verify your inputs. An error occured in converting the image to base64 in the required image encoding. Base64 images can be created with ColdFusion in BMP,JPEG,PNG,PNM,and TIFF formats.

MessageAn error occured in converting the image to base64 in the required image encoding. Base64 images can be created with ColdFusion in BMP,JPEG,PNG,PNM,and TIFF formats.

thanks for any help
    This topic has been closed for replies.
    Correct answer -__cfSearching__-
    > i used the readbinary on the CFFILE tag. On my insert do I need to use imageGetBlob.

    ... Hmm, from your other thread I thought #ItemAdded# was a string. But maybe not.

    The cffile / readBinary is meant as a replacement for ImageGetBlob. So if you _are_ using cffile / readbinary, you already have the bytes. You do not need to use ImageGetBlob on top of it. Just use the variable directly.

    <cffile action="readBinary" file="(..whatever..)" variable="imageBytes">
    ...
    <cfqueryparam cfsqltype="cf_sql_blob" value="#imageBytes#">
    ...

    3 replies

    Inspiring
    December 5, 2008
    You are welcome. Glad it is working now.
    -__cfSearching__-Correct answer
    Inspiring
    December 5, 2008
    > i used the readbinary on the CFFILE tag. On my insert do I need to use imageGetBlob.

    ... Hmm, from your other thread I thought #ItemAdded# was a string. But maybe not.

    The cffile / readBinary is meant as a replacement for ImageGetBlob. So if you _are_ using cffile / readbinary, you already have the bytes. You do not need to use ImageGetBlob on top of it. Just use the variable directly.

    <cffile action="readBinary" file="(..whatever..)" variable="imageBytes">
    ...
    <cfqueryparam cfsqltype="cf_sql_blob" value="#imageBytes#">
    ...
    BJ_-_CFAuthor
    Inspiring
    December 5, 2008
    thanks once I took off the ImageGetBlob then if now works for the gif image.

    thank you for your help.
    Inspiring
    December 5, 2008
    > When I try a gif, it give me an error

    I ran into some problems with gif's as well. The two solutions I found were a) if the image already exists on disk use cffile with "readbinary" or b) use java to extract the bytes.

    http://cfsearching.blogspot.com/2008/02/using-coldfusion-8s-imagegetblob.html
    BJ_-_CFAuthor
    Inspiring
    December 5, 2008
    i used the readbinary on the CFFILE tag. On my insert do I need to use imageGetBlob. It is giving me an error:

    item_photo= <cfqueryparam cfsqltype="cf_sql_blob" value="#ImageGetBlob(ItemAdded)#">

    Here is the error: Unable to cast an object of type [B to Image.

    thanks,

    Inspiring
    December 5, 2008
    > i used the readbinary on the CFFILE tag. On my insert do I need to use imageGetBlob.

    Those are two totally different errors, with different solutions. I suspect your last error is due to an incorrect usage of ImageGetBlob. Look at the documentation. I believe ImageGetBlob expects and image object.

    Are you passing in an image object or a just a string file name?

    http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=functions_h-im_23.html