Working with image.

  • Thread starter Thread starter Jensen bredal
  • Start date Start date
J

Jensen bredal

Hello gurus

I need to upload to accept image upload on my site. I also need to display
these images in a databound control.

The image are upload in a database.

My concers are:

-How do i enforce size limit on image?(which size is acceptable?)
I'm thinking of using a custum validator and validate the image for a
certain size.

Any comment will be higly appreciated.


Many thanks in advance
 
When you say "size", do you mean the width and height, or the phsyical file
size?
 
Well that were i'm very confused. I thought there was
a linear relation between the two parameter you mentioned.
But my knowledge is really weak in this area.
Assume the size is 3000000 bytes and the type is"filetype /JPEG". Does this
relate
to a unique (width , heigt) pair?

I assume a 50 k maximum size should be allowable.
What does it correspong to in terme of size(bytes)?

Does this depend on weather "JPEG" or "GIF"?
 
I don't know much about image processing and formats, but the physical file
size has no relationship to the width/height of am image. Image formats
contain extra information such as color indexes or extra metadata that adds
additional information. In addition, most web formats allow for loosy
compress which mean that some information is lost. Different files can have
different compression thresholds.

If you wanted to limit the upload size (in bytes) there is a size limit that
you can impose on ASP.NET so that huge files are not uploaded. This is
something that can be set in the web.config or machine.config. If you want
to limit the width/height of an image, you will need to look at the contents
of the file. If you know the format, the less processor intensive method
might be to open the uploaded file in a stream and locate the appropriate
bytes that identify this information. If you do not know the format well,
you can always load the stream into an Image object and use the
methods/properties available.
 
Well that was great help.

Thank you....




Peter Rilling said:
I don't know much about image processing and formats, but the physical file
size has no relationship to the width/height of am image. Image formats
contain extra information such as color indexes or extra metadata that adds
additional information. In addition, most web formats allow for loosy
compress which mean that some information is lost. Different files can have
different compression thresholds.

If you wanted to limit the upload size (in bytes) there is a size limit that
you can impose on ASP.NET so that huge files are not uploaded. This is
something that can be set in the web.config or machine.config. If you want
to limit the width/height of an image, you will need to look at the contents
of the file. If you know the format, the less processor intensive method
might be to open the uploaded file in a stream and locate the appropriate
bytes that identify this information. If you do not know the format well,
you can always load the stream into an Image object and use the
methods/properties available.
 
Checkout this C# Code. Easy to convert to VB if requied

http://www.aspheute.com/english/20001130.as

If you need to resize the image then follow this
There is a Ratio for each image. Suppose they are 800 X 600 then you divide 800 by 600 to get a ratio of 1.3. The only difference is first check which of this is greater & always divide the greater by the smaller value. If you find that the height is greater then reduce the height maybe say 100 px and then reducde the width by this Ratio.

This tip is because you are trying to povide a list to the user. Thumbnails should be easier for your Server to handle

Regards

Trevor Benedict
MCSD
 
Well those pieces of code really rock.
That was a major help i must admit...

Thank you to you all.





Trevor Benedict R said:
Checkout this C# Code. Easy to convert to VB if requied.

http://www.aspheute.com/english/20001130.asp

If you need to resize the image then follow this.
There is a Ratio for each image. Suppose they are 800 X 600 then you
divide 800 by 600 to get a ratio of 1.3. The only difference is first check
which of this is greater & always divide the greater by the smaller value.
If you find that the height is greater then reduce the height maybe say 100
px and then reducde the width by this Ratio.
This tip is because you are trying to povide a list to the user.
Thumbnails should be easier for your Server to handle.
 
Back
Top