Class: ImageOptim::Worker::Jhead

Inherits:
ImageOptim::Worker show all
Defined in:
lib/image_optim/worker/jhead.rb

Overview

www.sentex.net/~mwandel/jhead/

Jhead internally uses jpegtran which should be on path

Instance Method Summary collapse

Methods inherited from ImageOptim::Worker

#<=>, bin_sym, inherited, #initialize, klasses, #optimized?, option, option_definitions

Constructor Details

This class inherits a constructor from ImageOptim::Worker

Instance Method Details

#image_formatsObject

Works on jpegs



11
12
13
# File 'lib/image_optim/worker/jhead.rb', line 11

def image_formats
  [:jpeg]
end

#optimize(src, dst) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/image_optim/worker/jhead.rb', line 20

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

#run_orderObject

Run first [-10]



16
17
18
# File 'lib/image_optim/worker/jhead.rb', line 16

def run_order
  -10
end