Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # none, sierra2, burkes or steinberg look good in dithering
- #Files/args
- inputFile="${1}"
- ditherType="${2:-sierra2}"
- #print usage
- if [ -z "$inputFile" ]; then
- echo "Usage: wpConvert.sh [input] [dither]"
- echo "Dither options: none, bayer, floyd_steinberg, sierra2, sierra2_4a, sierra3, atkinson, burkes"
- exit 1
- fi
- inputBaseName=$(basename "$inputFile")
- inputFileName="${inputBaseName%.*}"
- outputFile="./wplace_${inputFileName}.png"
- #wplace palette as png encoded in base64
- paletteBase64="iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAwFBMVEUAAAAAAAAMgW4PeZ8PuWgQrqYT4b4T5nsoUJ4zOUE8PDxAk+RKQoRKazpNMbhalEpgABhg9/JoRjRrUPZtZD9tdY14DJl4eHh6ccR7Y1J9x/+ExXOH/16UjGuVaCqZsfubUkmchDGchGulDh6qOLmqqqqzudG1rvG7+vLFrTHLAHrNxZ7RgFHRgHjS0tLWtZTbpGPgn/nkXBro1F/sH4DtHCTzjan2qgn4snf53Tv6gHL6tqT/fyf/xaX/+rz///+JnjTCAAAAAXRSTlMAQObYZgAAABtJREFUGJVjYUQDLAKkCjCw8DGgAhaGoSpwEACVZwF8B2PFYwAAAABJRU5ErkJggg=="
- #paletteuse
- ffmpeg -y -i "${inputFile}" \
- -i <(printf '%s' "$paletteBase64" | base64 --decode) \
- -filter_complex "[0:v][1:v] paletteuse=dither=${ditherType}:alpha_threshold=128,format=rgba" \
- -update true "${outputFile}"
Add Comment
Please, Sign In to add comment