Skip to content

Instantly share code, notes, and snippets.

@cimmwolf
Created April 24, 2015 11:50
Show Gist options
  • Save cimmwolf/0f660d4d160ff3159714 to your computer and use it in GitHub Desktop.
Save cimmwolf/0f660d4d160ff3159714 to your computer and use it in GitHub Desktop.
[EN] Bash-script which can trim images with noise or artifacts. Requires ImageMagick. [RU] Bash-скрипт, который может обрезать пустые края у изображений даже при наличии на них шума и небольших артефактов. Требуется ImageMagick
#!/bin/bash
### setting
blur="0x15"
fuzz="15%"
nof=`ls -l *.jpg | wc -l`
i=1
echo -n " start trimming..."
for f in *.jpg
do
trim=`convert "$f" -virtual-pixel edge -blur "$blur" -fuzz "$fuzz" -trim -format '%wx%h%O' info:`
convert "$f" -crop "$trim" +repage "$f"
echo -ne \\r" complete: $i/$nof ($f)"
((i++))
done
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment