#!/bin/bash
dir="/posix/path/to/folder"
cd "$dir"
color1 = "#816c51"
color2 = "#5a4a3b"
color3 = "#1c110f"
for file in *.tiff
do
base=${file%*.tif}
convert -unsharp 5 "$base" "$base.ppm"
convert -opaque white -fill white -fuzz 10% "$base.ppm" "${base}_step1.tif"
convert -fuzz 5% -fill "$color1" -opaque "$color1" "${base}_step1.tif" "${base}_step2.tif"
convert -fuzz 1.5% -fill "$color1" -opaque "$color2" "${base}_step2.tif" "${base}_step3.tif"
convert -fuzz 12% -fill "black" -opaque "$color3" "${base}_step3.tif" "${base}_step4.tif"
convert "${base}_step4.tif" "${base}_final.tif"
done
I get a couple of error:
convert: unable to open image ...
convert: missing an image filename
test.sh: line 6: color1: command not found
I’d really appreciate some help! Thanks!
I’m a bit unclear on what this is trying to do (I don’t have much experience with ImageMagick), but from a Bash standpoint, I can tell you that this bit:
does not make sense: it tries to strip off a final
.tif(one F) from a file-name that ends in.tiff(two F’s). You presumably meant either this:(which strips off the final
.tiff) or this:(which finds files ending in
.tif); or, perhaps, this:(which handles both cases).
You also probably want to explicitly check for the case that
"$base"is'*'(which will happen, for example, if you try to use*.tifin a directory that doesn’t contain any files matching that name).