-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimgInfo.bat
53 lines (40 loc) · 1.36 KB
/
imgInfo.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
@if (@X)==(@Y) @end /* JScript comment
@echo off
rem :: Borrowed and modified from
rem :: https://github.com/npocmaka/batch.scripts/blob/master/hybrids/jscript/imgInfo.bat
rem :: Thank you to Vasil Arnaudov (github/npocmaka) for posting this
rem :: the first argument is the script name as it will be used for proper help message
cscript //E:JScript //nologo "%~f0" %*
exit /b %errorlevel%
@if (@X)==(@Y) @end JScript comment */
FSOObj = new ActiveXObject("Scripting.FileSystemObject");
var ARGS = WScript.Arguments;
if (ARGS.Length < 1 ) {
WScript.Echo("No file passed");
WScript.Echo("Usage:");
WScript.Echo(" Image");
WScript.Quit(1);
}
var filename=ARGS.Item(0);
if (!FSOObj.FileExists(filename)){
WScript.Echo("File "+filename+" does not exists");
WScript.Quit(2);
}
function ID2Format(id){
var ids={};
ids["{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}"]="BPM";
ids["{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}"]="PNG";
ids["{B96B3CB0-0728-11D3-9D7B-0000F81EF32E}"]="GIF";
ids["{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}"]="JPG";
ids["{B96B3CB1-0728-11D3-9D7B-0000F81EF32E}"]="TIFF";
return ids[id];
}
var img=new ActiveXObject("WIA.ImageFile");
try {
img.LoadFile(filename);
}catch(err){
WScript.Echo("Probably "+ filename + " is not an image");
WScript.Echo(err.message);
WScript.Quit(3);
}
WScript.Echo(img.Width+" x "+img.Height);