Skip to main content
Question

Base64 Image To Oracle Blob To Base64 Image


deanhowell
Influencer
Forum|alt.badge.img+23

Hello everyone,

I am storing a range of base64 PNG images as blobs in an Oracle Table.

 

As part of a separate process, I want to read these images from Oracle and use them in an HTML report.

 

What I am noticing is the attribute being written to Oracle is different to what is being returned from Oracle.

 

Attributes when written to OracleimageAttribute from Oracle

imageWhat do I need to do to read / write the image so I can use the Base64 version as an attribute in the HTML writer?

 

 

4 replies

david_r
Celebrity
  • July 11, 2022

Any particular reason for base64-encoding the images before storing them in the BLOB? Why not simply store the binary file in the BLOB directly, without having to go through base64?


deanhowell
Influencer
Forum|alt.badge.img+23
  • Author
  • Influencer
  • July 11, 2022
david_r wrote:

Any particular reason for base64-encoding the images before storing them in the BLOB? Why not simply store the binary file in the BLOB directly, without having to go through base64?

Good question @david_r​ and the main reason is that I am using base64 in my HTML for example

 

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4

//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot" />

 

So I want to be able to use the attribute

 

<img src="data:image/png;base64,@value(RasterBlob)" alt="Red dot" />

 

 

 


david_r
Celebrity
  • July 11, 2022
deanhowell wrote:

Good question @david_r​ and the main reason is that I am using base64 in my HTML for example

 

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4

//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot" />

 

So I want to be able to use the attribute

 

<img src="data:image/png;base64,@value(RasterBlob)" alt="Red dot" />

 

 

 

I would still just store the PNG as-is in the BLOB, then convert it to base64 at the last minute when generating the html.

BLOB is a binary data type, so it makes sense to store binary data, such as the PNG file contents, in it. Base64 is a text format, so it would be easier to simply store it as a CLOB in Oracle, rather than a BLOB.


deanhowell
Influencer
Forum|alt.badge.img+23
  • Author
  • Influencer
  • July 11, 2022
deanhowell wrote:

Good question @david_r​ and the main reason is that I am using base64 in my HTML for example

 

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4

//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot" />

 

So I want to be able to use the attribute

 

<img src="data:image/png;base64,@value(RasterBlob)" alt="Red dot" />

 

 

 

Thanks again, I will give that a go :)


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings