473,386 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

determine the pixel resolution of an image file


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
4 2394
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: CoreyMas | last post by:
Hello Again, Here is what I want to do: I have an image that is 100 px by 100 px I want to parse each pixel in said image, and store the color of that pixel in a file (the reasons for...
1
by: james | last post by:
I don't know if this is the right place to show my question. I can't understand why, in the BMP array after the headers, i find some zero that aren't in the real BMP image. This zero are at the end...
4
by: Sharon | last post by:
Hi Everyone, I have a TIF file 62992 x 113386 Pixels, Huffman RLE compression, 3200 x 3200 DPI resolution, binary colored (1 Bit Per Pixel), file on disk size 43.08 MB (45,169,042 Bytes). This...
8
by: **Developer** | last post by:
Seems that Dot.net can not handle files of Indexed Pixel Format as well as other types of formats. Given a file or and Image of type Indexed Pixel Format is there a method to convert it to some...
30
by: Chaos | last post by:
As my first attempt to loop through every pixel of an image, I used for thisY in range(0, thisHeight): for thisX in range(0, thisWidth): #Actions here for Pixel thisX, thisY But it takes...
10
by: Lucas | last post by:
I want to change some pixel value in the picture file. how to do it? If I read the file in binary mode, a bit == a pixel ? Thanks
2
by: ajay_itbhu | last post by:
Hi everyone, I want to read the pixel values of 2 similar images in bitmap format like 2 continuous frame of a video for calculating the median. But i dont know how to read the pixel values of...
1
by: ofiras | last post by:
In bitmap, how can I find the nearest pixel (pixel 1) to a specific pixel (pixel 2) that has different color from pixel 2? Or how can I find a pixel in a specific distance from pixel 2 (like a...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.