function GetNumberOfPages{[CmdletBinding()]param([Parameter(Mandatory = $true,ValueFromPipeline = $true,ValueFromPipelineByPropertyName = $true)][ValidateNotNullOrEmpty()][String]$TiffImage)if(([appdomain]::currentdomain.getassemblies() | Where {$_ -match "System.Drawing"}) -eq $null)
{
Write-Verbose "Loading System.Drawing assembly.";
[Void] [System.Reflection.Assembly]::LoadFromPartialName("System.Drawing");
}
if($file = [System.Drawing.Bitmap]::FromFile($TiffImage))
{
return $file.GetFrameCount([System.Drawing.Imaging.FrameDimension]::Page)
}
else
{
return -1
}
}
In usage, I go down this road:PSC:somedirectory> Get-ChildItem ‘.Images**** | ForEach-Object {"$($_.Name): $(GetNumberOfPages $_.fullname)"}Which returns as simple list:
test.jpg: 1Simple, but, free. I know it needs a lot of expansion, but, for 10 minutes of Googling and coding I am happy with it. Back to work.
1.tif: 14
2.tif: 3