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 13
def image_formats
  [:jpeg]
end
optimize(src, dst) click to toggle source
# 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_order() click to toggle source

Run first, while exif is still present

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

Private Instance Methods

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