From b493cfafd77e2bdb6e8949fc3bc6e73e4fbed21d Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Fri, 8 May 2020 10:20:53 +0200 Subject: Banners: Don't try to resize gifs. 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! --- app/views/refinery/banners/shared/_banner_image.html.erb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 --- a/app/views/refinery/banners/shared/_banner_image.html.erb +++ b/app/views/refinery/banners/shared/_banner_image.html.erb @@ -14,4 +14,8 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . %> -<%= 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 %> -- cgit v1.2.3