Elijah's Blog

Converting jpeg to png with Golang

A project I’m working on called “Comix” deals with comic images, and they’re not always the same format. To help keep the code consistent, I decided to always work with PNGs. When downloading the comic image, this means converting other image formats to PNG. Luckily with Golang, this can be accomplished in about 20 lines of code.

This handles all the transcoding in memory thanks to bytes.Buffer.

Full program code here: https://github.com/tizz98/comix