Converting image to byte array

  • Thread starter Bjorn Sagbakken
  • Start date
B

Bjorn Sagbakken

Hi.

This story is about uploading jpg's, then resize them to fixed width or
height and storing them to an SQL table.
The only way I have found so far is to read the uploaded file to an
image-variable, then using the method of creating thumbnails for the
resizing. Next, I write this to a temp file on the disk, and read the file
back to a byte array in order to insert/update the SQL table.

Now, this works well, and even fast enough, no problem really. I just
irritate myself by the fact that I do the format converting by temp file
saving to the HDD. To perfect this I really want to perform this in memory.
Anynone that has an idea for this?

Bjorn
 
M

Mark Fitzpatrick

Bjorn,
Have you tried using a MemoryStream? You should be able to save the
image to a MemoryStream then use the ToArray() method (I think that's the
one) of the MemoryStream to generate a byte array.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top