File - Forum

Forum Navigation
Climate strike banner
You need to log in to create posts and topics.

File

Hello, NeoWiners!

How can I do, for example in vbs to recover width and height of an image file?

I can not find anything on the Web...

Thanks in advance.

GetObjectInfo "mypicture" "Width" "[w]"
GetObjectInfo "mypicture" "Height" "[h]"

Thank guy !

But that is for the picture object.

I would like for the (Windows) file.

Hello,

I you would consider to use a plugin you may have a look at hpwImage:

Command:

hpwImageSize  "[PubDir][TextEntry13]" "[XSize]" "[YSize]"

Regards

Hans-Peter

Feli:

But that is for the picture object.
I would like for the (Windows) file.

Try ...

GetObjectInfo "object name" "ImageWidth" "variable"
GetObjectInfo "object name" "ImageHeight" "variable"

... if you don't want your user to see this image, just place "object name" in an "off screen location"

 

If you absolutely need to do it without loading the file, this webpage ...http://computer-programming-forum.com/59-vbscript/75000bd4d75d412d.htm ... has a vbs script to do it ...

Dim ImageArray 
Dim ThisImage 
ThisImage = "full or relative path to your image" 
ImageArray = Dimensions(ThisImage) 
MsgBox "The image dimensions are width: " & ImageArray(0) &_ 
  "  height: " & ImageArray(1),0,ThisImage 
wscript.quit 
Function Dimensions(strPicturePath) 
dim picture    'Documentation for the picture object is hard to find. 
On Error Resume Next 
Set Picture = LoadPicture(strPicturePath) 
If Err <> 0 Then 
 Dimensions = Array(0,0) 
Else 
 Dimensions = Array(Round(Picture.Width / 26.5),_ 
  Round(Picture.Height / 26.5)) 
End If 
End Function

... I have not verified that it works.

Oh my god !

So much time to look for a small line of script.

Thank you very much you are the best !