# Using gifAnimation library on Python Mode

**URL:** https://discourse.processing.org/t/using-gifanimation-library-on-python-mode/24577
**Category:** Processing.py
**Created:** [October 13, 2020, 7:28pm UTC](https://discourse.processing.org/t/using-gifanimation-library-on-python-mode/24577 "2020-10-13T19:28:23Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![villares](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/villares/32/3166_2.png) [@villares](https://discourse.processing.org/u/villares)
#### Post date: [October 13, 2020, 7:28pm UTC](https://discourse.processing.org/t/using-gifanimation-library-on-python-mode/24577/1 "2020-10-13T19:28:23Z")

</div>

I have answered this today on Stack Overflow and I think it might be useful for someone:

Just to be clear about libraries with Processing Python mode:

- You can use “pure Python” libraries;
- You can’t use Python libraries with C extensions & etc (like `numpy`);
- You can’t use JavaScript (or p5js) libraries;
- You can use Java & Processing Java mode libraries (most of them work)!

Art Simon has a nice example of gifAnimation export here: [https://github.com/APCSPrinciples/AnimatedGIF/](https://github.com/APCSPrinciples/AnimatedGIF/)

**A step by step approach:**

1. Download the `gifAnimation` library from:  
[https://github.com/extrapixel/gif-animation/archive/3.0.zip](https://github.com/extrapixel/gif-animation/archive/3.0.zip)

2. Unzip and copy the gifAnimation folder into your libraries folder, like this:  
`user/sketchbook/libraries/gifAnimation` (Linux) or  
`user/Documents/Processing/libraries/gifAnimation` (Mac/Windows)

3. Restart the IDE and add this at the start of your sketch:

```python
add_library('gifAnimation')

```

1. Initialize an exporter object inside `setup()`

```python
def setup():
    global exporter
    size(400, 400)
    exporter = GifMaker(this, "animation.gif")
    exporter.setRepeat(0) # infinite repeat
    exporter.setQuality(100) # test values
    exporter.setDelay(200) # milliseconds 

```

1. at the end of `draw()` use the `.addFrame()` method and maybe something for the end of the animation recording.

```python
def draw():    
    # your drawing here

    exporter.addFrame()

    if keyPressed and key == 'e':
        exporter.finish()
        print("gif saved, exit")
        exit()

```

---

<div class="post-metadata">

### Author: ![villares](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/villares/32/3166_2.png) [@villares](https://discourse.processing.org/u/villares)
#### Post date: [June 4, 2021, 2:21am UTC](https://discourse.processing.org/t/using-gifanimation-library-on-python-mode/24577/2 "2021-06-04T02:21:56Z")

</div>

Adding an extra warning to ensure you **rename the unzipped** Folder from _/gif-animation-3.0_ to **/gifAnimation** and a link to the thread that demonstrates how to _show an animated gif_ instead of exporting one (another feature from this library) [Loop animated .gif in python mode - #3 by JSGauthier](https://discourse.processing.org/t/loop-animated-gif-in-python-mode/30479/3)
