Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resize animated gif #68

Closed
gitviola opened this issue May 2, 2016 · 3 comments
Closed

Resize animated gif #68

gitviola opened this issue May 2, 2016 · 3 comments

Comments

@gitviola
Copy link
Contributor

gitviola commented May 2, 2016

I tried resizing an animated gif but it messes up the animation after resizing. I found out that there are two steps required to resize an animated gif.

Example

convert do.gif -coalesce temporary.gif
convert -size <original size> temporary.gif -resize 24x24 smaller.gif

Is there a way to get a resized version of an animated gif with arc?

@stavro
Copy link
Owner

stavro commented May 3, 2016

Are you sure that the above operation requires two calls to convert?

All of the examples here use one call to convert: http://www.imagemagick.org/Usage/anim_mods/#resize

eg: convert script_k.gif -coalesce -resize 20x20 script_k_direct2.gif

@gitviola
Copy link
Contributor Author

gitviola commented May 3, 2016

I tried it with the parameters mentioned above:

def transform(:thumb, {file, _scope}) do
    file_extension = file.file_name |> Path.extname
    case file_extension do
      ".gif" -> {:convert, "-coalesce -resize 250x250 -gravity center -extent 250x250"}
      _      -> {:convert, "-strip -thumbnail 250x250 -gravity center -extent 250x250"}
    end
  end

  def transform(:medium, {file, _scope}) do
    file_extension = file.file_name |> Path.extname
    case file_extension do
      ".gif" -> {:convert, "-coalesce -resize 700x700"}
      _      -> {:convert, "-quality 80 -strip -thumbnail 700x700> -gravity center"}
    end
  end

It takes forever and after a while there is a timeout

** (UndefinedFunctionError) undefined function :timeout.__struct__/1 (module :timeout is not available)
        :timeout.__struct__({:timeout, {Task, :await, [%Task{owner: #PID<0.1684.0>, pid: #PID<0.1689.0>, ref: #Reference<0.0.1.26960>}, 15000]}})

@stavro
Copy link
Owner

stavro commented Aug 19, 2016

This should be done through https://github.com/stavro/arc#complex-transformations for now.

@stavro stavro closed this as completed Aug 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants