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
There are some ways to do it.
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
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
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
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!
Popular in Questions
Other popular topics
Latest Phoenix Threads
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #hex
- #security









