473,725 Members | 2,197 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5088
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******@5thbu siness.com> wrote in message
news:ey******** ******@TK2MSFTN GP09.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******** ******@tk2msftn gp13.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******@5thbu siness.com> wrote in message
news:ey******** ******@TK2MSFTN GP09.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******** ******@tk2msftn gp13.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******@5thbu siness.com> wrote in message
news:uz******** ******@TK2MSFTN GP09.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******** ******@tk2msftn gp13.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.M apPath(".") & "\MyPicture.jpg ")
Me.Label1.Text = "The height is " & MyBitmap.Height .ToString & " and the
width is " & MyBitmap.Width. ToString

"Leszek" <ta******@5thbu siness.com> wrote in message
news:ey******** ******@TK2MSFTN GP09.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
5081
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 out what i'm doing wrong, and so far it seems i'm doing it the right way. Here's my code...any suggestions would be appreciated. <script language="javascript"> <!-- window.open("256fx/index.htm", "", "height=400, width=600"); //-->
4
16212
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 I've come up with. In this example, there are 5 images (0 thru 4) all with a height of 80px. When you mouse over an image, it changes the growingImage variable equal to the number of the image you mouse over, when you mouse out, it sets it to 5,...
7
4474
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 image size unspecified unless I need to change its dispayed size. What, if any, are the reasons why an image size should be specified in a stylesheet if it will be displayed in its actual size? -- Haines Brown
11
2022
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 the image but in design time mode all variables concerning Server or Context ar not set ! ...so I can't use MapPath function to obtain the physical parth of the picture ... So my second question is how to retrieve the physical root path of the...
3
1430
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 add the fields to the database and lookup the size and enter it. I know with .Net there's a way to find out the size but I'm not sure how to go about doing it. This is the repeater control: <ASP:Repeater id="RepeaterMediaName" runat="server"...
3
2351
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 correlation between the size of Used Pages in the database and its backup image size (Have to do some space calculation).
9
1499
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 clicks on some link all the images gets retransfered and the page loads very slow. You can check it if you right-click on an image and select properties. Is there a possibility to send the image and its actual size-information to the browser?
7
8197
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 width is smaller than 200. How can I do it? Thanks, qq
1
1406
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 retrieve not location. How can I write this code? Please, help me.
0
9113
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8097
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6702
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4519
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3221
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2635
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.