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

Decoder cannot decode input

Guest
Feb 25, 2011 Feb 25, 2011

Hello everybody,

I try to create a new image with a blob coming from a database, but when I execute the following instructions, ColdFusion returns me an error message "Decoder cannot decode input."

<cfquery name="qData" datasource="MyDS">
SELECT a.BLOB_DOC
FROM TOFFDOC a
WHERE a.CLE_DOC = #URL.cledoc# AND
a.TYP_DOC = 'JPG'
</cfquery>

<cfset myOriginalImage=ImageNew(qData.blob_doc)>

I use Coldfusion 9.0.1.274733 enterprise edition on a Windows server 2003 and Sysbase Sql Anywhere 11 for the database.

An idea ?

1.8K
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
Enthusiast ,
Feb 25, 2011 Feb 25, 2011

Does your CF datasource have the BLOB option enabled?


See:
http://help.adobe.com/en_US/ColdFusion/9.0/Admin/WSc3ff6d0ea77859461172e0811cbf364104-7fe0.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
Guest
Feb 25, 2011 Feb 25, 2011

Yes, I checked the CLOB and BLOB options  in the advanced settings of the datasource

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
Enthusiast ,
Feb 25, 2011 Feb 25, 2011

If you view the blob field's contents is the result a base 64 encoded string? If so you may need to wrap a call to the ToBinary function around the field when using it is a parameter for the ImageNew function.

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
Guest
Feb 25, 2011 Feb 25, 2011

Hi, Thanks for your answer

Sorry, I forgot to specify that the code works fine when I retrieve a small BLOB image (less than 400k), for the bigger images it raises an exception.  I also tried to use the ToBase64() conversion function but I always have the same error.

Regards

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
Enthusiast ,
Feb 25, 2011 Feb 25, 2011

Have you verified that the BLOG being retrieved is a valid image? Can you open and view the image file if the image is saved to the file system with CFFILE? Is the image in a format compatible with ImageNew()?

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
Guest
Feb 25, 2011 Feb 25, 2011

The retrieved image is a JPG format.

I can create a new image using the ImageNew() function only for image with a size less than 400k.

Actually, I am not at my office and I couldn't test using CFFILE.  I will test Monday

Thanks 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
Guest
Feb 28, 2011 Feb 28, 2011

I can browse the image when I export this one with Sybase central

<cfoutput>

<cffile action="readbinary" file="...\894170cf31d9e327bc074e050e2cac4a.jpg" variable="myImage">

<cfimage action="writeToBrowser" source="#myImage#">

</cfoutput>


But when I try to use ImageNew() with a BLOB field, CF returns me "Decoder cannot decode input." for the same image

<cfquery name="qData" datasource="MyDs">
SELECT a.BLOB_DOC FROM TOFFDOC a
WHERE a.CLE_DOC = #URL.cledoc# AND
a.TYP_DOC = 'JPG'
</cfquery>

<cfset myOriginalImage=ImageNew(qData.blob_doc)>

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
Enthusiast ,
Feb 28, 2011 Feb 28, 2011

What happens if you use CFFILE to write the contents of BLOB_DOC to disk? Is the resulting file correct?

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
Guest
Feb 28, 2011 Feb 28, 2011

Yes it works fine when I use the CFFILE syntaxe

<cffile action="write" file="#rootLarge##qBlob.IMG_CLE_DOC#.jpg" output="#qBlob.blob_doc#" >

It's really strange

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
Enthusiast ,
Feb 28, 2011 Feb 28, 2011

Have you tried writing the image to the file system, then using the file system as the source for the ImageNew function call?

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
Guest
Feb 28, 2011 Feb 28, 2011

Yes, and it works fine

<cffile action="readbinary" file="...\894170cf31d9e327bc074e050e2cac4a.jpg" variable="binObj">

<cfset myImage=ImageNew(binObj)>

<cfimage action="writeToBrowser" source="#myImage#">

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
Guest
Mar 01, 2011 Mar 01, 2011
LATEST

Actually, I found this workaround

<cftry>

   <cffile action="write" file="#rootLarge##qImages.IMG_CLE_DOC#.jpg" output="#qImages.blob_doc#" >  

   <cffile action="readBinary" file="#rootLarge##qImages.IMG_CLE_DOC#.jpg" variable="myOriginalImage">

   <cfset myOriginalImage=ImageNew(myOriginalImage)>

   <cfset myWidth=#ImageGetWidth(myOriginalImage)#>

   <cfset myHeight=#ImageGetHeight(myOriginalImage)#>

        <cfif myWidth gt 900 or myHeight gt 540>

              <cfset ImageScaleToFit(myOriginalImage,900, 540)>

        </cfif>

   <cfimage source="#myOriginalImage#" action="write" destination="#rootLarge##qImages.IMG_CLE_DOC#.jpg" overwrite="yes" quality="1">

   <cfcatch type="any"><cfset errorMessage=errorMessage&"#cfcatch.message#<BR>"></cfcatch>

</cftry>

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