Skip to content

Instantly share code, notes, and snippets.

@polm
Created August 21, 2015 04:17
Show Gist options
  • Save polm/fc6aab8a5aa860991a9c to your computer and use it in GitHub Desktop.
Save polm/fc6aab8a5aa860991a9c to your computer and use it in GitHub Desktop.
Scripts for making photos in to lofi pixel art
#!/bin/bash
# based on cellusion's photoshop method
convert "$1" -resize 256x1000 -colorspace Gray -auto-level \
gradient.png -clut -scale 1000x1000 -posterize 6 "$1".out.png
#!/bin/bash
# based on cellusion's photoshop method
# make the gradient
function gradient-step() {
left=$1
right=$2
width=$(( $3 * 256 ))
convert \( -size 1x1 "xc:$left" "xc:$right" +append \) \
-filter cubic -resize ${width}x1! grad.png
if [ -e gradient.png ]; then
convert gradient.png grad.png +append tmp.png
mv tmp.png gradient.png
rm grad.png
else
mv grad.png gradient.png
fi
}
function finalize-gradient() {
convert gradient.png -resize 256x1! tmp.png
mv tmp.png gradient.png
}
rm -f gradient.png
#gradient-step black orange 30
#gradient-step orange pink 30
#gradient-step pink white 10
#gradient-step white lime 10
#gradient-step black orange 30
#gradient-step orange pink 30
#gradient-step pink white 10
#gradient-step white lime 10
gradient-step black cyan 70
gradient-step cyan white 10
gradient-step white yellow 20
gradient-step yellow maroon1 10
#gradient-step black red 5
#gradient-step red black 2
#gradient-step black maroon1 70
#gradient-step maroon1 white 10
#gradient-step white cyan 15
finalize-gradient
@vegarsti
Copy link

vegarsti commented May 31, 2016

This seems exciting! (I found you through your translation of the Japanese game designer's post, through Hacker News.)
How do you use this? I tried bash gradientify.sh <image>, but I need a gradient.png. Could you provide the one you use? Or am I misunderstanding how to use this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment