By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,948 Members | 1,595 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,948 IT Pros & Developers. It's quick & easy.

determine the pixel resolution of an image file

P: n/a

I have an asp.net page that is dynamically building a table and populating
cells with images (typically jpeg) and with associated metadata.

How can the asp.net code efficiently determine the pixel resolution from the
image file (without loading the entire image into memory on the server) to
allow it to properly size the table cell and its associated Image control?

Thanks, Bruce
May 22 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Bruce wrote:
I have an asp.net page that is dynamically building a table and populating
cells with images (typically jpeg) and with associated metadata.

How can the asp.net code efficiently determine the pixel resolution from the
image file (without loading the entire image into memory on the server) to
allow it to properly size the table cell and its associated Image control?

Thanks, Bruce


Hi Bruce,
As u have written "image file (without loading the entire image
into memory on the server)" may not be feasible without loading the
image into memory. Because to access the properties of the particular
Image, need to first create an object of the image and then u can access
the properties of that image. And creating an object will always consume
the memory for the object.

Regards,
Sandy
May 22 '06 #2

P: n/a
Hi Bruce,

Thank you for posting!

I think you can use GDI+ to read the metadata from the image file. Here's a
sample:

# Discovering the properties of an image
http://www.bobpowell.net/discoverproperties.htm

Hope this helps.

Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

May 22 '06 #3

P: n/a
Walter,

Thanks for update.

In the example you referenced, he makes this call:
Image img = Image.FromFile(dlg.FileName);

Thus I assume that the entire image file was loaded into memory to prepare
to query the Image object for properties. My question is whether there is
any way to get access to the pixel resulution of the file without loading
the file into memory. (My reason for asking is that it is my understanding
the JPEG files have metadata within the file that can be extracted without
loading the entire file. I dont know if this is true for gif, png, etc.)

According to the earlier post from Sandeep, it sound like the answer is
likely "no". But if anyone else has ideas, I'd appreciate them.

Thanks,
Bruce

"Walter Wang [MSFT]" <wa****@online.microsoft.com> wrote in message
news:jX**************@TK2MSFTNGXA01.phx.gbl...
Hi Bruce,

Thank you for posting!

I think you can use GDI+ to read the metadata from the image file. Here's
a
sample:

# Discovering the properties of an image
http://www.bobpowell.net/discoverproperties.htm

Hope this helps.

Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.

May 22 '06 #4

P: n/a
Hi Bruce,

Thank you for your update.

Yes, you are correct here that GDI+ will load the entire image, since you
need to create the object before you can query its properties.

For JPEG file types, if you know that the files are formatted (which is
publicly documented, but the specification is not owned by Microsoft), you
should be able to read the image dimension information from the file
without having to read in the entire file.

Another thought on this issue would be: since image files normally don't
change frequently, you might be able to save their dimension information
separately. Thus only needing to load the image files once.

Hope this helps.

Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

May 24 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.