Created
February 10, 2015 01:02
-
-
Save vadimkantorov/755adc946aefb1f1cf87 to your computer and use it in GitHub Desktop.
A PowerShell script to acquire an image from a scanner and to save it in PNG
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$deviceManager = new-object -ComObject WIA.DeviceManager | |
$device = $deviceManager.DeviceInfos.Item(1).Connect() | |
$wiaFormatPNG = "{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}" | |
foreach ($item in $device.Items) { | |
$image = $item.Transfer($wiaFormatPNG) | |
} | |
if($image.FormatID -ne $wiaFormatPNG) | |
{ | |
$imageProcess = new-object -ComObject WIA.ImageProcess | |
$imageProcess.Filters.Add($imageProcess.FilterInfos.Item("Convert").FilterID) | |
$imageProcess.Filters.Item(1).Properties.Item("FormatID").Value = $wiaFormatPNG | |
$image = $imageProcess.Apply($image) | |
} | |
$fname = ("{0:D03}_" -f $args[0]) + $args[1] + ".png" | |
$image.SaveFile("$(pwd)/$fname") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment