wowlixir

wowlixir

Arc - multiple outputs from one upload?

Hello,

I’m using Waffle (a fork of Arc) for image uploads in my Phoenix project. When an image is successfully uploaded, I would like to generate a bunch of smaller images from it, which will then be used in a tiled image pyramid viewer. Of course if the user deletes the image the tiles should be automatically deleted as well.

How can I accomplish this?
If I understand it correctly, Arc’s default “transformations” flow assumes each input file may map to at most one output file for each version, even if I want to run arbitrary commands. I already have the command to generate the images, I just need to understand how to integrate this with Arc.

Thanks in advance!

Most Liked

kokolegorille

kokolegorille

There are some ways to do it.

Oban by @sorentwo.

or a simple task… like in this post by @alvises

BTW, You may find more articles on using mogrify, or doing raw file upload in the previous linked site.

After this, You can create your own helper to display the associated files. For example it could be

render_slice(img)
kokolegorille

kokolegorille

Hello and welcome,

It is possible to specify multiple versions in the uploader, something like…

  @versions [:original, :large, :thumb, :mini]

  def transform(:mini, _) do
    {:convert, "-resize 160x90^ -gravity center -extent 160x90 -format png", :png}
  end

  def transform(:thumb, _) do
    ...
  end

  def transform(:large, _) do
    ...
  end

For delete, I did not solve it yet in the best way… In case of cascade delete for example…

But I have a cleaning task running periodically, deleting what needs to be.

Kurisu

Kurisu

I think you’re talking about images files associated with database records, right? Indeed I can’t see really a better solution.

But just in case the OP author is not aware of it, I would like to add this:

A Waffle uploader module has a delete function that should delete all the versions of an image (:mini, :large, :original…) all together when called.

Last Post!

wowlixir

wowlixir

I’m still very much a newbie so I’m still pretty lost, but I’ll try to understand things a little better before asking more questions. Thank you very much!

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New

Other popular topics Top

baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 42533 114
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

We're in Beta

About us Mission Statement