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

cfImage to BLOB - Workaround Needed

Participant ,
Feb 07, 2008 Feb 07, 2008

Copy link to clipboard

Copied

Can someone please give me a simple workaround? And no, I do not want to store the files in a directory. I rather store via database.

My Error:
The destination file should contain an extension, so that ColdFusion can determine the image format.
(This error is thrown on my second cfqueryparam line.)

TOPICS
Advanced techniques

Views

1.6K

Translate

Translate

Report

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 ,
Feb 07, 2008 Feb 07, 2008

Copy link to clipboard

Copied

Try extracting the BufferedImage using ImageGetBufferedImage. Then use the ImageIO class to write it to a ByteArrayOutputStream. Finally passing the bytes to cfqueryparam.

http://java.sun.com/j2se/1.5.0/docs/api/javax/imageio/ImageIO.html#write(java.awt.image.RenderedImag...

Votes

Translate

Translate

Report

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 ,
Feb 07, 2008 Feb 07, 2008

Copy link to clipboard

Copied

Though all of that is unnecessary. Your only problem is that you are using cffile action="readbinary" instead of ImageNew. Change it to ImageNew and it should work fine.



Votes

Translate

Translate

Report

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 ,
Feb 08, 2008 Feb 08, 2008

Copy link to clipboard

Copied

Thank you for your quick response. But now I am getting this error:

"The tmp image format is not supported on this operating system.
Use GetReadableImageFormats() and GetWriteableImageFormats() to see which image formats are supported."

Any ideas??

Votes

Translate

Translate

Report

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 ,
Feb 08, 2008 Feb 08, 2008

Copy link to clipboard

Copied

What is the value of #form.image#. Is it a file path or an image that has been uploaded? If it is a file path, what type of image is it: jpg, gif, ..?

Votes

Translate

Translate

Report

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 ,
Feb 08, 2008 Feb 08, 2008

Copy link to clipboard

Copied

Three image types I want to accept, jpeg, gif, or png.
#form.image# is coming from:

Votes

Translate

Translate

Report

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 ,
Feb 08, 2008 Feb 08, 2008

Copy link to clipboard

Copied

I do not think you can do that. #form.image# only contains a temporary file name. You need to upload the file first using cffile action="upload". It should not make much difference since the image file is already on the server by that point. Then pass the absolute file path to the ImageNew function. You can delete the saved image when you are finished.



Votes

Translate

Translate

Report

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 ,
Feb 08, 2008 Feb 08, 2008

Copy link to clipboard

Copied

quote:

Three image types I want to accept, jpeg, gif, or png.


I do not think ImageGetBlob() works on GIF's. At least not in my tests. It returns the error

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.

So you may have to use the ImageIO method after all.

EDIT: Oops. I may be mixing your requirements with mine. If you upload the file and then use cffile action="readbinary" you already have the bytes. So you should not need to use ImageGetBlob. Try inserting the bytes directly.




Votes

Translate

Translate

Report

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
New Here ,
Apr 17, 2008 Apr 17, 2008

Copy link to clipboard

Copied

what about .bmp?

Votes

Translate

Translate

Report

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 ,
Apr 20, 2008 Apr 20, 2008

Copy link to clipboard

Copied

ImageGetBlob should work correctly with bitmaps.

Votes

Translate

Translate

Report

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
New Here ,
Sep 21, 2010 Sep 21, 2010

Copy link to clipboard

Copied

LATEST

Need help:

Problem:

I want to modify the DPI infromation of my bufferedImage. What is the procedure. The image after extraction from PDF is taken in as bufferedImage & its of PNG type.

How can I update its DPI iformation, like 150 to 300 & 300 to 150.

Regards,

Gaurav

Votes

Translate

Translate

Report

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
Documentation