Update copy-image-blurred.ps1 and copy-image-pixelated.ps1

This commit is contained in:
Markus Fleschutz 2023-03-03 12:34:42 +01:00
parent 1e8de9a0c7
commit 4e215f4cd3
2 changed files with 8 additions and 7 deletions

View File

@ -16,28 +16,28 @@
Author: Markus Fleschutz | License: CC0
#>
param([string]$ImageFile = "", [string]$TargetDir = "", [int]$ImageWidth = 1920, [int]$ImageHeight = 1393)
param([string]$ImageFile = "", [string]$TargetDir = "", [int]$ImageWidth = 1920, [int]$ImageHeight = 1393, [int]$Frames = 300)
try {
if ($ImageFile -eq "") { $ImageFile = Read-Host "Enter file path to image file" }
if ($TargetDir -eq "") { $TargetDir = Read-Host "Enter file path to target directory" }
$StopWatch = [system.diagnostics.stopwatch]::startNew()
"⏳ (1/300) Checking image file..."
"⏳ (1/$Frames) Checking image file..."
if (!(Test-Path "$ImageFile" -pathType leaf)) { throw "Can't access image file: $ImageFile" }
$Basename = (Get-Item "$ImageFile").Basename
"⏳ (2/300) Searching for ImageMagick 6..."
"⏳ (2/$Frames) Searching for ImageMagick 6..."
& convert-im6 --version
if ($lastExitCode -ne "0") { throw "Can't execute 'convert-im6' - make sure ImageMagick 6 is installed and available" }
[int]$centerX = $ImageWidth / 2
[int]$centerY = $ImageHeight / 2
[int]$Frames = 300
[int]$x = 0
[float]$increment = $centerX / $Frames
for ($i = 0; $i -lt $Frames; $i++) {
$TargetFile = "$TargetDir/$($Basename)_$($i).jpg"
$FrameNo = '{0:d4}' -f $i
$TargetFile = "$TargetDir/frame_$($FrameNo).jpg"
"⏳ ($i/$Frames) Copying to $TargetFile..."
& convert-im6 -stroke black -strokewidth 9 -fill white -draw "circle $centerX,$centerY $x,$centerY" "$ImageFile" "$TargetFile"
$x += $increment

View File

@ -33,7 +33,8 @@ try {
$Factor = 0.001
for ($i = 0; $i -lt 297; $i++) {
$TargetFile = "$TargetDir/$($Basename)_$($i).jpg"
$FrameNo = '{0:d4}' -f $i
$TargetFile = "$TargetDir/frame_$($FrameNo).jpg"
"⏳ ($($i + 3)/300) Copying to $TargetFile with pixelation factor $Factor..."
$Coeff1 = 100.0 * $Factor
$Coeff2 = 100.0 / $Factor
@ -42,7 +43,7 @@ try {
}
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
"✅ copied $SourceFile to a series of 300 pixelated images in 📂$TargetDir in $Elapsed sec."
"✅ copied $SourceFile to a series of 300 pixelated frames in 📂$TargetDir in $Elapsed sec."
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"