ImageMagick convert scan: Difference between revisions

From WickyWiki
mNo edit summary
mNo edit summary
Line 19: Line 19:
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 "image.jpg" -resize 1500x -quality 85 "./new/image.jpg"
</syntaxhighlight>
</syntaxhighlight>


Line 25: Line 25:
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 "image.jpg" -white-threshold 92% -resize 1500x -quality 80 "(new)image.jpg"
convert "image.jpg" -white-threshold 92% -resize 1500x -quality 80 "./new/image.jpg"
</syntaxhighlight>
</syntaxhighlight>


Line 31: Line 31:
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 "image.jpg" -white-threshold 92% -resize 1500x -quality 80 "(new)image.jpg"
convert "image.jpg" -white-threshold 92% -resize 1500x -quality 80 "./new/image.jpg"
</syntaxhighlight>
</syntaxhighlight>


Line 40: Line 40:


<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
convert "image.jpg" -crop 2x2+4+4@ +repage +adjoin "(new)image.jpg"
convert "image.jpg" -crop 2x2+4+4@ +repage +adjoin "./new/image.jpg"
</syntaxhighlight>
</syntaxhighlight>


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

Revision as of 19:47, 3 April 2017


Compress, using quality

mkdir new
for file in *.jpg
do
 nameext="${file##*/}"
 name="${nameext%.*}"
 ext="${nameext##*.}"
 convert "${file}" -quality 85 "./new/${name}.${ext}"
done

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 "image.jpg" -resize 1500x -quality 85 "./new/image.jpg"

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 "image.jpg" -white-threshold 92% -resize 1500x -quality 80 "./new/image.jpg"

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 "image.jpg" -white-threshold 92% -resize 1500x -quality 80 "./new/image.jpg"

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 "image.jpg" -crop 2x2+4+4@ +repage +adjoin "./new/image.jpg"

Also see