Page 1 of 1
Image Dimension ??
Posted: 01 May 2009 13:52
by spam_killer
Is there any trick or command line to get the dimension of an image such as jpg or gif using CMD command..
I search this forum for any topic related to the problem but I can't find any solution.. Also search in google but still no result..
If there is not possible to get image dimension from command line, can anyone suggest any software available on the internet?
Thanks..!!
Posted: 04 May 2009 10:17
by jaffamuffin
ImageMagick is a fantastic command line program and will give you thousands of operations possible on images.
But "identify image.jpg" should out put the required info, just use a for loop to extract the required values.
Also, XP has built in functionally (like how explorer can give you details of the file size in details view)
Possibly using the post below about dll integration it may be possible, or using a bit of vba. there is a post on the imagemagick forums about this but I can't find it just now, complete with vba code.
Re: Image Dimension ??
Posted: 26 Jan 2015 08:42
by npocmaka_
tooltipInfo.bat:
Code: Select all
@if (@X)==(@Y) @end /* JScript comment
@echo off
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.Quit(1);
}
var filename=ARGS.Item(0);
var objShell=new ActiveXObject("Shell.Application");
/////
//fso
ExistsItem = function (path) {
return FSOObj.FolderExists(path)||FSOObj.FileExists(path);
}
getFullPath = function (path) {
return FSOObj.GetAbsolutePathName(path);
}
//
//paths
getParent = function(path){
var splitted=path.split("\\");
var result="";
for (var s=0;s<splitted.length-1;s++){
if (s==0) {
result=splitted[s];
} else {
result=result+"\\"+splitted[s];
}
}
return result;
}
getName = function(path){
var splitted=path.split("\\");
return splitted[splitted.length-1];
}
//
function main(){
if (!ExistsItem(filename)) {
WScript.Echo(filename + " does not exist");
WScript.Quit(2);
}
var fullFilename=getFullPath(filename);
var namespace=getParent(fullFilename);
var name=getName(fullFilename);
var objFolder=objShell.NameSpace(namespace);
var objItem=objFolder.ParseName(name);
//https://msdn.microsoft.com/en-us/library/windows/desktop/bb787870(v=vs.85).aspx
WScript.Echo(fullFilename + " : ");
WScript.Echo(objFolder.GetDetailsOf(objItem,-1));
}
main();
It accepts single argument - the file and prints it's toop tip info.Used against picture:
C:\Capture.PNG :
Item type: PNG image
Dimensions: ?871 x 836?
Size: 63.8 KB
For binaries it will print their version, for media files their length and etc.
Re: Image Dimension ??
Posted: 25 Apr 2015 03:18
by npocmaka_
Another way - with
WIA.ImageFile object:
Code: Select all
@if (@X)==(@Y) @end /* JScript comment
@echo off
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);
}
try {
var img=new ActiveXObject("WIA.ImageFile");
}catch(err){
WScript.Echo("Probably "+ filename + " is not an image");
WScript.Echo(err.message);
WScript.Quit(3);
}
img.LoadFile(filename);
WScript.Echo("Height:"+img.Height);
WScript.Echo("Width:"+img.Width);
WScript.Echo("HorizontalResolution:"+img.HorizontalResolution);
WScript.Echo("VerticalResolution:"+img.VerticalResolution);
WScript.Echo("Format:"+img.FormatID);
WScript.Echo("ActiveFrame:"+img.ActiveFrame);
WScript.Echo("Type:"+img.FileExtension);
WScript.Echo("FrameCount:"+img.FrameCount);
WScript.Echo("IsAnimated:"+img.IsAnimated);
WScript.Echo("PixelDepth:"+img.PixelDepth);
WScript.Echo("IsExtendedPixelFormat:"+img.IsExtendedPixelFormat);
WScript.Echo("IsAlphaPixelFormat:"+img.IsAlphaPixelFormat);
With Wia.ImageProcess is possible to edit pictures -
Code: Select all
https://msdn.microsoft.com/en-us/library/windows/desktop/ms630826(v=vs.85).aspx#SharedSample007
https://msdn.microsoft.com/en-us/library/windows/desktop/ms630819(v=vs.85).aspx
Re: Image Dimension ??
Posted: 25 Apr 2015 06:57
by foxidrive
I'm curious what the resolution figures represent....
Height:769
Width:1066
HorizontalResolution:143.9925994873047
VerticalResolution:143.9925994873047
Format:{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}
ActiveFrame:1
Type:png
FrameCount:1
IsAnimated:false
PixelDepth:24
IsExtendedPixelFormat:false
IsAlphaPixelFormat:false
Re: Image Dimension ??
Posted: 25 Apr 2015 07:23
by npocmaka_
Code: Select all
https://msdn.microsoft.com/en-us/library/windows/desktop/ms630506%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396
pixels per inch/dpi. I prefer pixels...