ASP.Net Thumbnails

C

Chris D

I'm doing some work with submitting graphics via ASP.net page to SQL 2000
server using VB.

I know how to get a graphic into the database from a filefield control. I
also know how to pull it out of the database and thumbnail it on the fly.

Creating thumbnail on the fly seems extremely inefficient to me as this has
to be done every time the image is requested. What I want to do is get the
image from the filefield control, thumbnail it and save the thumbnail to the
database along with the full size image. That way the thumbnail process is
only ran once and I'm not to concerned about the extra storage space.

What I cant figure out is how to get the image from the
postedfile.imputstream.read to a system.drawing.image to generate the
thumbnail and then send the thumbnail to the database again.

I'm new to .net so any help is greatly appreciated

Thanks
Chris D
 
S

Sherif ElMetainy

Hello

Use System.Drawing.Image.FromStream methof to get the image from the posted
file inputstream
To put the image in the database, Create a MemoryStream object and save the
image to it

System.Drawing.Image origImage =
System.Drawing.Image.FromStream(postedFile.InputStream);
postedFile.InputStream.Seek(0, SeekOrigin.Begin); // rewind the input stream
to read it again to store the original image in the database

System.Drawing.Image thumbnail = new System.Drawing.Bitmap(w, h);
//generate the thumbnail

MemoryStream ms = new MemoryStream();
thumbnail.Save(ms);
ms.Seek(0, SeekOrigin.Begin);

byte[] buffer = new byte[ms.Length];
ms.Read(buffer, 0, buffer.Length);

Best regards,

Sherif ElMetainy
 
C

Chris D

I have tried what you suggested and it seems to work. The images are in the
database.

Where I run into problems is retrieving the images processed by this code.
Is there any special way of retrieving these images. Images submitted with
my old code retrieve fine. Its almost like the format of the image is not
correct. All it does is show a 'X' image

Chris

Sherif ElMetainy said:
Hello

Use System.Drawing.Image.FromStream methof to get the image from the posted
file inputstream
To put the image in the database, Create a MemoryStream object and save the
image to it

System.Drawing.Image origImage =
System.Drawing.Image.FromStream(postedFile.InputStream);
postedFile.InputStream.Seek(0, SeekOrigin.Begin); // rewind the input stream
to read it again to store the original image in the database

System.Drawing.Image thumbnail = new System.Drawing.Bitmap(w, h);
//generate the thumbnail

MemoryStream ms = new MemoryStream();
thumbnail.Save(ms);
ms.Seek(0, SeekOrigin.Begin);

byte[] buffer = new byte[ms.Length];
ms.Read(buffer, 0, buffer.Length);

Best regards,

Sherif ElMetainy



Chris D said:
I'm doing some work with submitting graphics via ASP.net page to SQL 2000
server using VB.

I know how to get a graphic into the database from a filefield control. I
also know how to pull it out of the database and thumbnail it on the fly.

Creating thumbnail on the fly seems extremely inefficient to me as this has
to be done every time the image is requested. What I want to do is get the
image from the filefield control, thumbnail it and save the thumbnail to the
database along with the full size image. That way the thumbnail process is
only ran once and I'm not to concerned about the extra storage space.

What I cant figure out is how to get the image from the
postedfile.imputstream.read to a system.drawing.image to generate the
thumbnail and then send the thumbnail to the database again.

I'm new to .net so any help is greatly appreciated

Thanks
Chris D
 
C

Chris D

Never mind, I got it to work.

Thanks a lot for the help

Chris

Chris D said:
I have tried what you suggested and it seems to work. The images are in the
database.

Where I run into problems is retrieving the images processed by this code.
Is there any special way of retrieving these images. Images submitted with
my old code retrieve fine. Its almost like the format of the image is not
correct. All it does is show a 'X' image

Chris

Sherif ElMetainy said:
Hello

Use System.Drawing.Image.FromStream methof to get the image from the posted
file inputstream
To put the image in the database, Create a MemoryStream object and save the
image to it

System.Drawing.Image origImage =
System.Drawing.Image.FromStream(postedFile.InputStream);
postedFile.InputStream.Seek(0, SeekOrigin.Begin); // rewind the input stream
to read it again to store the original image in the database

System.Drawing.Image thumbnail = new System.Drawing.Bitmap(w, h);
//generate the thumbnail

MemoryStream ms = new MemoryStream();
thumbnail.Save(ms);
ms.Seek(0, SeekOrigin.Begin);

byte[] buffer = new byte[ms.Length];
ms.Read(buffer, 0, buffer.Length);

Best regards,

Sherif ElMetainy



Chris D said:
I'm doing some work with submitting graphics via ASP.net page to SQL 2000
server using VB.

I know how to get a graphic into the database from a filefield
control.
I this
has to
the
process
 

d4d

Joined
May 27, 2011
Messages
1
Reaction score
0
So what did you do to solve it???

I have seen this everywhere... people solve the problem, but then dont show how they solved it.

I also need to do the same thing.
upload a file into a database, (which I can do) on the fly extract a thumbnail, (which is what I am having issues with) and also put the thumbnail in a database (which I can do).

any help would be great.

I am using asp.net with vb.net code behind and sql2008 on w2k3.
I can read and convert C# so if it is in C# that is not an issue.

I am able to get the image to go to the database no problem.
so now I want to extract the thumb at the same time but for the life of me I can not get it to work without first sending the image to a dir on a drive and doing the thumbnail extraction there and then reinserting the images into the database. Which is all to inefficient.

d4d

Never mind, I got it to work.

Thanks a lot for the help

Chris

"Chris D" <[email protected]> wrote in message
news:[email protected]...
> I have tried what you suggested and it seems to work. The images are in

the
> database.
>
> Where I run into problems is retrieving the images processed by this code.
> Is there any special way of retrieving these images. Images submitted with
> my old code retrieve fine. Its almost like the format of the image is not
> correct. All it does is show a 'X' image
>
> Chris
>
> "Sherif ElMetainy" <[email protected]> wrote in message
> news:[email protected]...
> > Hello
> >
> > Use System.Drawing.Image.FromStream methof to get the image from the

> posted
> > file inputstream
> > To put the image in the database, Create a MemoryStream object and save

> the
> > image to it
> >
> > System.Drawing.Image origImage =
> > System.Drawing.Image.FromStream(postedFile.InputStream);
> > postedFile.InputStream.Seek(0, SeekOrigin.Begin); // rewind the input

> stream
> > to read it again to store the original image in the database
> >
> > System.Drawing.Image thumbnail = new System.Drawing.Bitmap(w, h);
> > //generate the thumbnail
> >
> > MemoryStream ms = new MemoryStream();
> > thumbnail.Save(ms);
> > ms.Seek(0, SeekOrigin.Begin);
> >
> > byte[] buffer = new byte[ms.Length];
> > ms.Read(buffer, 0, buffer.Length);
> >
> > Best regards,
> >
> > Sherif ElMetainy
> >
> >
> >
> > "Chris D" <[email protected]> wrote in message
> > news:[email protected]...
> > > I'm doing some work with submitting graphics via ASP.net page to SQL

> 2000
> > > server using VB.
> > >
> > > I know how to get a graphic into the database from a filefield

control.
> I
> > > also know how to pull it out of the database and thumbnail it on the

> fly.
> > >
> > > Creating thumbnail on the fly seems extremely inefficient to me as

this
> > has
> > > to be done every time the image is requested. What I want to do is get

> the
> > > image from the filefield control, thumbnail it and save the thumbnail

to
> > the
> > > database along with the full size image. That way the thumbnail

process
> is
> > > only ran once and I'm not to concerned about the extra storage space.
> > >
> > > What I cant figure out is how to get the image from the
> > > postedfile.imputstream.read to a system.drawing.image to generate the
> > > thumbnail and then send the thumbnail to the database again.
> > >
> > > I'm new to .net so any help is greatly appreciated
> > >
> > > Thanks
> > > Chris D
> > >
> > >

> >
> >

>
>
 

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,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top