PowerShell dot net example

Discussions about image processing and document imaging.
Post Reply
Allanxxx
Posts: 7
Joined: Tue Jan 22, 2008 6:21 am

PowerShell dot net example

Post by Allanxxx » Mon Mar 25, 2019 7:23 am

Hi I'm learning dot net and I was trying to test a simple PowerShell Script to draw something on a TIF. I don't get any error messages but the image is only copied and not modified.
Here's my code:

add-type -Path "C:\users\allan\desktop\GdPicture.NET.10.dll"
$GB = [GdPicture10.GdPictureImaging]::new()
$GB.SetLicenseNumber("000000000000000000000000")


$TIF = "C:\users\Allann\Desktop\x.tif"
$OUTFILE = "C:\users\Allan\Desktop\xxxxxxxxxxxxxxxxxxx.tif"

[int]$IMG
$IMG = $GB.CreateGdPictureImageFromFile($TIF)

$smting = $GB.ARGB(0,0,0,0)

$GB.DrawFilledRectangle($IMG,30,30,30,50,$SMTING,$True)
$GB.DrawText($IMG,"IT WORKED",10,100,22,0,$smting,"ARIAL",$true)

$GB.SaveAsTIFF($IMG,$OUTFILE,4)
-------------------------------------------------------------------------------------------------
I'm want to purchase the license. Could you also tell me which solution I need buy to use just the GD.....dll for writing on JPG and Tif images.

Thanks

Gabriela
Posts: 436
Joined: Wed Nov 22, 2017 9:52 am

Re: PowerShell dot net example

Post by Gabriela » Mon Mar 25, 2019 9:37 am

Hello,

I would suggest trying the current version of the toolkit for the evaluation period for free:
https://www.gdpicture.com/download-gdpicture/
Here is the comparison matrix for features you may find useful:
https://www.gdpicture.com/products/dotn ... on-matrix/

If you encounter any issue with the current release, please let us know. I can say you nothing about why your code does not work on version 10, as we do not support older versions. If your issue persists with the current release, please send us a code snippet and a related document, so we can investigate further. Fo purchasing the license, please contact the sales department for more details.

Allanxxx
Posts: 7
Joined: Tue Jan 22, 2008 6:21 am

Re: PowerShell dot net example

Post by Allanxxx » Mon Mar 25, 2019 11:33 pm

Thanks for the quick response Gabriela,
I downloaded and applied GdPicture.net.14.dll with the temporary license key and the image is still not modified. Maybe I'm not saving it correctly or specifying the correct functions (even though I am not getting any errors). All it does is create a new image file with no changes
I'm trying:
----------------------------------------------------------
[int]$IMG
$IMG = $GB.CreateGdPictureImageFromFile($TIF)
$smting = $GB.ARGB(0,0,0,0)

$GB.DrawFilledRectangle($IMG,30,30,30,50,$SMTING,$True)
$GB.DrawText($IMG,"IT WORKED",10,100,22,0,$smting,"ARIAL",$true)

$GB.SaveAsTIFF($IMG,$OUTFILE,4)
----------------------------------------------------------
Windows 10 pro
standard JPG and TIF images

Thanks,
Allan

Gabriela
Posts: 436
Joined: Wed Nov 22, 2017 9:52 am

Re: PowerShell dot net example

Post by Gabriela » Tue Mar 26, 2019 1:28 pm

Hello, Allan,

Here is the code snippet I have used on empty jpeg file with the current release.

Code: Select all

using (GdPictureImaging image = new GdPictureImaging())
{
    int imageID = image.CreateGdPictureImageFromFile("");
    if (image.GetStat() == GdPictureStatus.OK)
    {
        if ((image.DrawFilledRectangle(imageID, 30, 30, 30, 50, Color.Blue, true) == GdPictureStatus.OK) &&
            (image.DrawText(imageID, "IT WORKED", 10, 100, 22, 0, Color.Red, "ARIAL", true) == GdPictureStatus.OK))
        {
            if (image.SaveAsTIFF(imageID, "drawed_rect.tiff", TiffCompression.TiffCompressionAUTO) == GdPictureStatus.OK)
                MessageBox.Show("Done!");
            else
                MessageBox.Show("Error!");
        }
    }
    image.ReleaseGdPictureImage(imageID);
}
Please see the attached resulting TIFF file. So I can confirm there is no issue in the toolkit with this code snippet.
Attachments
drawed_rect.tiff
drawed_rect.tiff (7.5 KiB) Viewed 9424 times

Allanxxx
Posts: 7
Joined: Tue Jan 22, 2008 6:21 am

Re: PowerShell dot net example

Post by Allanxxx » Wed Mar 27, 2019 9:08 pm

Thanks Gabriela, it worked! :) .

Here is the code for powershell to change a Tiff image:
-------------------------------------------------------------------------------------------------------------------------------
add-type -Path "C:\users\allan martin\desktop\GdPicture.NET.14.dll"
$GB = [GdPicture14.GdPictureImaging]::new()
$L = [GdPicture14.LicenseManager]::new()
$L.RegisterKEY("*REDACTED*")

$TIF = "C:\users\Allan Martin\Desktop\Infile.tif"
$OUTFILE = "C:\users\Allan Martin\Desktop\Outfile.tif"

[int]$IMG
$IMG = $GB.CreateGdPictureImageFromFile($TIF)

$smting = $GB.ARGB(255,255,255,255) #Chang to white
$GB.DrawFilledRectangle($IMG,30,30,30,50,$SMTING,$True)
$GB.DrawText($IMG,"Tell Gabriela it worked",10,100,22,0,$smting,"ARIAL",$true)

$GB.SaveAsTIFF($IMG, $Outfile,4)
-----------------------------------------------------------------------------------------------------------------------------

Gabriela
Posts: 436
Joined: Wed Nov 22, 2017 9:52 am

Re: PowerShell dot net example

Post by Gabriela » Thu Mar 28, 2019 11:06 am

Hello,

I'm happy to hear that. Enjoy! :)

Post Reply

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot] and 1 guest