Thumbnails for every file types and convert files between different formats

<%- if @topic_view.topic.tags.present? %>
<%= t 'js.tagging.tags' %>: <%- @topic_view.topic.tags.each do |t| %> <%= t %> <%- end %>
<% end %>

A wee while ago I did a proof of concept PR that would:

  • add the ability to create thumbnails for any file type (not just images)
  • allow developers to convert files to different format and track them as variants.

Allow file variant with different extensions POC

For example, this PR would enable scenarios like:

  • generate thumbnails for videos and display them in asset-admin
  • upload a spread sheet to the CMS and offer the option to the user to download it in alternative format like PDF, CSV or LibreOffice’s ODS

Important: The PR would NOT do all of that out of the box … it would give you APIs allowing you to implement these features.

While the PR itself is relatively simple, implementing it properly and long term maintenance of this API would require some effort.

I’m trying to ascertain if there’s real world demand for this and if it’s something developers want.

Please, let me know if this is something you would be keen to use yourself. If you have real world examples where this would have been useful for you or where clients have asked for this feature, that would be very valuable as well.

Converting files between formats has been something I’ve bumped up against before, and would be really useful. I never managed to get the asset adaptor to do it. One real-world example of this was a site which needed uploaded images to be cropped in an unusual shape (with transparency). The funky cropping part was relatively easy with an extension, but getting the client to convert to PNG before upload was a real friction point and I’d have loved to have been able to take any of their sources, convert them and then crop them in one nice operation.

1 Like

The fundamental problem is that variants are currently controlled by the file extension. So even something simple like taking PNG and converting it to a JPG becomes problematic. If we implement this change, someone could hopefully be able to create an extension that would enable something like this:

<% $MyImage.PNG.Fit(300,300) %>

That’s exactly the problem I came up against… I built my processor to do the cropping, but really wanted pass a converted file into it (whilst keeping it in the proper assets system and not resorting to some nasty hacks).

Certainly gets my vote.

I also do like the idea of stuff like video thumbs, but I always run a mile from self-hosting video, so that specific use-case wouldn’t help me. What I have had to build in the past is a PDF thumbnailer which spits out a JPG of the first page of an uploaded PDF file. So, provided the API is sufficiently ‘pluggable’, it would be great.