Concatenating lazy operations

22 views
Skip to first unread message

Shannon Carey

unread,
Apr 17, 2013, 2:44:00 PM4/17/13
to dragonf...@googlegroups.com
Hi,

I'm looking for ways to improve the performance of our Dragonfly-based image service. I noticed that the ImageMagick command line is called once per call to the job's process() method. Sometimes, multiple calls are necessary. However, ImageMagick also has the ability to chain multiple "image operators" in sequence on one command line invocation. I assume one command line would be more efficient due to less reading & writing of files.

In order to implement chaining of multiple commands, it seems apparent that I should aggregate the operations into the TempObject that is strung through sequential calls to the Processor. At first glance, it seems that I could aggregate the commands into the @data attribute or the @meta attribute of the TempObject, however there is no way to know when the lazy aggregation is over and the actual evaluation needs to be performed by calling "convert" with the aggregated operations. When job.apply is called, it simply executes each of the listed methods on the Processor: it does not build a lazily executed sequence of steps.

For those familiar with the Dragonfly source code: do you have any ideas what kind of approach would be best to accomplish the functionality I'm imagining?

Thanks,
Shannon

Mark Evans

unread,
Apr 19, 2013, 1:45:29 PM4/19/13
to dragonf...@googlegroups.com
Hi
If you want to use imagemagick to chain multiple operators in one invocation, then you can simply use the "convert" method, e.g.

image.convert("-some long set of args -here")

and you can make a short cut for common ones by making a shortcut, e.g. in configuration

c.job :my_operation do |size, thing|
process :convert "-resize #{size} -some args #{thing}"
end

then

image.my_operation('30x30', 'blah')

is that what you mean?
Mark

Shannon Carey

unread,
Apr 19, 2013, 2:25:29 PM4/19/13
to dragonf...@googlegroups.com
Yep, I figured that out shortly after posting :) Thanks!
Reply all
Reply to author
Forward
0 new messages