Image Question

  • Thread starter Thread starter Stan Sainte-Rose
  • Start date Start date
Herfried,
above?

Mhm... Why not store the files as BLOBs?
1. The question was, do you have the routine to convert all image formats to
blobs,
2. Do you kow if you loose image information from converting to and from
blobs.

Cor
 
* "Cor said:
1. The question was, do you have the routine to convert all image formats to
blobs,

Yes. Simply store the whole file.
2. Do you kow if you loose image information from converting to and from
blobs.

You won't loose information when storing the whole image file.
 
Hi Herfried,

Not that it is really important but now you make me curious.
(I told you that I did know very few about imaging, it is something more but
not what I wanted it to be)

I have a gif file

I load that as an image
I stream that to a bytearea (Here I can not loose data I think)
I save that as a blob (that is the part where I am sure to loose no data)
I read that as a blob (no problem as far as I can see it are bytes)
I stream that to an image (I think that here is also no problem)
I save that as a png

And then there is no data lost?

Same question with the difference the last sentence because the previous
sounds to me impossible.

I save that as a gif

Is in the last situation is every bit from the created gif file the same as
the original?

Cor
 
* "Cor said:
Not that it is really important but now you make me curious.
(I told you that I did know very few about imaging, it is something more but
not what I wanted it to be)

I have a gif file

I load that as an image
I stream that to a bytearea (Here I can not loose data I think)
I save that as a blob (that is the part where I am sure to loose no data)
I read that as a blob (no problem as far as I can see it are bytes)
I stream that to an image (I think that here is also no problem)
I save that as a png

Why do you want to save it as a PNG?
And then there is no data lost?

Same question with the difference the last sentence because the previous
sounds to me impossible.

I save that as a gif

Why? Just save the byte array to a GIF file.
Is in the last situation is every bit from the created gif file the same as
the original?

Yes.
 
Hi Herfried,

Thanks,

Do you have for me managed code sample for this?
Why? Just save the byte array to a GIF file.
Because I never saw that posibility, so maybe I do something to much.

Cor
 
Cor:

If saving binary data in a blob could result in lost or modified data it
would be virtually useless. I can't imagine a "database" that decided on
your behalf what was and was not "information."

Tom
 
Hi Herfried,
That's a question for the ASP.NET group. Currently, I don't have a
sample.

Reading a gif file in a byte area?

You asked me why I did not do that, and than I said I did not know how to do
that with managed code.

And no

:-)

So serious, was it late yesterday Herfried?

Cor
 
Hi Tom,
If saving binary data in a blob could result in lost or modified data it
would be virtually useless. I can't imagine a "database" that decided on
your behalf what was and was not "information."

No for showing a picture on a form or a thumbnail it can be very effective.
I did not check it, however my idea was that an 32Mb Tiff picture would not
fit easy as a field in a database.

But if you have expieriences with putting that kind of pictures in a
database I would glad hear about those expiriences.

Cor
 
Cor,

I did mention that I didn't know too much about Image conversion, but here
are a few conditions under which you may loose data:

1) Changing from a "lossless" format to a "lossy" format (e.g. Gif to Jpeg -
Gif stores an exact replication of the image data, but JPEG compression
results in smaller sizes because it discards data that it thinks isn't
important)

2) Changing the color depth of the image (e.g. 24 bit PNG to 8 bit gif - Gif
only stores 256 colors, PNG can store 8 bit or 24 bit (or higher) images.

3) Changing between formats where the destination format doesn't support
transparent colors.

4) Changing between a vector format to a bitmap format (e.g. wmf to gif)

5) Changing the resolution of the image.

6) Changing from a specialized format that stores data other than image data
(e.g. photographers name) or a format that can hold multiple images (e.g.
Icon) to another format that doesn't support these features.


These should be the only types of conditions that you could "loose" data.
You shouldn't be loosing any by storing it in a BLOB (assuming there's no
bugs in your database code ;)

From what I understand from your conversion, changing from GIF to PNG
shouldn't cause you to loose any data (although the PNG compression could
result in fewer bytes in some cases)

A better group for this might be microsoft.public.dotnet.framework.drawing
or a more generic image convcersion group as you problem seems to be with
changing image formats, not the storing of data in BLOBS or other files.


Hope this helps,

Trev.
 
* "Cor said:
Reading a gif file in a byte area?

You asked me why I did not do that, and than I said I did not know how to do
that with managed code.

Sorry, misread your post. Have a look at the 'MemoryStream' class.
You can create a memory stream from a byte array and then use
'Image.FromImage' to construct an image from the data. Alternatively,
you can use the 'BinaryWriter' to write the byte array to disk.
 
Cor,

"Lossy compression" that you voluntarily choose to use is one thing...
having the database decide that it will "lose data" by dropping some bytes
from a binary stream is quite another. A blob "must" return whatever you
store in it unchanged. Keep in mind it doesn't know why you are storing the
data, it doesn't know it is an image destined for a web page.

One of the problems you encounter when very large binary fields are stored
is a maintenance issue. Not a big deal if you mostly add images but (as far
as I know) if you update and delete images a lot the database becomes filled
with old versions of the data which have to be purged periodically.

Tom
 
Hi Herfried,
Sorry, misread your post. Have a look at the 'MemoryStream' class.
You can create a memory stream from a byte array and then use
'Image.FromImage' to construct an image from the data. Alternatively,
you can use the 'BinaryWriter' to write the byte array to disk.

Here a link with some answers that are given in this newsgroup on that.

http://groups.google.com/groups?hl=...=group=microsoft.public.dotnet.languages.vb.*

But you told me to do it this way and that I did find very intresting
Why? Just save the byte array to a GIF file.

I could not make the URL shorter.

:-))))))))

Cor
 
Hi Trev,

The meaning of this thread is not the information, but the way we give
answers in this newsgroup.

But thanks for the information, because it added something again to mine and
I it makes things I was not sure of more sure because you read the same.
(It interest me, so it is not spoiled information)

And when I next time have a question like this, I take your advice and go
directly to Bob Powell in the drawing group.

And read my last answer to Herfried. Than all comes more clear.

:-)

Cor
 
And read my last answer to Herfried. Than all comes more clear.

lol. Guess I didn't pick up on the subtleness in your other posts ;)

Trev.
 
Back
Top