VIPs-Warning ** tile 0 x 1104 错误 - Gif 崩溃网站 - Ruby on Rails

问题描述 投票:0回答:0

我已经将我的应用程序部署到 fly.io 并发现了一个有趣的错误,它只影响生产。使用本地存储时,相同的 gif 不会导致此问题。 gif 已上传到 AWS S3

首先我得到 VIPs-Warning ** tile 0 x 1104 错误 接着是 ActionView::Template::Error (gifload: Image EOF detected before image complete

这是我用来加载图像的代码:

<% if post.images.attached? %
    <% post.images.each do |image| %>
    <%= image_tag image.representation(loader: { n: -1 }, resize_to_fit: [400, nil]).processed, class: "img-fluid" %>
<% end %>

这是有问题的 gif,我没有看到它有什么特别或奇怪的地方,我的其他 gif 更大、更宽、更高,不会导致应用程序崩溃。有没有办法用 Active Storage 挽救失败的 gif 加载?

我试过添加这些行:

<% if post.images.attached? %>
  <% post.images.each do |image| %>
  <%= image_tag image.representation(loader: { n: -1 }, resize_to_fit: [400, nil]).processed, class: "img-fluid", onerror: "this.style.display='none'" %>
<% end %>

当我重新部署站点时,这没有解决任何问题

<% if post.images.attached? %>
  <% post.images.each do |image| %>
  <%= image_tag image.representation(loader: { n: -1 }, resize_to_fit: [400, nil]).processed, class: "img-fluid", rescue nil %>
<% end %>

这会导致语法错误。显然 vips 有问题,我发现了一个关于它的旧线程,但没有关于如何处理它的解决方案: https://github.com/libvips/libvips/issues/1701

*编辑以修复格式

ruby-on-rails gif eof vips
© www.soinside.com 2019 - 2024. All rights reserved.