|author||Harald Eilertsen <email@example.com>||2020-05-08 10:20:53 +0200|
|committer||Harald Eilertsen <firstname.lastname@example.org>||2020-05-08 10:20:53 +0200|
Banners: Don't try to resize gifs.deploy-20200508
ImageMagick does not handle resizing of animated gifs wery well. Optimized gifs will usually have individual sizes for each frame, only containing the actually changed image data. Each frame also have an offset from the origin. When ImageMagick tries to resize such an image, the offsets gets messed up and the result looks rather terrible. There's ways to handle this in ImageMagick, by first making all frames the same size (`convert -coalesce ...`) then resize (`convert -resize ...`) and finally optimize the gif again (`convert -layers Optimize ...`). However, this is a bit too much to handle when trying to download the animation, so it should be done on or before upload. For now, I think doing it offline before upload should be good enough. This _requires_ though, that the animation has the correct dimensions before upload!
1 files changed, 5 insertions, 1 deletions
diff --git a/app/views/refinery/banners/shared/_banner_image.html.erb b/app/views/refinery/banners/shared/_banner_image.html.erb
index ffaebae..c13a637 100644
@@ -14,4 +14,8 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
-<%= link_to(image_fu(banner_image.image, '500x'), banner_image.url, :target => "_blank") %>
+<% if banner_image.image.image_mime_type == "image/gif" %>
+ <%= link_to(image_tag(banner_image.image.url), banner_image.url, :target => "_blank") %>
+<% else %>
+ <%= link_to(image_fu(banner_image.image, '500x'), banner_image.url, :target => "_blank") %>
+<% end %>