From: mmd-osm Date: Wed, 3 Apr 2019 17:12:45 +0000 (+0200) Subject: Skip gif animation optimization in case both frames are identical X-Git-Tag: live~2592^2~4 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/7f138fb014e201e9e6b63ababf57d0f7c53bd86c Skip gif animation optimization in case both frames are identical This works around an issue in libgd2 library which would otherwise cause segfaults due to zero sized images --- diff --git a/lib/gpx.rb b/lib/gpx.rb index 4580421ba..f3e0c0e26 100644 --- a/lib/gpx.rb +++ b/lib/gpx.rb @@ -103,7 +103,9 @@ module GPX res = GD2::AnimatedGif.gif_anim_begin(frames[0]) res << GD2::AnimatedGif.gif_anim_add(frames[0], nil, delay) (1...nframes).each do |n| - res << GD2::AnimatedGif.gif_anim_add(frames[n], frames[n - 1], delay) + res << GD2::AnimatedGif.gif_anim_add(frames[n], + (frames[n] == frames[n - 1] ? nil : frames[n - 1]), + delay) end res << GD2::AnimatedGif.gif_anim_end