thoughtbot / paperclip

Easy file attachment management for ActiveRecord
https://thoughtbot.com
Other
9.01k stars 2.43k forks source link

Add Graphics Magick support #662

Closed brodock closed 12 years ago

brodock commented 12 years ago

Graphics Magick is in some way similar to ImageMagick (does have a compatibility layer) but may differ in many other ways. The one that makes this propose a win, is that Graphics Magick is made with performance in mind.

On official website, there are a list of advantages: Here are some reasons to prefer GraphicsMagick over ImageMagick:

source: http://www.graphicsmagick.org/

So, by that in mind, I think that is a cood candidate, and I also have something in mind that can help make both works: https://github.com/probablycorey/mini_magick

I don't know if mini_magick have all the necessary APIs but, it can be extended so to cover all needs that paperclip have. Also it's a good idea to separate the "graphics logic" from "paperclips logic"

jyurek commented 12 years ago

While you make good points, there's nothing stopping you from using GM with paperclip now.

mike-burns commented 12 years ago

@brodock you can make a paperclip-graphicsmagick gem that interacts with Paperclip. See https://github.com/thoughtbot/paperclip-thumbnailer for an example of how to write a processor; you can even leverage that gem to build your processor.

Let us know how it goes!

mulderp commented 11 years ago

Hi Mike,

I just put a small processor for graphicsmagick together: https://github.com/mulderp/paperclip-gmagick

I also released 0.0.1 of paperclip-graphicsmagick (Only resizing is supported right now, and it's more or less extracted from the thumbnail processor)

Eventually helpful for others.

LYY commented 11 years ago

@mulderp I switched to graphicsmagick recently, mini_magick can support both im and gm, but paperclip doesn't.

your work is very helpful for me, thank you!

mulderp commented 11 years ago

Thanks! Happy to hear. If I remember correctly, it was rather a quick hack, if you find bugs/issues just file a bug or send a PR!

w-4luar commented 8 years ago

Maybe a bit late, but the following solution works right for me and is extremely easy to implement:

    module MyNamespace
      module Paperclip
        module Helpers
          ImageMagick_commands = [
              "animate",
              "batch",
              "benchmark",
              "compare",
              "composite",
              "conjure",
              "convert",
              "display",
              "identify",
              "import",
              "mogrify",
              "montage"
          ]

          def run(cmd, arguments = "", interpolation_values = {}, local_options = {})

            if ImageMagick_commands.include?(cmd.to_s)
              arguments.prepend(cmd + ' ')
              cmd = 'gm'
            end

            super
          end
        end
      end
    end

    module Paperclip
      extend MyNamespace::Paperclip::Helpers
    end