Sha256: 146653691062728605910fdb00ef4df7039720c9803302467ab58d2f8da5ee7f

Contents?: true

Size: 724 Bytes

Versions: 3

Compression:

Stored size: 724 Bytes

Contents

require 'image_optim/worker'
require 'exifr'

class ImageOptim
  class Worker
    # http://www.sentex.net/~mwandel/jhead/
    #
    # Jhead internally uses jpegtran which should be on path
    class Jhead < Worker
      # Works on jpegs
      def image_formats
        [:jpeg]
      end

      # Run first [-10]
      def run_order
        -10
      end

      def used_bins
        [:jhead, :jpegtran]
      end

      def optimize(src, dst)
        if (2..8).include?(EXIFR::JPEG.new(src.to_s).orientation.to_i)
          src.copy(dst)
          args = %W[-autorot #{dst}]
          resolve_bin!(:jpegtran)
          execute(:jhead, *args) && dst.size?
        else
          false
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
image_optim-0.17.1 lib/image_optim/worker/jhead.rb
image_optim-0.17.0 lib/image_optim/worker/jhead.rb
image_optim-0.16.0 lib/image_optim/worker/jhead.rb