Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

ImageGetBlob with GIFs

Participant ,
Dec 05, 2008 Dec 05, 2008
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
1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , Dec 05, 2008 Dec 05, 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="c...
Translate
Valorous Hero ,
Dec 05, 2008 Dec 05, 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 05, 2008 Dec 05, 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,

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Dec 05, 2008 Dec 05, 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 05, 2008 Dec 05, 2008
This code works using a jpg image. When I try it with a gif I get an error.

<cfset itemPhoto = file.ServerFile>
<cfimage action="read" source="\Inetpub\wwwroot\safety\recognition\photoArea\#itemPhoto#" name="ItemAdded">
<cfset imageScaleToFit(ItemAdded,100,"")>
<cfquery name="updateCatalogItem" datasource="#application.dsn#">
update safety_recognitioncatalog
set item_description = <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.p_description#">,
item_points = <cfqueryparam cfsqltype="cf_sql_integer" value="#form.p_points#">,
item_link = <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.p_webAddress#">,
item_photo = <cfqueryparam cfsqltype="cf_sql_blob" value="#ImageGetBlob(ItemAdded)#">,
item_area_id = <cfqueryparam cfsqltype="cf_sql_integer" value="#form.p_area#">
where id = <cfqueryparam cfsqltype="cf_sql_integer" value="#form.p_id#">
</cfquery>

I then tried to take the image that is on the serve and use cffile with the action of readbinary. Then I used the same update code as above.

<cffile action="readbinary" file="\Inetpub\wwwroot\safety\recognition\photoArea\#itemPhoto#" variable="ItemAdded">

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Dec 05, 2008 Dec 05, 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#">
...
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 05, 2008 Dec 05, 2008
thanks once I took off the ImageGetBlob then if now works for the gif image.

thank you for your help.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Dec 05, 2008 Dec 05, 2008
LATEST
You are welcome. Glad it is working now.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources