I need to read a graphics file and get the width/height in VBScript (ASP). I found a package called gfxSpex
that seems to be what a lot of people use but the GIFs g
If you have root access to your server I have a COM DLL that uses ExifTool to analyse file information and meta data for any file type and return the results as a JSON string.
Here's an example implementation:
Function file_information(ByVal full_path)
Dim ExifTool : Set ExifTool = Server.CreateObject("ClassicASP.ExifTool")
' If the file isn't found it returns an error string: "Error: the file... couldn't be found"
file_information = ExifTool.FileInfo(full_path)
Set ExifTool = nothing
End Function
Response.Write file_information(Server.MapPath("image.png"))
Output:
[
{
"SourceFile":"C:/inetpub/wwwroot/exiftool/image.png",
"ExifToolVersion":11.57,
"FileName":"image.png",
"Directory":"C:/inetpub/wwwroot/exiftool",
"FileSize":"4.5 MB",
"FileModifyDate":"2019:08:14 15:34:18+01:00",
"FileAccessDate":"2019:08:14 15:34:06+01:00",
"FileCreateDate":"2019:08:14 15:34:17+01:00",
"FilePermissions":"rw-rw-rw-",
"FileType":"PNG",
"FileTypeExtension":"png",
"MIMEType":"image/png",
"ImageWidth":1600,
"ImageHeight":1354,
"BitDepth":8,
"ColorType":"RGB with Alpha",
"Compression":"Deflate/Inflate",
"Filter":"Adaptive",
"Interlace":"Noninterlaced",
"ImageSize":"1600x1354",
"Megapixels":2.2
}
]
The files and installation instructions are available at: https://github.com/as08/ClassicASP.ExifTool
Yes, I'm not sure why the comment was deleted! Basically, it gave me a link to https://docs.microsoft.com/en-us/windows-hardware/drivers/image/wia-image-processing-filter. It's a lot more than I needed but good to know it's there. I just used:
set oIMG = CreateObject("WIA.ImageFile")
oIMG.loadFile(path)
iHeight = oIMG.Height
iWidth = oIMG.Width
set oIMG = nothing
It worked for gif, jpg, and png's. I didn't even need to register it.