Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Image resize 1

Status
Not open for further replies.

maviscruet

Technical User
Apr 2, 2008
2
GB
Hi guys,

In PHP there is a handy little function in PHP:
list($width, $height, $type, $attr) = getimagesize("image_name.jpg");
This will get the image width, height and file type.

Is there any way of getting this information using ASP?

I have no access to the software on the server so cannot install any ancillery software.
I am now desperate to find a solution so any help or advice would be greatly appreciated!
 
There is no image processing native to ASP but if you google around you might come up with a script that someone was nice enough to share.

The file type you could probably guess by using the FSO to examine the filename extension: .JPG .PNG .GIF etc...

As for the width and height those should be discoverable by parsing the image header inside the file but I can say from experience on platforms other than ASP that this can be a pain in the butt to do manually.


The first result in this google search looks promising:ASP parse image file header

Trust me you want to at least start by looking at someone else's code because before you can write your parser you have to learn the header layout of each image format and that is as complicated as it sounds.
 
>Is there any way of getting this information using ASP?
Simplest is to use loadpicture function built-in.
[tt]
set opic=loadpicture(server.mappath("image_name.jpg"))
'in unit of pixel as that of the php built-in function
width=round(opic.width/2540*96)
height=round(opic.height/2540*96)
set opic=nothing
[/tt]
 
I stand corrected.

It looks likes this function has been part of VBScript since version 2.0 .... so almost from the start.


Looking at the following list of VBScript features and the version in which theyt were added, I am sad to admit this was not the only new feature of which I was ignorant.

A
star.gif
for you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top