Support for +commands #19

Open
tmaier opened this Issue Apr 1, 2013 · 1 comment

Comments

Projects
None yet
2 participants
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 -

+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.

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