# GIF or PNG Creation/Encoding Library?

**URL:** https://forum.ada-lang.io/t/gif-or-png-creation-encoding-library/971
**Category:** General
**Created:** [July 8, 2024, 5:59am UTC](https://forum.ada-lang.io/t/gif-or-png-creation-encoding-library/971 "2024-07-08T05:59:08Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![SMerrony](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/smerrony/32/410_2.png) [@SMerrony](https://forum.ada-lang.io/u/SMerrony)
#### Post date: [July 8, 2024, 5:59am UTC](https://forum.ada-lang.io/t/gif-or-png-creation-encoding-library/971/1 "2024-07-08T05:59:08Z")

</div>

Does anyone know of a library or binding for creating/encoding either GIF or PNG images in Ada?

---

<div class="post-metadata">

### Author: ![bracke](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/bracke/32/19_2.png) [@bracke](https://forum.ada-lang.io/u/bracke)
#### Post date: [July 8, 2024, 7:03am UTC](https://forum.ada-lang.io/t/gif-or-png-creation-encoding-library/971/2 "2024-07-08T07:03:01Z")

</div>

I found the following, don’t know anything about it:

> **[GitHub - riccardo-bernardini/pngada: Ada binding for libpng (basic, at the...](https://github.com/riccardo-bernardini/pngada)**
>
> Ada binding for libpng (basic, at the moment). Contribute to riccardo-bernardini/pngada development by creating an account on GitHub.

---

<div class="post-metadata">

### Author: ![cantanima](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/cantanima/32/121_2.png) [@cantanima](https://forum.ada-lang.io/u/cantanima)
#### Post date: [July 8, 2024, 3:53pm UTC](https://forum.ada-lang.io/t/gif-or-png-creation-encoding-library/971/3 "2024-07-08T15:53:00Z")

</div>

@zertovitch has gid on alire, a crate that decodes images and possibly encodes animated gifs (I say that based on a blog post of his) but there’s no documentation and my quick scan of the code didn’t reveal encoders.

Does it have to be GIF or PNG? I am working on a library crate for [PNM](https://en.wikipedia.org/wiki/Netpbm#File_formats) at the moment. It’s nowhere near ready, and nowhere near efficient, but PNM’s can be converted to GIFs with an external program. Eventually I wanted to add GIF and/or PNG.

---

<div class="post-metadata">

### Author: ![zertovitch](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/zertovitch/32/90_2.png) [@zertovitch](https://forum.ada-lang.io/u/zertovitch)
#### Post date: [July 8, 2024, 5:34pm UTC](https://forum.ada-lang.io/t/gif-or-png-creation-encoding-library/971/4 "2024-07-08T17:34:51Z")

</div>

Other than the already mentioned **PNG** binding, there is also this:

> **[PNG\_IO](https://sourceforge.net/projects/png-io/)**
>
> Download PNG\_IO for free. An Ada 2012 library for reading and writing PNG image files. PNG\_IO is an Ada2012 coder/decoder for Portable Network Graphics, allowing Ada2012 programs to read and write PNG files. It is portable across machines and...

With **GIF** you are limited to 256 colours; usually the result is not so nice…  
You can also have a look at **QOI**.  
There is an Ada encoder & decoder for it @

> **[GitHub - Fabien-Chouteau/qoi-spark: “Quite OK Image” Ada implementation](https://github.com/Fabien-Chouteau/qoi-spark)**
>
> “Quite OK Image” Ada implementation. Contribute to Fabien-Chouteau/qoi-spark development by creating an account on GitHub.

It corresponds to the [“qoi” Alire crate](https://alire.ada.dev/crates/qoi).

---

<div class="post-metadata">

### Author: ![SMerrony](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/smerrony/32/410_2.png) [@SMerrony](https://forum.ada-lang.io/u/SMerrony)
#### Post date: [July 9, 2024, 2:35pm UTC](https://forum.ada-lang.io/t/gif-or-png-creation-encoding-library/971/5 "2024-07-09T14:35:04Z")

</div>

🙂 I’ve already hand-coded PPM and PAM encoders for my project. I was seeking something natively displayable in browsers and on desktops without external programs.

---

<div class="post-metadata">

### Author: ![SMerrony](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/smerrony/32/410_2.png) [@SMerrony](https://forum.ada-lang.io/u/SMerrony)
#### Post date: [July 9, 2024, 2:36pm UTC](https://forum.ada-lang.io/t/gif-or-png-creation-encoding-library/971/6 "2024-07-09T14:36:22Z")

</div>

QOI looks nice, but not (yet) supported by browsers or most desktops.

I spent a day trying to get PNG\_IO to work, in the end I failed with linking errors for zlib…

In the meantime I’ve coded up a simple (uncompressed) GIF encoder which I’ll enhance over the next few days.

---

<div class="post-metadata">

### Author: ![zertovitch](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/zertovitch/32/90_2.png) [@zertovitch](https://forum.ada-lang.io/u/zertovitch)
#### Post date: [August 21, 2024, 6:28pm UTC](https://forum.ada-lang.io/t/gif-or-png-creation-encoding-library/971/7 "2024-08-21T18:28:52Z")

</div>

GID ( [Alire - Gid](https://alire.ada.dev/crates/gid) ) now provides a simple PNG encoder (Dumb\_PNG).

---

<div class="post-metadata">

### Author: ![JC001](https://forum.ada-lang.io/letter_avatar_proxy/v4/letter/j/e56c9b/32.png) [@JC001](https://forum.ada-lang.io/u/JC001)
#### Post date: [August 22, 2024, 10:45am UTC](https://forum.ada-lang.io/t/gif-or-png-creation-encoding-library/971/8 "2024-08-22T10:45:38Z")

</div>

[Image I/O](https://github.com/jrcarter/Image_IO) provides `Write_PNG`. It uses the `Deflate_3` method with [Z Compression](https://github.com/jrcarter/Z_Compression) to achieve good compression ratios.

---

<div class="post-metadata">

### Author: ![DrPi](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/drpi/32/225_2.png) [@DrPi](https://forum.ada-lang.io/u/DrPi)
#### Post date: [August 24, 2024, 6:06pm UTC](https://forum.ada-lang.io/t/gif-or-png-creation-encoding-library/971/9 "2024-08-24T18:06:38Z")

</div>

You’ll have to change GID name 😅
