473,395 Members | 1,411 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,395 software developers and data experts.

How to retrieve image size?

Hello,

I need to set dynamically height and width attributes of an image control on
a WebForm. I know how to read the whole image from the hard-drive and use
its height and width properties. I guess it is not efficient as the whole
image needs to be read. I need to retrieve only two parameters: height and
width.

Is it possible to read only the size of image from the hard-drive?

Thanks,
Leszek Taratuta
Nov 18 '05 #1
7 5063
Leszek,

You would need to write a component that read the header of the image file.
If your dealing with large files, many requests, and not a huge server, it
may be something worthwhile doing.

OTOH, the client's machine will automatically size the image once
downloaded, and there isn't a huge overhead in determinging h/w of an image.

Alex Papadimoulis
"Leszek" <ta******@5thbusiness.com> wrote in message
news:ey**************@TK2MSFTNGP09.phx.gbl...
Hello,

I need to set dynamically height and width attributes of an image control on a WebForm. I know how to read the whole image from the hard-drive and use
its height and width properties. I guess it is not efficient as the whole
image needs to be read. I need to retrieve only two parameters: height and
width.

Is it possible to read only the size of image from the hard-drive?

Thanks,
Leszek Taratuta

Nov 18 '05 #2
Alex:

What I am trying to accomplish is to resize the browser window to fit an
image. I need to retrieve the image size on the server side, so I could
generate a JavaScript code (window.open ...) providing proper width and
height of the window.
Is it difficult to write a code for reading just the image header?
I would need such code for .jpg, .gif, and .bmp.

Thanks,
Leszek Taratuta

"Alex Papadimoulis" <alexp-at-halogenstudios.com> wrote in message
news:Ok**************@tk2msftngp13.phx.gbl...
Leszek,

You would need to write a component that read the header of the image file. If your dealing with large files, many requests, and not a huge server, it
may be something worthwhile doing.

OTOH, the client's machine will automatically size the image once
downloaded, and there isn't a huge overhead in determinging h/w of an image.
Alex Papadimoulis
"Leszek" <ta******@5thbusiness.com> wrote in message
news:ey**************@TK2MSFTNGP09.phx.gbl...
Hello,

I need to set dynamically height and width attributes of an image control
on
a WebForm. I know how to read the whole image from the hard-drive and

use its height and width properties. I guess it is not efficient as the whole image needs to be read. I need to retrieve only two parameters: height and width.

Is it possible to read only the size of image from the hard-drive?

Thanks,
Leszek Taratuta


Nov 18 '05 #3
you'll need to find a copy of the file format spec, then read the files
header and parse the info.

I did this a long time ago using VB6 and Gif images.
Greg Jackson
PDX, Oregon
Nov 18 '05 #4
I have such functions in VBScript and classic ASP. I just thought there
would be a standard method somewhere using .NET.

Thanks,
Leszek

"Jaxon" <Gr*************@hotmail.com> wrote in message
news:uO**************@tk2msftngp13.phx.gbl...
you'll need to find a copy of the file format spec, then read the files
header and parse the info.

I did this a long time ago using VB6 and Gif images.
Greg Jackson
PDX, Oregon

Nov 18 '05 #5
Hi Leszek,

Firstly I want to thank Alex and Greg for their great help in this issue. I
agree with them that we need to write our own functions to do what you need
in .NET.

On the other hand, you can send your feedback of our products to Microsoft
directly.

Contact Microsoft
http://register.microsoft.com/mswish/suggestion.asp
"...
Microsoft Wish

Make a product suggestion or feature request. Product enhancement
suggestions can include:
Improvements on existing products
Suggestions for additional features
Ways to make our products easier to use
..."

I hope it helps.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 18 '05 #6
Where do you want to do this? Client or Server. If server then you can use
the .net classes to get the information. Check out the graphic classes.
Don't have access to the doc right now but I have done this. It is simple ,
just create the correct class (the hard part) , one of the constructors
takes the filename as input. Then there are readable properties to find out
most of the details of the image.
"Leszek" <ta******@5thbusiness.com> wrote in message
news:uz**************@TK2MSFTNGP09.phx.gbl...
I have such functions in VBScript and classic ASP. I just thought there
would be a standard method somewhere using .NET.

Thanks,
Leszek

"Jaxon" <Gr*************@hotmail.com> wrote in message
news:uO**************@tk2msftngp13.phx.gbl...
you'll need to find a copy of the file format spec, then read the files
header and parse the info.

I did this a long time ago using VB6 and Gif images.
Greg Jackson
PDX, Oregon


Nov 18 '05 #7
Here is the way I would do it in VB.Net. I am not sure if this is what you
mean by reading the whole file or not.

Dim MyBitmap As New Bitmap(Server.MapPath(".") & "\MyPicture.jpg")
Me.Label1.Text = "The height is " & MyBitmap.Height.ToString & " and the
width is " & MyBitmap.Width.ToString

"Leszek" <ta******@5thbusiness.com> wrote in message
news:ey**************@TK2MSFTNGP09.phx.gbl...
Hello,

I need to set dynamically height and width attributes of an image control on a WebForm. I know how to read the whole image from the hard-drive and use
its height and width properties. I guess it is not efficient as the whole
image needs to be read. I need to retrieve only two parameters: height and
width.

Is it possible to read only the size of image from the hard-drive?

Thanks,
Leszek Taratuta

Nov 18 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

38
by: Shaun McKinnon | last post by:
HI...Here's my problem...I have a popup window that loads when i want it to, but it's not sized properly. I've set the size, but it doesn't seem to work. I've been on 8 different websites to find...
4
by: Kenny | last post by:
I have been trying to write a script that will increase the size of and image when you mouse over it, and decrease it to original size, when you mouse out. After a couple of attempts, this is what...
7
by: Haines Brown | last post by:
I'm in the practice of specifying img width and height in my style definitions, although I usually use the actual size of the image. I'm reworking the style and it would be convenient to leave...
11
by: KarimL | last post by:
Thanks for your advices... but i need to get the Image height because i dynamically resize the height of my webcontrol based on the image height. More i just have the url (relative parth) to the...
3
by: Jim via DotNetMonster.com | last post by:
Hi, I have the location of an image in the database and I'm displaying it with a repeater control. I'd like to add the width and height and I'm not sure what the best way to do it is. I could...
3
by: Anurag | last post by:
Hi, I posted this on other user-groups. Hardly got any responses. Here goes the question: PLATFORM = DB2 UDB 8.2+ on AIX 5.x, DPF Two Topics broadly: (A) I wish to find out a rough...
9
by: klausklausenator | last post by:
Hi all, I have a php-generated webpage with images. My problem is: the Internet Explorer cannot calculate the correct image size. Because of this the images are not cached. So everytime a user...
7
by: finecur | last post by:
I have a <img scr="mypic.jpg"in my html. I would like to display the image by width=200 if the image width is larger than 200. I also would like to display the image by its real width if the image...
1
by: Mirazul Hasan | last post by:
I can store and retrieve image reference or location such as "E:\\New Folder\\Multipurpose\\image\\"+ txtname.Text + txtaccnumber.Text +".JPG"; . But I want to store original image and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.