ImageMagick convert scan: Difference between revisions
From WickyWiki
mNo edit summary |
|||
| Line 27: | Line 27: | ||
<syntaxhighlight lang=bash> | <syntaxhighlight lang=bash> | ||
#divide picture into quarters with a 4 pixel overlap | #!/bin/bash | ||
convert ' | for file in *.jpg | ||
do | |||
file_name="${file##*/}" | |||
file_path="${file%/*}" | |||
file_basename="${file_name%.*}" | |||
file_ext="${file_name##*.}" | |||
#divide picture into quarters with a 4 pixel overlap | |||
convert '${file}' -crop 2x2+4+4@ +repage +adjoin '${file_basename}_%d.${file_ext}' | |||
done | |||
</syntaxhighlight> | </syntaxhighlight> | ||
= Also see = | = Also see = | ||
* [[ImageMagick tools]] | * [[ImageMagick tools]] | ||
Revision as of 19:17, 3 April 2017
Text document resize and quality
After scanning a document you may want to resize and compress the resulting image. You should scan with a higher resolution so you can have a better-quality lower resolution.
convert '*.jpg' -set filename:f '%t(resized).%e' -resize 1500x -quality 85 '%[filename:f]'
Text document white threshold
The white paper background will probably not end up being white so we add a 'white-threshold'. A lower value will mean more light areas are converted to pure white.
convert '*.jpg' -set filename:f '%t(resized).%e' -white-threshold 92% -resize 1500x -quality 80 '%[filename:f]'
White threshold
The white paper background will probably not end up being white so we add a 'white-threshold'. A lower value will mean more light areas are converted to pure white.
convert '*.jpg' -set filename:f '%t(resized).%e' -white-threshold 92% -resize 1500x -quality 80 '%[filename:f]'
Split up picture
When you scan all your old photos, four at a time, you can use this to divide them up in quarters.
#!/bin/bash
for file in *.jpg
do
file_name="${file##*/}"
file_path="${file%/*}"
file_basename="${file_name%.*}"
file_ext="${file_name##*.}"
#divide picture into quarters with a 4 pixel overlap
convert '${file}' -crop 2x2+4+4@ +repage +adjoin '${file_basename}_%d.${file_ext}'
done