Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # There will be an error messages when running this in VSCode, but all the code below will still work fine.
- # There will be no errors when this script is running directly in ISE or in a PowerShell console instead of VSCode.
- Import-Module -Name "$PSScriptRoot\modules\ImagePlayground" -Verbose
- $error.Exception.LoaderExceptions
- # Save QR code to a PNG file
- New-ImageQRCode -Content 'Test123_Test123_Test123_Test123_Test123_Test123' -FilePath "$PSScriptRoot\QRCode.png" -Verbose
- #$Message = Get-ImageQRCode -FilePath "$PSScriptRoot\QRCode.png"
- # Crop saved QR code image
- # The size of a module is 20 pixels, the tool creates a Quiet Zone of 4x20 pixels. Here we limit the Quiet Zone to 2 modules (40 pixels)
- $Image = Get-Image -FilePath "$PSScriptRoot\QRCode.png"
- Write-Host "Resolution old: $($Image.Width)x$($Image.Width)"
- $Rectangle = [SixLabors.ImageSharp.Rectangle]::new(40, 40, $Image.Width - 80, $Image.Height - 80)
- $Image.Crop($Rectangle)
- Write-Host "Resolution new: $($Image.Width)x$($Image.Width)"
- Save-Image -Image $Image -FilePath "$PSScriptRoot\QRCode_cropped.png"
- # Resize QR code image to 200%
- Write-Host "Resolution old: $($Image.Width)x$($Image.Width)"
- $Image.Resize(200)
- Write-Host "Resolution new: $($Image.Width)x$($Image.Width)"
- Save-Image -Image $Image -FilePath "$PSScriptRoot\QRCode_cropped_resized.png"
- # Remove color halftones that have been introduced during resizing
- #$Image.BlackWhite() # BlackWhite() reduces to 4 instead of 2 unique colors
- $Image.Contrast(100)
- Save-Image -Image $Image -FilePath "$PSScriptRoot\QRCode_cropped_resized_blackwhite.png"
- #Pause
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement