TUESDAY, DECEMBER 26, 2023
Image Processing For A Digital Comic
My process for creating my books has gotten increasingly more complicated. Currently, I'm using Python (and assorted binaries) to turn 24-bit PNGs into highly-optimized 8-bit PNGs (with file sizes rivaling jpeg and webp). I'm going with PNGs because it's a good format for images that are predominately flat colored, so if your images have a lot of gradients or details, a format like JPEG would work better. The steps are as follows...
- Saving out of Adobe Illustrator as a 24-bit PNG
- Running a Python script on each image where:
- the unnecessary chunks are removed
- the image is quantized using libimagequant (results are better than Adobe's)
- the resulting palette is optimized (palette reduction) by removing similar colors, increasing black and white point contrasts slightly and RGB value averaging. This process is obviously lossy but within tolerances I set
- a hidden watermark is added, which is text from a 5-bit table converted to pixels (looks similar to a QRCode)
- the PNG is recompressed using advPNG (w/zopfli setting @ 50 iterations)
- metadata is injected as tEXt and zTXt chunks into the final png file
- After this, a PHP script builds the CBR digital comic file: