Updated some scripts

This commit is contained in:
Markus Fleschutz 2023-03-06 21:29:00 +01:00
parent 87f33e284a
commit 3cd7b2f855
3 changed files with 10 additions and 10 deletions

View File

@ -33,7 +33,7 @@ try {
& ffmpeg -framerate 24 -pattern_type glob -i "$SourcePattern" -c:v libx264 -pix_fmt yuv420p "$TargetFile" & ffmpeg -framerate 24 -pattern_type glob -i "$SourcePattern" -c:v libx264 -pix_fmt yuv420p "$TargetFile"
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
"✅ converted $($Files.Count) image frames to .MP4 video $TargetFile in $Elapsed sec." "✅ converted $($Files.Count) image frames to video $TargetFile in $Elapsed sec."
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -16,7 +16,7 @@
Author: Markus Fleschutz | License: CC0 Author: Markus Fleschutz | License: CC0
#> #>
param([string]$ImageFile = "", [string]$TargetDir = "", [int]$ImageWidth = 1920, [int]$ImageHeight = 1393, [int]$Frames = 300) param([string]$ImageFile = "", [string]$TargetDir = "", [int]$ImageWidth = 1920, [int]$ImageHeight = 1393, [int]$Frames = 600)
try { try {
if ($ImageFile -eq "") { $ImageFile = Read-Host "Enter file path to image file" } if ($ImageFile -eq "") { $ImageFile = Read-Host "Enter file path to image file" }
@ -38,12 +38,12 @@ try {
for ($i = 0; $i -lt $Frames; $i++) { for ($i = 0; $i -lt $Frames; $i++) {
$FrameNo = '{0:d4}' -f $i $FrameNo = '{0:d4}' -f $i
$TargetFile = "$TargetDir/frame_$($FrameNo).jpg" $TargetFile = "$TargetDir/frame_$($FrameNo).jpg"
"⏳ ($i/$Frames) Copying to $TargetFile..." "⏳ ($i/$Frames) Converting with r=$($centerX - $x) to $TargetFile..."
& convert-im6 -stroke black -strokewidth 9 -fill white -draw "circle $centerX,$centerY $x,$centerY" "$ImageFile" "$TargetFile" & convert-im6 -stroke black -strokewidth 9 -fill white -draw "circle $centerX,$centerY $x,$centerY" "$ImageFile" "$TargetFile"
$x += $increment $x += $increment
} }
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
"✅ converted image $ImageFile to $Frames frames in 📂$TargetDir in $Elapsed sec." "✅ converted image $ImageFile to $Frames blurred frames in 📂$TargetDir in $Elapsed sec."
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -16,26 +16,26 @@
Author: Markus Fleschutz | License: CC0 Author: Markus Fleschutz | License: CC0
#> #>
param([string]$SourceFile = "", [string]$TargetDir = "") param([string]$SourceFile = "", [string]$TargetDir = "", [int]$Frames = 700)
try { try {
if ($SourceFile -eq "") { $SourceFile = Read-Host "Enter file path to source image file" } if ($SourceFile -eq "") { $SourceFile = Read-Host "Enter file path to source image file" }
if ($TargetDir -eq "") { $TargetDir = Read-Host "Enter file path to target directory" } if ($TargetDir -eq "") { $TargetDir = Read-Host "Enter file path to target directory" }
$StopWatch = [system.diagnostics.stopwatch]::startNew() $StopWatch = [system.diagnostics.stopwatch]::startNew()
"⏳ (1/300) Checking source image file..." "⏳ (1/$Frames) Checking source image file..."
if (!(Test-Path "$SourceFile" -pathType leaf)) { throw "Can't access source image file: $SourceFile" } if (!(Test-Path "$SourceFile" -pathType leaf)) { throw "Can't access source image file: $SourceFile" }
$Basename = (Get-Item "$SourceFile").Basename $Basename = (Get-Item "$SourceFile").Basename
"⏳ (2/300) Searching for ImageMagick 6 executable..." "⏳ (2/$Frames) Searching for ImageMagick 6 executable..."
& convert-im6 --version & convert-im6 --version
if ($lastExitCode -ne "0") { throw "Can't execute 'convert-im6' - make sure ImageMagick 6 is installed and available" } if ($lastExitCode -ne "0") { throw "Can't execute 'convert-im6' - make sure ImageMagick 6 is installed and available" }
$Factor = 0.001 $Factor = 0.001
for ($i = 0; $i -lt 297; $i++) { for ($i = 0; $i -lt $Frames; $i++) {
$FrameNo = '{0:d4}' -f $i $FrameNo = '{0:d4}' -f $i
$TargetFile = "$TargetDir/frame_$($FrameNo).jpg" $TargetFile = "$TargetDir/frame_$($FrameNo).jpg"
"⏳ ($($i + 3)/300) Copying to $TargetFile with pixelation factor $Factor..." "⏳ ($($i + 3)/$Frames) Converting with pixelation factor $Factor to $TargetFile..."
$Coeff1 = 100.0 * $Factor $Coeff1 = 100.0 * $Factor
$Coeff2 = 100.0 / $Factor $Coeff2 = 100.0 / $Factor
& convert-im6 -scale $Coeff1% -scale $Coeff2% "$SourceFile" "$TargetFile" & convert-im6 -scale $Coeff1% -scale $Coeff2% "$SourceFile" "$TargetFile"
@ -43,7 +43,7 @@ try {
} }
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
"✅ converted image $SourceFile to 300 pixelated frames in 📂$TargetDir in $Elapsed sec." "✅ converted image $SourceFile to $Frames pixelated frames in 📂$TargetDir in $Elapsed sec."
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"