Sha256: 62b32d8713cf925e189d90120c1f2b4ec143bf0f17d469dd504dbad5866ab221

Contents?: true

Size: 886 Bytes

Versions: 1

Compression:

Stored size: 886 Bytes

Contents

module Paperclip
  class Trimmer < Processor
    def initialize(file, options={}, attachment=nil)
      super

      @current_format   = File.extname(@file.path)
      @basename         = File.basename(@file.path, @current_format)
    end

    # This class is meant to help trim off letterboxing from
    # YouTube poster images. YouTube always delivers a 4:3 poster
    # image (the HQ version), and adds black edges if the video
    # doesn't fit.
    def make
      source = @file
      destination = Tempfile.new(@basename)

      Paperclip.run("convert",
        ":source " \
        "-quality 100 " \
        "-bordercolor \"#000000\" " \
        "-border 1x1 " \
        "-fuzz 10% " \
        "-trim +repage " \
        ":dest",
        :source => File.expand_path(source.path),
        :dest   => File.expand_path(destination.path)
      )

      destination
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
asset_host_core-2.0.0.beta lib/asset_host_core/paperclip/trimmer.rb