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

Support for +commands #19

Open
tmaier opened this issue Apr 1, 2013 · 2 comments
Open

Support for +commands #19

tmaier opened this issue Apr 1, 2013 · 2 comments

Comments

@tmaier
Copy link
Contributor

tmaier commented Apr 1, 2013

ImageSorcery only supports -commands, but there are also some +commands, like +repage

  def convert_to_arguments(args)
    special_args = [:layer, :annotate]
    args.reject {|k, v| special_args.include?(k) }.map {|k, v| " -#{k} '#{v}'"}
  end

https://github.com/EricR/image_sorcery/blob/master/lib/image_sorcery.rb#L135-L138

I would suggest following convention: If an argument is a symbol, it is an ordinary -command. If it is a string, the user takes care of the prefix by himself.

Alternative: Convert Symbol to string, check if it has a prefix (+ or -). If not, add -

@willglynn
Copy link

+1. I needed to construct a command like:

convert -size 100x100 xc:none \
  image_a.png -geometry +0+0 -composite \
  image_b.png -geometry +10+20 -composite \
  output.png

This was possible through the current public interface, but only just. I was relying on the fact that the convert output filename isn't escaped to pass in arbitrary command strings.

Going into production like that seemed like a bad idea, and the rest of my usage of ImageSorcery in this instance was minimal, so I opted to drop the dependency and go straight to ImageMagick via Process.spawn in the calling code instead, which also prevents shell escaping issues.

@systemed
Copy link

systemed commented Jun 1, 2017

I monkey-patched it like this:

class ImageSorcery
  private
  def convert_to_arguments(args)
    special_args = [:layer, :annotate]
    args.reject {|k, v| special_args.include?(k) }.map {|k, v| " #{k.is_a?(Symbol) ? '-'+k.to_s : k } #{v==true ? '' : 39.chr+v.to_s+39.chr} "}
  end
end

A bit messy but works fine, and allows you to do

magick['+repage'] = true

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

No branches or pull requests

3 participants