Table of Contents

Introduction

Name: Ditherpunk

Description: CLI tool to convert images into bit-limited images, utilizing dithering to produce the illusion of more shades.

Repository: https://git.freshair.farm/nathan/dither


Examples

Input:

img

Output:

img


Retrospective

Initial motivation: I wanted to learn how to deal with CLI arguments with Clap, and I also wanted to deal with a problem that would benefit greatly from concurrent processing with Rayon. One way or another, I somehow stumbled upon this post by surma.dev on the topic of Dithering, or sometimes referred to as Ditherpunk.

I looked through what he wrote and thought this would be something fun to try out in Rust.

What I've learned: Dealing with CLI inputs, especially folders, is kind of a pain! In particular, I found it a little hard to figure out when to panic, or when to retry. For example, the desired output folder does not exist. We try to create the folder. It might or might not work. If it doesn't, do we immediately error out? Or do we try again? I chose to go with the safer route, and to panic if it still can't access the folder after it attempts to create it.

What I'd do differently: Strings. I did not have a firm grasp on the different String types available in Rust, and thus it's a really ugly mismash of bad Rust practices.

Next steps: I need to clean up the existing code, especially the output filename generation code. Further, I'd also like to implement a dithering option that would supper N bit colors.