back to index | | home .

emboss on paper effect from image edge

Final Result:

$./ [input_file_or_path]
$output filename: [input_filename-emboss.original_extension]

Fred's script shadowhighlight is not mandatory. Set shlgPath to use different path other than bin or current folder. (Remove for loop to disable checking for the script.)
5 images would been made in /tmp, as I'm not good with cache function yet.
Final result would move to current folder. ie test.png becomes test-emboss.png.
Increase the exposure variable will make change the contrast but grayer color-tone. The brightness and contrast function is not straight foward as gimp.
Image with transparency will replaced by white background in the result. (To keep the alpha channel, comment out the line with mogrify)
*Script below does not support multiple inputs or flags, only basic error check.

#!/usr/bin/env bash  
# usage: ./ input_file  
exposure=10% # bigger value for more contrast, but grayer.  
shlgPath=~/Downloads/shadowhighlight  #'full_path/shadow'  
# check input  
if [ ! -f "$input" ]; then echo "null file;nothing done";exit 1; fi  
filename=$(basename -- "$input")  
ex=".${filename##*.}" #file extension  
# output to current_dir/filename-emboss.original_extension  

fname=(ts t-edge t-edge2 tshb t-whiteEmboss)  
# export files to /tmp/  
ct=-1;for i in {a..e};do ct=$ct+1; eval "$i=/tmp/${fname[$ct]}$ex";done  

## start here  
# check shadowhighligh, in bin, current folder, or $shlgPath.  
for p in $shlg ./$shlg $shlgPath; do  
 if which "$p" >/dev/null; then  
    xp="$p"; echo 'use '$xp  
    $xp -sa 60 -ha 60 -ma 70 $input $a  # sharpen, fred script;  
[ -z $xp ] && a=$input; #if not, skip  
# edge detect  
convert $a -colorspace gray -canny 0x1+10%+30% $b  
# thicker edge  
convert $b \  
          \( -clone 0 -roll +1+0 -clone 0 -compose difference -composite \) \  
          \( -clone 0 -roll +0+1 -clone 0 -compose difference -composite \) \  
          -delete 0  -compose screen -composite $c  
# add blur shadding  
convert $c  -blur 0x2 -shade   90x75   $d  
# emboss like looks  
convert $d $c \  
          -alpha Off -compose CopyOpacity -composite \  
          -evaluate subtract "$exposure" $e  
# if transparent, flatten  
picinfo=$(identify -format '%[channels]\n' $e)  
[[ $picinfo =~ "a" ]] && mogrify -flatten -background white $e;  
# move image to current folder  
mv $e $output; echo "output filename: $output "  

Animation was created by Fred's SplitImage script

./splitimage -m TB -i 10 -r 40 test.jpg test-emboss.jpg polo-card.gif  
in=polo-card.gif; fps=4;  
ffmpeg -i $in -r $fps -c:v libvpx -quality good -b:v 0 -crf 15 \  
 -pix_fmt yuv420p -movflags faststart -tile-columns 2 ${in%.*}.webm  

edge detect:
shade_blur 3rd example (emboss):
Check script exist: if-either, if missing one of them, hash check
fred emboss, bevel