Created
January 28, 2022 13:11
-
-
Save jishanshaikh4/1ed821d99a9b3a2d8d8cbc8164d76c62 to your computer and use it in GitHub Desktop.
Generate fake thumbnail for an image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Execute as ./fake_thumbnail.sh hiddenimage.png wantedthumbnail.png output.png | |
high="$1" # High image (full-size original view) | |
low="$2" # Low image (thumbnail) (should be the same size) | |
output="output.png" | |
[ ! -z "$3" ] && output="$3" # Output image | |
size=$(convert "$high" -format "%wx%h" info:) | |
convert "$high" -alpha off +level 3.5%,100% -gamma 20 high_gamma.png | |
low_gamma="-alpha off -gamma 0.8 +level 0%,77%" | |
convert \( "$low" $low_gamma \) high_gamma.png \ | |
-compose Mathematics -define compose:args='0,-0.33,1,0.33' \ | |
-composite low_adjusted.png | |
convert low_adjusted.png high_gamma.png -size $size pattern:gray25 -composite \ | |
-set gamma 0.022727 -define png:include-chunk=none,gAMA "$output" | |
rm high_gamma.png low_adjusted.png |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment