<commit_before>module Dragonfly
  module ImageMagick
    module Processors
      class Thumb

        GRAVITIES = {
          'nw' => 'NorthWest',
          'n'  => 'North',
          'ne' => 'NorthEast',
          'w'  => 'West',
          'c'  => 'Center',
          'e'  => 'East',
          'sw' => 'SouthWest',
          's'  => 'South',
          'se' => 'SouthEast'
        }

        # Geometry string patterns
        RESIZE_GEOMETRY         = /\A\d*x\d*[><%^!]?\z|\A\d+@\z/ # e.g. '300x200!'
        CROPPED_RESIZE_GEOMETRY = /\A(\d+)x(\d+)#(\w{1,2})?\z/ # e.g. '20x50#ne'
        CROP_GEOMETRY           = /\A(\d+)x(\d+)([+-]\d+)?([+-]\d+)?(\w{1,2})?\z/ # e.g. '30x30+10+10'

        def update_url(url_attributes, geometry, opts={})
          format = opts['format']
          url_attributes.ext = format if format
        end

        def call(content, geometry, opts={})
          args = case geometry
          when RESIZE_GEOMETRY
            resize_args(geometry)
          when CROPPED_RESIZE_GEOMETRY
            resize_and_crop_args($1, $2, $3)
          when CROP_GEOMETRY
            crop_args(
              'width' => $1,
              'height' => $2,
              'x' => $3,
              'y' => $4,
              'gravity' => $5
            )
          else raise ArgumentError, "Didn't recognise the geometry string #{geometry}"
          end
          args += ' -auto-orient -strip'
          content.process!(:convert, args, opts)
        end

        private

        def resize_args(geometry)
          "-resize #{geometry}"
        end

        def crop_args(opts)
          raise ArgumentError, "you can't give a crop offset and gravity at the same time" if opts['x'] && opts['gravity']

          width   = opts['width']
          height  = opts['height']<commit_msg>fix args order for image magick<commit_after>module Dragonfly
  module ImageMagick
    module Processors
      class Thumb

        GRAVITIES = {
          'nw' => 'NorthWest',
          'n'  => 'North',
          'ne' => 'NorthEast',
          'w'  => 'West',
          'c'  => 'Center',
          'e'  => 'East',
          'sw' => 'SouthWest',
          's'  => 'South',
          'se' => 'SouthEast'
        }

        # Geometry string patterns
        RESIZE_GEOMETRY         = /\A\d*x\d*[><%^!]?\z|\A\d+@\z/ # e.g. '300x200!'
        CROPPED_RESIZE_GEOMETRY = /\A(\d+)x(\d+)#(\w{1,2})?\z/ # e.g. '20x50#ne'
        CROP_GEOMETRY           = /\A(\d+)x(\d+)([+-]\d+)?([+-]\d+)?(\w{1,2})?\z/ # e.g. '30x30+10+10'

        def update_url(url_attributes, geometry, opts={})
          format = opts['format']
          url_attributes.ext = format if format
        end

        def call(content, geometry, opts={})
          args = case geometry
          when RESIZE_GEOMETRY
            resize_args(geometry)
          when CROPPED_RESIZE_GEOMETRY
            resize_and_crop_args($1, $2, $3)
          when CROP_GEOMETRY
            crop_args(
              'width' => $1,
              'height' => $2,
              'x' => $3,
              'y' => $4,
              'gravity' => $5
            )
          else raise ArgumentError, "Didn't recognise the geometry string #{geometry}"
          end
          args = '-auto-orient -strip ' + args
          content.process!(:convert, args, opts)
        end

        private

        def resize_args(geometry)
          "-resize #{geometry}"
        end

        def crop_args(opts)
          raise ArgumentError, "you can't give a crop offset and gravity at the same time" if opts['x'] && opts['gravity']

          width   = opts['width']
          height  = opts['height']
{'fraction_non_alphanumeric': 0.1582138919514884, 'fraction_numerical': 0.016538037486218304, 'mean_word_length': 1.5628531073446328, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6193691', 'n_tokens_mistral': 1270, 'n_tokens_neox': 1179, 'n_words': 259}