<commit_before>require 'RMagick'

class Magick::Image
  # image.auto_orient! # Rotates the image according to EXIF orientation tag
  # The above is broken in older versions of imagemagick (regardless of rmagick version)
  def reorient!
    self.get_exif_by_entry('Orientation')
    case self['EXIF:Orientation']
    when Magick::LeftBottomOrientation.to_i.to_s
      self.rotate!(-90)      
    when Magick::RightTopOrientation.to_i.to_s
      self.rotate!(90)      
    end
  end
end

module ImagesOnS3

  def has_images_on_s3( options = {} )
    attr_accessor :temp_data
    mattr_accessor :resize_options
    mattr_accessor :keep_original

    validates_uniqueness_of :filename, :allow_nil => true
    validates_inclusion_of :content_type, :in => %w( image/jpeg image/pjpeg image/gif image/png image/x-png image/jpg image/tiff ), :allow_nil => true
    
    if column_names.include?('size')
      validates_numericality_of :size
      validates_inclusion_of :size, :in => (1.kilobyte..10.megabytes)
    end
  
    before_validation :set_properties_from_image_data, :unless => Proc.new{|i| i.temp_data.blank? }
    after_validation :store_on_s3
    after_destroy :delete_from_s3
    
    include InstanceMethods unless included_modules.include?(InstanceMethods)<commit_msg>Update orientation metadata after rotating<commit_after>require 'RMagick'

class Magick::Image
  # image.auto_orient! # Rotates the image according to EXIF orientation tag
  # The above is broken in older versions of imagemagick (regardless of rmagick version)
  def reorient!
    self.get_exif_by_entry('Orientation')
    case self['EXIF:Orientation']
    when Magick::LeftBottomOrientation.to_i.to_s
      self.rotate!(-90)      
      self['EXIF:Orientation'] = Magick::TopLeftOrientation.to_i.to_s
    when Magick::RightTopOrientation.to_i.to_s
      self.rotate!(90)      
      self['EXIF:Orientation'] = Magick::TopLeftOrientation.to_i.to_s
    end
  end
end

module ImagesOnS3

  def has_images_on_s3( options = {} )
    attr_accessor :temp_data
    mattr_accessor :resize_options
    mattr_accessor :keep_original

    validates_uniqueness_of :filename, :allow_nil => true
    validates_inclusion_of :content_type, :in => %w( image/jpeg image/pjpeg image/gif image/png image/x-png image/jpg image/tiff ), :allow_nil => true
    
    if column_names.include?('size')
      validates_numericality_of :size
      validates_inclusion_of :size, :in => (1.kilobyte..10.megabytes)
    end
  
    before_validation :set_properties_from_image_data, :unless => Proc.new{|i| i.temp_data.blank? }
    after_validation :store_on_s3
    after_destroy :delete_from_s3
    
    include InstanceMethods unless included_modules.include?(InstanceMethods)
{'fraction_non_alphanumeric': 0.08973887458624494, 'fraction_numerical': 0.008091210003677823, 'mean_word_length': 4.065176908752328, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '2442153', 'n_tokens_mistral': 922, 'n_tokens_neox': 889, 'n_words': 187}