Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the detail informations from a .png file in PowerShell

Tags:

powershell

png

How can I get the detail informations from a specific .png file in PowerShell?
Like dimensions, bit depth and size.

like image 612
Etienne Avatar asked Mar 04 '12 04:03

Etienne


People also ask

How do I get data from a file in PowerShell?

When you want to read the entire contents of a text file, the easiest way is to use the built-in Get-Content function. When you execute this command, the contents of this file will be displayed in your command prompt or the PowerShell ISE screen, depending on where you execute it.

How do I print the contents of a file in PowerShell?

Once you have saved the script, go to the output pane and run the script, as shown in the image below. Note, the PowerShell cmdlet for print is “Out-Printer“. The “Out-Printer” cmdlet of the PowerShell will only send data to your printer. Now, we will move towards printing a file using this “cmdlet“.

How do I open a PNG file in PowerShell?

You can use the Start-Process (or its start alias) command. It will open your image with the default application set to open png files (or ask you to choose one if no default image viewer is set).


1 Answers

  • You might want to use the PowershellPack Module which contains get-image:

    PS D:\> import-module psimagetools
    PS D:\> get-item .\fig410.png | get-image
    FullName              : D:\fig410.png
    FormatID              : {B96B3CAF-0728-11D3-9D7B-0000F81EF32E}
    FileExtension         : png
    FileData              : System.__ComObject
    ARGBData              : System.__ComObject
    Height                : 450
    Width                 : 700
    HorizontalResolution  : 96,0119934082031
    VerticalResolution    : 96,0119934082031
    PixelDepth            : 32
    IsIndexedPixelFormat  : False
    IsAlphaPixelFormat    : True
    IsExtendedPixelFormat : False
    IsAnimated            : False
    FrameCount            : 1
    ActiveFrame           : 1
    Properties            : System.__ComObject
    
  • or you could use Wia.ImageFile directly (which is how the get-image function does it) this way:

    PS D:\> $image  = New-Object -ComObject Wia.ImageFile
    PS D:\> $image.loadfile("D:\fig410.png")
    PS D:\> $image
    
    FormatID              : {B96B3CAF-0728-11D3-9D7B-0000F81EF32E}
    FileExtension         : png
    FileData              : System.__ComObject
    ARGBData              : System.__ComObject
    Height                : 450
    Width                 : 700
    HorizontalResolution  : 96,0119934082031
    VerticalResolution    : 96,0119934082031
    PixelDepth            : 32
    IsIndexedPixelFormat  : False
    IsAlphaPixelFormat    : True
    IsExtendedPixelFormat : False
    IsAnimated            : False
    FrameCount            : 1
    ActiveFrame           : 1
    Properties            : System.__ComObject
    
like image 118
jon Z Avatar answered Sep 24 '22 14:09

jon Z