]> git.openstreetmap.org Git - rails.git/commitdiff
Skip gif animation optimization in case both frames are identical
authormmd-osm <mmd.osm@gmail.com>
Wed, 3 Apr 2019 17:12:45 +0000 (19:12 +0200)
committermmd-osm <mmd.osm@gmail.com>
Wed, 3 Apr 2019 17:15:37 +0000 (19:15 +0200)
This works around an issue in libgd2 library which would otherwise
cause segfaults due to zero sized images

lib/gpx.rb

index 4580421ba533458b63e8fbda2b3d95a9ba452235..f3e0c0e26c0bddce6d50931fbd5627d333cecd05 100644 (file)
@@ -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