class ImageOptim::Worker::Jhead

www.sentex.net/~mwandel/jhead/

Jhead internally uses jpegtran which should be on path

Constants

ORIENTED

Public Instance Methods

image_formats() click to toggle source

Works on jpegs

# File lib/image_optim/worker/jhead.rb, line 15
def image_formats
  [:jpeg]
end
optimize(src, dst, options = {}) click to toggle source
# 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_order() click to toggle source

Run first, while exif is still present

# File lib/image_optim/worker/jhead.rb, line 20
def run_order
  -10
end
used_bins() click to toggle source
# File lib/image_optim/worker/jhead.rb, line 24
def used_bins
  [:jhead, :jpegtran]
end

Private Instance Methods

oriented?(image) click to toggle source
# File lib/image_optim/worker/jhead.rb, line 42
def oriented?(image)
  exif = EXIFR::JPEG.new(image.to_s)
  ORIENTED.include?(exif.orientation.to_i)
end