Reputation: 101
I need to open an image file with Paint.Net and then perform a Save As. Along with choosing a file type to save as, it would be great to set the image DPI and convert any CMYK images to RGB. Instead of doing this manually for thousands of images, I'm attempting to automate the process with PowerShell, taking advantage of its ability to control .NET programs. I'd like to accomplish this with the new PowerShell Core, but I'm okay with having to use PS 5 if necessary. My Paint.Net version is 4.1.6
My research leads me to believe I first need to load the assemblies in PowerShell. I've tried to accomplish this with variations of [Reflection.Assembly]. The code runs successfully, but I'm not sure if I'm doing it correctly because I can't seem to create a new object using my newly loaded assembly.
Here are two example lines of code that I've used to load the assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\paint.net\PaintDotNet.Base.dll")
[System.Reflection.Assembly]::LoadFrom("C:\Program Files\paint.net\PaintDotNet.Base.dll")
Afterwards, I believe I need to create a new object using my new assembly:
$tempImage = New-Object PaintDotNet.Base.Bitmap 'C:\Users\jf060898\Pictures\img1.jpg'
When I attempt to create the object, I get the following error: "New-Object : Cannot find type [PaintDotNet.Base.Bitmap]: verify that the assembly containing this type is loaded." However, when I list the assemblies, I see my Paint.Net:
Name Version Culture PublicKeyToken
PaintDotNet.Base 4.106.7016.38074 neutral null
Upvotes: 1
Views: 989