Make Vips the recommended/default variant processor for Active Storage

I don’t have any preferred method for this. My example comes from how currently I ‘m doing this, but I have no problem changing the code to make it work with VIPS.

For me, encoding and decoding Active Storage blob records, as well as downloading the received blobs, is something that would be more suitable to handle on the Active Storage side.

Hi there! I came back to say thank you for teaching me about Aptfile, I’ve successfully added libvips-dev to my Herokuish deployed app.

For composition, although Active Storage still doesn’t support variants on Vips. I managed to use another method with Vips::Image.text, and another has_one_attached :watermarked_image attachment to process my watermarks.

Thanks!

I’m a little late to this one. The one problem I have found since switching to VIPS is that active storage gif uploads (used in action text) can’t be transformed while remaining animated.

This means I edit my action text, add a gif, but when it displays - there is only a static image.

I’d very much appreciate it if anyone could help.

Under rMagick, I was able to adjust

/views/active_storage/blobs/_blob.html.erb

with

  <% if blob.representable? %>
    <% if blob.content_type == Mime[:gif].to_s %>
      <%= image_tag url_for(blob.representation(loader: { page: nil }, coalesce: true, resize_to_limit: local_assigns[:in_gallery] ? [ 800, 600 ] : [ 1024, 768 ])) %>
    <% else %>
      <%= image_tag url_for(blob.representation(resize_to_limit: local_assigns[:in_gallery] ? [ 800, 600 ] : [ 1024, 768 ])) %>
    <% end %>
  <% end %>

under VIPS, I get an error

Vips::Error: VipsOperation: class “coalesce” not found

Is there a VIPS equivalent to achieve the same thing?

Thank you :slight_smile:

1 Like