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


13
14
15
# File 'lib/image_optim/worker/jhead.rb', line 13

def image_formats
  [:jpeg]
end

#optimize(src, dst) ⇒ Object


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

def optimize(src, dst)
  return false unless oriented?(src)

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

#run_orderObject

Run first, while exif is still present


18
19
20
# File 'lib/image_optim/worker/jhead.rb', line 18

def run_order
  -10
end

#used_binsObject


22
23
24
# File 'lib/image_optim/worker/jhead.rb', line 22

def used_bins
  [:jhead, :jpegtran]
end