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

Constant Summary collapse

ORIENTED =

not top-left

(2..8).freeze

Instance Method Summary collapse

Methods inherited from ImageOptim::Worker

#initialize, #inspect, #optimized?, #options, #resolve_used_bins!

Methods included from ClassMethods

#bin_sym, #create_all, #create_all_by_format, extended, #inherited, #klasses, #option, #option_definitions

Constructor Details

This class inherits a constructor from ImageOptim::Worker

Instance Method Details

#image_formatsObject

Works on jpegs



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

def image_formats
  [:jpeg]
end

#optimize(src, dst, options = {}) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/image_optim/worker/jhead.rb', line 28

def optimize(src, dst, options = {})
  return false unless oriented?(src)

  src.copy(dst)
  args = %W[
    -autorot
    #{dst}
  ]
  resolve_bin!(:jpegtran)
  execute(:jhead, args, options) && dst.size?
end

#run_orderObject

Run first, while exif is still present



20
21
22
# File 'lib/image_optim/worker/jhead.rb', line 20

def run_order
  -10
end

#used_binsObject



24
25
26
# File 'lib/image_optim/worker/jhead.rb', line 24

def used_bins
  [:jhead, :jpegtran]
end