How to use dragonfly to crop a circular section from an image

98 views
Skip to first unread message

Praveenram Balachandar

unread,
Dec 9, 2013, 9:48:50 AM12/9/13
to dragonf...@googlegroups.com
Hi,

I'm using dragonfly 0.9.15.

Given an image, I'm confused at how to use the convert method in dragonfly to crop a circular portion from the image with transparent background.

I am able to use a direct image magick command to run it from command line but the example command I found uses actual files and I'm unaware of how to get the file while dragonfly processes it on the fly.

Here's the actual command I took from a stack overflow post on imagemagick.


Command:

convert -size 200x200 xc:none -fill walter.jpg -draw "circle 100,100 100,1" circle_thumb.png

Now I tried to replicate the same with a convert in dragonfly.

require 'dragonfly/rails/images'

Dragonfly[:images].configure do |c|
  c.job :crop_circle do
    process :resize, "320x440"
    encode :png
    process :convert, '-virtual-pixel HorizontalTile -background transparent -draw "circle 400,400 400,1" -compose Copy_Opacity -composite'
  end
end

How can I achieve this.

Any help is appreciated. The output I want is exactly same as what is there on the stackoverflow post I've mentioned.

Thanks,
Praveen.

Thomas Bindzus

unread,
Sep 9, 2014, 1:46:12 PM9/9/14
to dragonf...@googlegroups.com
Hi Praveenram,

I've posed an answer to the question on Stackoverflow:


You probably don't need it anymore, but perhaps someone else will find it useful :-)

Kind regards
- Thomas
Reply all
Reply to author
Forward
0 new messages