Skip to content

Commit

Permalink
Add new method, bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
PrzemyslawKlys committed Jun 5, 2024
1 parent cd0652f commit 59157eb
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
### 0.0.6 - 2023.12.30
### 0.0.7 - 2024.06.05

- Add another method `$Image.WatermarkImage("$PSScriptRoot\Samples\LogoEvotec.png",50,100, 0.5, 0.5)`

### 0.0.6 - 2023.12.30
- Added new library: Codeuctivity.ImageSharpCompare
- Added Image Compare feature
- Bump dependencies
Expand Down
4 changes: 2 additions & 2 deletions ImagePlayground.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
CmdletsToExport = @()
CompanyName = 'Evotec'
CompatiblePSEditions = @('Desktop', 'Core')
Copyright = '(c) 2011 - 2023 Przemyslaw Klys @ Evotec. All rights reserved.'
Copyright = '(c) 2011 - 2024 Przemyslaw Klys @ Evotec. All rights reserved.'
Description = 'ImagePlayground is a PowerShell module that provides a set of functions for image processing. Among other things it can create QRCodes, BarCodes, Charts, and do image processing that can help with daily tasks.'
DotNetFrameworkVersion = '4.7.2'
FunctionsToExport = @('ConvertTo-Image', 'Get-Image', 'Get-ImageBarCode', 'Get-ImageExif', 'Get-ImageQRCode', 'Merge-Image', 'New-ImageBarCode', 'New-ImageChart', 'New-ImageChartBar', 'New-ImageChartBarOptions', 'New-ImageChartLine', 'New-ImageChartPie', 'New-ImageChartRadial', 'New-ImageQRCode', 'New-ImageQRCodeWiFi', 'New-ImageQRContact', 'Remove-ImageExif', 'Resize-Image', 'Save-Image', 'Set-ImageExif')
GUID = 'ff5469f2-c542-4318-909e-fd054d16821f'
ModuleVersion = '0.0.6'
ModuleVersion = '0.0.7'
PowerShellVersion = '5.1'
PrivateData = @{
PSData = @{
Expand Down
18 changes: 18 additions & 0 deletions Sources/ImagePlayground/Image.Watermark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,23 @@ public void WatermarkImage(string filePath, WatermarkPlacement placement, float
AddImage(image, location, opacity);
}
}

public void WatermarkImage(string filePath, int x, int y, float opacity = 1f, float padding = 18f, int rotate = 0, FlipMode flipMode = FlipMode.None, int watermarkPercentage = 20) {
string fullPath = System.IO.Path.GetFullPath(filePath);

var location = new Point(x, y);
using (var image = SixLabors.ImageSharp.Image.Load(fullPath)) {
var watermarkWidth = _image.Width * watermarkPercentage / 100;
var watermarkHeight = watermarkWidth * image.Height / image.Width;

// rotate watermark
if (rotate == 0) {
image.Mutate(mx => mx.Resize(watermarkWidth, watermarkHeight).Flip(flipMode));
} else {
image.Mutate(mx => mx.Resize(watermarkWidth, watermarkHeight).Flip(flipMode).Rotate(rotate));
}
AddImage(image, location, opacity);
}
}
}
}

0 comments on commit 59157eb

Please sign in to comment.