def add_output_option(option_name, *args)
      (@output_options ||= []).push(option_name)
      args.each { |ea| @output_options.push(Shellwords.escape(ea.to_s)) }

      # if we're a resize call, let's give the -size render hint to gm, but only when it's safe:
      # * we don't have input options yet,
      # * we're not cropping (because the -size will prevent the crop from working),
      # * and we have dimensions in the form of NNNxNNN
      if %w{-geometry -resize -sample -scale}.include?(option_name) &&
        @input_options.empty? &&
        !@output_options.include?('-crop')
        dimensions = args.first
        if dimensions.to_s =~ /\A(\d+x\d+)\z/
          @input_options.push('-size', dimensions)
        end
      end
      # Support call chaining:
      self
    end
def add_output_option(option_name, *args)
      (@output_options ||= []).push(option_name)
      args.each { |ea| @output_options.push(Shellwords.escape(ea.to_s)) }

      # if we're a resize call, let's give the -size render hint to gm, but only when it's safe:
      # * we don't have input options yet,
      # * we're not cropping (because the -size will prevent the crop from working),
      # * and we have dimensions in the form of NNNxNNN
      if %w{-geometry -resize -sample -scale}.include?(option_name) &&
        @input_options.empty? &&
        !@output_options.include?('-crop')
        dimensions = args.first
        if dimensions.to_s =~ /\A(\d+x\d+)\z/
          @input_options.push('-size', dimensions)
        end
      end
      # Support call chaining:
      self
    end
For normal options, like -resize or -flip, you can call .resize("32x32") or .flip().
 If you need to add an output option that starts with a '+', you can use this method.