ImageMagick convert scan: Difference between revisions

From WickyWiki
mNo edit summary
mNo edit summary
 
(12 intermediate revisions by the same user not shown)
Line 2: Line 2:
[[Category:Ubuntu Images]]
[[Category:Ubuntu Images]]
[[Category:201612]]
[[Category:201612]]
= Compress, using quality =
<syntaxhighlight lang=bash>
#!/bin/bash
mkdir new
for file in *.jpg
do
nameext="${file##*/}"
name="${nameext%.*}"
ext="${nameext##*.}"
tofile="./new/${name}.${ext}"
echo "${file} --> ${tofile}"
convert "${file}" -white-threshold 92% -resize 1500x -quality 80 "${tofile}"
done
echo "Press ENTER to continue .."
read
</syntaxhighlight>


= Text document resize and quality =
= 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.
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.
<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
convert '*.jpg' -set filename:f '%t(resized).%e' -resize 1500x -quality 85 '%[filename:f]'
convert "${file}" -resize 1500x -quality 85 "${tofile}"
</syntaxhighlight>
</syntaxhighlight>


= Text document white threshold =
= 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.
<syntaxhighlight lang=bash>
convert '*.jpg' -set filename:f '%t(resized).%e' -white-threshold 92% -resize 1500x -quality 80 '%[filename:f]'
</syntaxhighlight>


= 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.
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.
<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
convert '*.jpg' -set filename:f '%t(resized).%e' -white-threshold 92% -resize 1500x -quality 80 '%[filename:f]'
convert "${file}" -white-threshold 85% -resize 1500x -quality 80 "${tofile}"
</syntaxhighlight>
</syntaxhighlight>


Line 27: Line 41:


<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
#divide picture into quarters with a 4 pixel overlap
convert "${file}" -crop 2x2+4+4@ +repage +adjoin "${tofile}"
convert "*.jpg" -set filename:f '%t(%d)(resized).%e' -crop 2x2+4+4@ +repage +adjoin '%[filename:f]'
</syntaxhighlight>
</syntaxhighlight>


= Also see =
= Also see =
* [[ImageMagick tools]]
* [[ImageMagick tools]]

Latest revision as of 18:11, 29 April 2017


Compress, using quality

#!/bin/bash
mkdir new
for file in *.jpg
do
 nameext="${file##*/}"
 name="${nameext%.*}"
 ext="${nameext##*.}"
 tofile="./new/${name}.${ext}"
 echo "${file} --> ${tofile}"
 convert "${file}" -white-threshold 92% -resize 1500x -quality 80 "${tofile}"
done
echo "Press ENTER to continue .."
read

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 "${file}" -resize 1500x -quality 85 "${tofile}"

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 "${file}" -white-threshold 85% -resize 1500x -quality 80 "${tofile}"

Split up picture

When you scan all your old photos, four at a time, you can use this to divide them up in quarters.

convert "${file}" -crop 2x2+4+4@ +repage +adjoin "${tofile}"

Also see