User Tools

Site Tools


doc:appunti:linux:gimp_batch

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
doc:appunti:linux:gimp_batch [2022/11/23 17:29] – [Call the script from the command line] niccolodoc:appunti:linux:gimp_batch [2022/11/23 17:39] (current) – [Call the script from the command line] niccolo
Line 54: Line 54:
 </code> </code>
  
 +===== Combining Imagemagick and GIMP =====
 +
 +The final recipe works as follow:
 +
 +  * Enlarge the image at 250% with Imagemagick. This proved to be the best choice to enhance the text readability via the erode filter. This is because the erode filter works by adding a single pixel around the dark parts.
 +  * Apply the GIMP erode filter.
 +  * Use Imagemagick to apply the **%%-unsharp%%** filter. Resize to the original size and crop/resize the image to a fixed size, even if the input image is slightly wider or narrower. Force the resolution to 200 dpi ignoring that of the original image.
 +
 +This is the full script, which **receives the filename** to be processed and saves the output file into the **./outdir/** directory:
 +
 +<code bash>
 +#!/bin/bash
 +
 +BASENAME="$(basename "$1")"
 +TMP="tmp.$$.png"
 +
 +convert "$1" -scale '250%' "$TMP"
 +cp -p simple-myerode.scm /home/niccolo/.config/GIMP/2.10/scripts/
 +gimp -i -b "(simple-myerode \"$TMP\" 0 0 0 0 0 0)" -b '(gimp-quit 0)'
 +convert "$TMP" -unsharp '0x3+1.0+0' \
 +    -scale 'x2000' -gravity center -crop '1400:2000' \
 +    -background white -extent '1400x2000' -density 200 -units PixelsPerInch \
 +    -quality 90 \
 +    "./outdir/$BASENAME"
 +rm "$TMP"
 +</code>
  
doc/appunti/linux/gimp_batch.txt · Last modified: 2022/11/23 17:39 by niccolo