From a6ea75a2e25420e561ce669ca7c9bcee04ec6f2c Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Mon, 13 May 2019 20:17:01 +0100 Subject: [PATCH] Adjust to final animated GIF interface --- Gemfile | 2 +- Gemfile.lock | 14 ++++---------- lib/gpx.rb | 15 +++++++-------- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/Gemfile b/Gemfile index 604db1500..26872a043 100644 --- a/Gemfile +++ b/Gemfile @@ -117,7 +117,7 @@ gem "canonical-rails" gem "logstasher" # Used to generate images for traces -gem "gd2-ffij", :git => "https://github.com/mmd-osm/gd2-ffij.git", :branch => "animated_gif" +gem "gd2-ffij", "= 0.4.0.dev" # Used for browser detection gem "browser" diff --git a/Gemfile.lock b/Gemfile.lock index 73169aaea..a7fcdf30e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,11 +1,3 @@ -GIT - remote: https://github.com/mmd-osm/gd2-ffij.git - revision: c92057a8f699a36b5f6d208db3d11eb3bae185dd - branch: animated_gif - specs: - gd2-ffij (0.3.1) - ffi (>= 1.0.0) - GEM remote: https://rubygems.org/ specs: @@ -181,6 +173,8 @@ GEM multipart-post (>= 1.2, < 3) ffi (1.10.0) fspath (3.1.0) + gd2-ffij (0.4.0.dev) + ffi (>= 1.0.0) geoip (1.6.4) globalid (0.4.2) activesupport (>= 4.2.0) @@ -468,7 +462,7 @@ DEPENDENCIES factory_bot_rails fakefs faraday - gd2-ffij! + gd2-ffij (= 0.4.0.dev) geoip htmlentities http_accept_language (~> 2.0.0) @@ -518,4 +512,4 @@ DEPENDENCIES webmock BUNDLED WITH - 1.16.6 + 1.17.2 diff --git a/lib/gpx.rb b/lib/gpx.rb index f3e0c0e26..1b1c17ac7 100644 --- a/lib/gpx.rb +++ b/lib/gpx.rb @@ -100,16 +100,15 @@ module GPX end end - 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] == frames[n - 1] ? nil : frames[n - 1]), - delay) + image = GD2::AnimatedGif.new + frames.each do |frame| + image.add(frame, :delay => delay) end - res << GD2::AnimatedGif.gif_anim_end + image.end - res + output = StringIO.new + image.export(output) + output.read end def icon(min_lat, min_lon, max_lat, max_lon) -- 2.43.2