Skip to content

Instantly share code, notes, and snippets.

@yutsuku
Created October 1, 2021 22:40
Show Gist options
  • Save yutsuku/152f91d2e68c6402b7e4e114f1083391 to your computer and use it in GitHub Desktop.
Save yutsuku/152f91d2e68c6402b7e4e114f1083391 to your computer and use it in GitHub Desktop.
powershell_autocrop.ps1
# Auto crop images to bounding box using imagemagick
# You can use scoop to install imagemagick => "scoop install imagemagick"
# Change path and file extension!
Get-ChildItem -Recurse -File -Path "E:\images path\" -Include *.png | ForEach-Object {
$Path = Join-Path -Path 'E:\images path\cropped' -ChildPath $_.Name
C:\Users\moh\scoop\apps\imagemagick\current\convert.exe "`"$($_.FullName)`"" -fuzz 5% -trim +repage "`"$Path`""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment