Sha256: c03554c390cacbe37f89b0285816fd400a14f9a99c77543b5b932db6bf5a8cbd
Contents?: true
Size: 925 Bytes
Versions: 1
Compression:
Stored size: 925 Bytes
Contents
require 'image_optim/worker' require 'exifr/jpeg' class ImageOptim class Worker # http://www.sentex.net/~mwandel/jhead/ # # Jhead internally uses jpegtran which should be on path class Jhead < Worker TIMEOUT_OPTION = timeout_option ORIENTED = 2..8 # not top-left # Works on jpegs def image_formats [:jpeg] end # Run first, while exif is still present def run_order -10 end def used_bins [:jhead, :jpegtran] end 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 private def oriented?(image) exif = EXIFR::JPEG.new(image.to_s) ORIENTED.include?(exif.orientation.to_i) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
discourse_image_optim-0.26.1 | lib/image_optim/worker/jhead.rb |