program works but ineffective on sample data. Assembling new sample data...
This commit is contained in:
parent
ac03d27c62
commit
16bc87b419
71
Process-Images.ps1
Normal file
71
Process-Images.ps1
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
# Script to find, process, and anaylze the results of processing.
|
||||||
|
|
||||||
|
# eventually make this folder select.
|
||||||
|
$ImagePathToProcess = "C:\Users\eeckert\Downloads\Test Photos\Unmodified"
|
||||||
|
$ArchivePathBase = "\\192.168.24.15\OriginalPhotos\TestPath"
|
||||||
|
$ImageOutputPath = "C:\Users\eeckert\Downloads\Test Photos\AfterImageMagick - Pass 1"
|
||||||
|
$depth = 15 # how many folders down do we go.
|
||||||
|
$Reduction_Percentage = '25%'
|
||||||
|
|
||||||
|
$Logging = @()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (!($ImagePathToProcess)) {
|
||||||
|
# If this path doesn't exist, then error out. Erik's a fool and has been burned by this before.
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
# do stuff!
|
||||||
|
|
||||||
|
# get file list - image formats only
|
||||||
|
|
||||||
|
$imagefiles = get-childitem $imagePathToProcess -Recurse -Depth $depth -Include ('*.jpg','*.png','*.bmp')
|
||||||
|
|
||||||
|
foreach ($image in $imagefiles) {
|
||||||
|
$copyResult = $null
|
||||||
|
|
||||||
|
# Set Paths
|
||||||
|
$SourcePath = $image.FullName
|
||||||
|
$SourceSize = $image.Length
|
||||||
|
|
||||||
|
|
||||||
|
$ArchivePathDest = $SourcePath.Replace($ImagePathToProcess,"") # strip sourcepath
|
||||||
|
$ArchivePath = $ArchivePathBase + $ArchivePathDest
|
||||||
|
$ArchivePath_Parent = Split-Path -Parent $ArchivePath
|
||||||
|
|
||||||
|
New-Item -Path $ArchivePath_Parent -ItemType Directory -Force
|
||||||
|
$copyresult = Copy-Item $SourcePath $ArchivePath -Force
|
||||||
|
|
||||||
|
if (!($copyresult)) {
|
||||||
|
$copyresult_Dest = $null
|
||||||
|
$actualDest_file = $ImageOutputPath + $SourcePath.Replace($ImagePathToProcess,"") # strip sourcepath
|
||||||
|
$actualDest_Parent = Split-Path -Parent $actualDest_file
|
||||||
|
|
||||||
|
New-Item -Path $actualDest_Parent -ItemType Directory -Force
|
||||||
|
$copyresult_Dest = Copy-Item $SourcePath $actualDest_file -Force
|
||||||
|
|
||||||
|
if (!($copyresult_Dest)) {
|
||||||
|
# if no error Assemble the imagemagick command line
|
||||||
|
$command = "magick"
|
||||||
|
$commandArgs = "mogrify `"$actualDest_file`" -resize $Reduction_Percentage"
|
||||||
|
|
||||||
|
Start-Process $command -ArgumentList $commandArgs -wait
|
||||||
|
|
||||||
|
$NewImage = get-item -path $actualDest_file
|
||||||
|
|
||||||
|
$NewSize = $NewImage.Length
|
||||||
|
|
||||||
|
$Logging += [PSCustomObject]@{
|
||||||
|
FileName = $SourcePath
|
||||||
|
'Original Size' = $SourceSize
|
||||||
|
'New Size' = $NewSize
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,3 +1,8 @@
|
|||||||
# ImageResizeAndArchive
|
# ImageResizeAndArchive
|
||||||
|
|
||||||
Project to update all photos on Egnyte to lower resoluiton, 72DPI photos. Original to be stored in $ArchiveLocation.
|
## Project to update all photos on Egnyte to lower resoluiton, 72DPI photos. Original to be stored in $ArchiveLocation.
|
||||||
|
|
||||||
|
$ImagePathToProcess = Location of files to process - including subfolders.
|
||||||
|
$ArchivePathBase = Location to store Archived His Res Photos
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user