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

Enhancement: magick:gravity:<value> #254

Closed
ghost opened this issue Mar 21, 2016 · 5 comments
Closed

Enhancement: magick:gravity:<value> #254

ghost opened this issue Mar 21, 2016 · 5 comments
Milestone

Comments

@ghost
Copy link

ghost commented Mar 21, 2016

Would be nice to be able to set the gravity of the crop (magick:gravity:center) so you could do center crops with magick:crop:400x300+0+0 for example.

@envygeeks envygeeks added this to the v2.2.0 milestone Mar 21, 2016
@ghost
Copy link
Author

ghost commented Mar 21, 2016

@envygeeks, I didn't want to start a new issue for this but after this was added I wanted to test the proxy. Currently I'm just using it like:

{% img 'image.jpg' magick:gravity:center magick:crop:600x400+0+0 %}

Mini Magick suggests combining options which is looks like magick.rb does below:

magick.rb

def process
      img = MiniMagick::Image.open(@path)
      private_methods(true).select { |v| v =~ /\Amagick_/ }.each do |method|
        send(method, img)
      end

      img.write(
        @path
      )
    ensure
      img.destroy!
    end

However my images are still being cropped from the top left corner. Image Magick suggests the following for cropping from the center:

The most common use of a gravitated crop, is to crop the 'center' of an image.

convert rose: -gravity Center -crop 32x32+0+0 +repage crop_center.gif

Which is why I thought {% img 'image.jpg' magick:gravity:center magick:crop:600x400+0+0 %} might work? Any insight or guidance would be appreciated. Apologies if this doesn't end up being related to jekyll-assets.

@envygeeks
Copy link
Owner

We only pass-through options. If it's not working as expected that seems like a Minimagic bug to me, if it expects them in a certain order that again is a mini-magic problem because this is Ruby, we have no way to guarantee a hash will come in a specific order and adhering to such a crazy idiom is something we will never do (as it's up to them to order it the way they want if they expect that.)

That said, I see a disparity between what ImageMagick wants and what you send. They use "Center" you use "center", in my experience ImageMagick is pretty strict about what it wants (for good reason since it's a complicated piece of software that has wrappers for it's wrappers to make it easier.)

@ghost
Copy link
Author

ghost commented Mar 21, 2016

@envygeeks, Thanks for the quick response. I wish it was the center or Center but I've tried both with the same results.

I may send Mini Magick a message just to see if that is the case. Push comes to shove I guess I'll have to do some manual image manipulation but I guess things could be worse.

Not sure how you want to proceed but if that's the case I can't see a real use for magick:gravity:<value>

@ghost
Copy link
Author

ghost commented Mar 22, 2016

@envygeeks What are your thoughts about this? He also suggested a possible solution #362. Thanks for your help this far.

@envygeeks
Copy link
Owner

ccde62e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant