Print Page | Close Window

ASP picture width

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=7758
Printed Date: 01 April 2026 at 7:19am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: ASP picture width
Posted By: venki
Subject: ASP picture width
Date Posted: 01 December 2003 at 6:23am
Can ASP read picture width and heigh? I need it for upload script, if some one uploaded big picture (not in KB but in size!) to write error to user. I just need a script that will read picture width and heigh.



Replies:
Posted By: michael
Date Posted: 01 December 2003 at 8:08am
You would not be able to determine the picture size until you uploaded the picture using asp as asp is serverside. Now most upload components support a maxwidth property and some even resize it automatically for you. Check the component documentation.

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: venki
Date Posted: 01 December 2003 at 1:43pm
for ex. if I hawe picture uploaded on server can I read its width?


Posted By: pmormr
Date Posted: 01 December 2003 at 4:58pm

you should be able too read the properties off the picture with some type of component



-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/


Posted By: michael
Date Posted: 01 December 2003 at 5:29pm
like I said, what component for uploading are you using? That may make it much easier.

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: theSCIENTIST
Date Posted: 02 December 2003 at 5:16am

What if I don't use any component, like Pure ASPUpload? A file is then saved to a dir.

One can easily get the file size, last mod date and all that, but not the pixel dimension.

How can I get hold of the picture dimenssions?

Thx.



Posted By: cybermaster
Date Posted: 02 December 2003 at 12:30pm

..you shoud do that with javascript...



-------------
http://www.toxiclab.org - Toxiclab.org -webmasters community


Posted By: Mart
Date Posted: 02 December 2003 at 1:02pm

but what if you need it in a variable etc? You either need to use a component or use asp.net and GDI+



Posted By: theSCIENTIST
Date Posted: 03 December 2003 at 1:37am

Can Javascript read width/height pixels out of a file? I though JS can do any operations with the file system.

If this is correct, that JS can do it, than it's easy to get the dimessions to ASP vars, you could fill hidden fileds in a form with the JS values, submit it, and gracefully retrieve it with ASP.

Can you post some code on the JS get picture dimenssion?

Thx.

------------------
EDIT > CORRECTION:
------------------
The above line: "I though JS can do any operations with the file system."
Should be: I though JS can't do any operations with the file system.



Posted By: venki
Date Posted: 07 December 2003 at 2:23pm
Im not using any component instaled on server, Im usinp pure asp, but anyway like theSCIENTIST sayed what if I have a file saved in dir and then read its size and other.. I was thinking of JavaScript before, but its not good, I used to read picture size and store in cookie and then whit asp read cookie but that isnt good.


Posted By: Mart
Date Posted: 07 December 2003 at 2:33pm
If you can use .net this should work:

Dim objBitmap As New System.drawing.Bitmap(server.mapPath("file.jpg"))
Dim width As Integer = objBitmap.Width
Dim height As Integer = objBitmap.Height
objBitmap.dispose()


Posted By: Badaboem
Date Posted: 07 December 2003 at 2:56pm

Originally posted by venki venki wrote:

Im not using any component instaled on server, Im usinp pure asp, but anyway like theSCIENTIST sayed what if I have a file saved in dir and then read its size and other.. I was thinking of JavaScript before, but its not good, I used to read picture size and store in cookie and then whit asp read cookie but that isnt good.

Javascript does work, but it uses the onsubmit method or oncheck etc. It's not supported by netscape and mac browsers (the form will never submit). I'm currently trying to resolve that issue.



Posted By: venki
Date Posted: 09 December 2003 at 5:22am

no, i cant use .net



Posted By: fernan82
Date Posted: 09 December 2003 at 9:03pm
JavaScript can't get the width of the file, it can only get the width of an image displayed on a webpage, if the image is 600 pixels but has a 300 pixels width tag javascript will return 300. It is possible as somebody mentioned to display the image on a webpage without width or height tags, get the pixels with javascript and post them to an ASP page, but that's a lot of hassle.

here's how to do it with ASP:

http://www.4guysfromrolla.com/webtech/050300-1.shtml



-------------
FeRnAN
http://www.danasoft.com/">


Posted By: Necronom
Date Posted: 23 December 2003 at 12:30am

Yes, there is a way :)

You can read the image's height, width, color dimension, and type with ASP. I spent about 3 months putting together a script that will upload, read, and resize proportinatly(sp?) on the fly. It was a bitch, but I got it to work, and it's PURE ASP...no com's...no .net.

Here's the kicker...it's so embedded in my site, that stripping it all out isn't really possible (and I'm trying to figure out a way to market this one...)

If you would like to see an example, go to http://www.BodyMod.org - http://www.BodyMod.org and click into one of the catagories. When you see a thumbnail that says there is no thumbnail, click it. Once inside, you'll see the scaled down image. Click on that to see the original.

If I get some time, I'll try to weed through my source and pull out the important pieces...

. necronom .



Posted By: MorningZ
Date Posted: 23 December 2003 at 9:32am

might want to take a stab with a http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=e3IqWT3BDHA.33548%40TK2MSFTNGP10.phx.gbl&rnum=8&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26q%3Dvbscript%2Bfind%2Bimage%2Bwidth - function like this

i used to have perfectly working code to find height/width, but it was years ago and i cannot find it..... i gotta have it saved on CD somewhere



-------------
Contribute to the working anarchy we fondly call the Internet



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net