# Create gif from saved images

**URL:** <https://discourse.julialang.org/t/create-gif-from-saved-images/85146>\
**Category:** General Usage\
**Tags:** plots, animations\
**Created:** [August 2, 2022, 7:44am UTC](https://discourse.julialang.org/t/create-gif-from-saved-images/85146 "2022-08-02T07:44:45Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [August 3, 2022, 8:47am UTC](https://discourse.julialang.org/t/create-gif-from-saved-images/85146/6 "2022-08-03T08:47:46Z")

</div>

Hi! I hope you solved your problem with @empet’s excellent advice.

If you find you’re doing this type of thing often, you might find it useful to have FFMPEG.jl in your toolbox. FFMPEG is the “Swiss Army knife” of image and video processing, and it’s conveniently wrapped in a Julia package.

If all your PNG files are named in the same way, you can write code such as this:

```julia
using FFMPEG
imagesdirectory = "/tmp/temp/"
framerate = 30
gifname = "/tmp/output.gif"
FFMPEG.ffmpeg_exe(`-framerate $(framerate) -f image2 -i $(imagesdirectory)/%10d.png -y $(gifname)`)

```

In this command, the `%10d.png` matches all files named with just 10 digits followed by “.png”. If your first file was `00001-timeseries.png` you would use `%05d-timeseries.png`. The `-y` overwrites the GIF output file if it already exists.

You can use similar commands to create ‘real’ videos - this function:

```julia
FFMPEG.ffmpeg_exe(`-framerate $(framerate) -f image2 -i $(imagesdirectory)/%10d.png -vf "scale=1920:1080" -c:v libx264 -pix_fmt yuv420p -y "/tmp/output-video.mov"`)

```

rescales every image then outputs a video in a MPEG 4 container file.

(In a test I just did with this bigger output, the GIF file size for 150 frames was 198Mb, the equivalent movie was 4Mb. Presumably a fair amount of lossy compression going on.)

---

_[View the full topic](https://discourse.julialang.org/t/create-gif-from-saved-images/85146)._
