stavro / arc_ecto

An integration with Arc and Ecto.
255 stars 149 forks source link

Timout when transforming image #85

Open svennerberg opened 6 years ago

svennerberg commented 6 years ago

Whenever I try to convert images to something a bit larger than 640px or so I get a timeout. I have tried to increase the timeout time to up to 2 minutes but it doesn't complete before that either.

The same problem happens on both my local machine and on Heroku.

I guess this problem has something to do with Image Magick but I basically do the same conversions using paperclip on Rails without any problems.

Have anybody else experienced the same problem? Are there workarounds?

This is what my definition looks like:

defmodule Succinct.FeaturedImage do
  use Arc.Definition
  use Arc.Ecto.Definition

  @acl :public_read
  @versions [:original, :thumb, :small]

  def validate({file, _}) do
    ~w(.jpg .jpeg .gif .png) |> Enum.member?(Path.extname(file.file_name))
  end

  # Transformations
  def transform(:thumb, _) do
    {:convert, "-strip -thumbnail 250x250^ -gravity center -extent 250x250 -format png", :png}
  end

  def transform(:small, _) do
    {:convert, "-strip -resize 640x640> -quality 80", :jpg}
  end

  def transform(:large, _) do
    {:convert, "-strip -resize 1400x1400> -quality 60 -format jpg", :jpg}
  end

end
pedep commented 6 years ago

What happens when you run the command manually? I get an error running convert test.jpg -strip -resize 1400x1400> -quality 60 -format jpg out.jpg in both bash and zsh. This should be solved by escaping the > (becomes \>) like they do in the documentation

If this does not work, you could try setting @async false to see if the commands ever finishes