Git Product home page Git Product logo

Comments (4)

jnicklas avatar jnicklas commented on July 18, 2024

Not sure if there's a global config option in MiniMagick to set this kind of stuff. There isn't anything in Refile at least.

from refile-mini_magick.

janko avatar janko commented on July 18, 2024

If your VPS has certain memory/disk limits, it seems reasonable for me to set it per-VPS, that is, in the policy.xml file. Is there a reason why you would want to set it per-application/attribute?

I think there is no pretty way to add it to Refile. I was thinking we could write the processing methods like this:

def fit(img, width, height)
  img.combine_options do |cmd|
    # ...
    yield cmd if block_given?
    # ...
  end
end

And then you could override that method with

Refile::MiniMagick.prepend Module.new {
  def fit(img, width, height) do
    super do |cmd|
      cmd.limit "memory", "400MiB"
      cmd.limit "map", "400MiB"
      cmd.limit "disk", "1MiB"
    end
  end
}

from refile-mini_magick.

Sudrien avatar Sudrien commented on July 18, 2024

Part of the problem is, as far as I can tell, policy.xml isn't multi-instance aware. If I have 8 files being thumbnailed (which I very well could, from a single page render, depending on browser setup) the memory preferences would be much lower per file than they would be if I could force them to process serially.

from refile-mini_magick.

janko avatar janko commented on July 18, 2024

In #1 there was a similar request to make Refile::MiniMagick extendable using a dedicated API, but in #1 (comment) I explained why I don't think it would be a good idea. However, I will probably add an (undocumented) yield I proposed above, hopefully it should be good enough for both cases.

from refile-mini_magick.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.