Sha256: 1a97b59fccc1de7d9e7aa31fc8437251d1f5083193f470e2bd664189fbf1cc5e
Contents?: true
Size: 1.04 KB
Versions: 18
Compression:
Stored size: 1.04 KB
Contents
require 'shellwords' module Snapshot # This class takes care of rotating images class ScreenshotRotate # @param (String) The path in which the screenshots are located in def run(path) Helper.log.debug "Going to rotate screenshots from generated png files" rotate(path) end def rotate(path) Dir.glob([path, '/**/*.png'].join('/')).each do |file| Helper.log.debug "Rotating '#{file}'" command = nil if file.end_with? "landscapeleft.png" command = "sips -r -90 '#{file}'" elsif file.end_with? "landscaperight.png" command = "sips -r 90 '#{file}'" elsif file.end_with? "portrait_upsidedown.png" command = "sips -r 180 '#{file}'" end # Only rotate if we need to if command PTY.spawn( command ) do |r, w, pid| r.sync r.each do |line| # We need to read this otherwise things hang end ::Process.wait pid end end end end end end
Version data entries
18 entries across 18 versions & 1 rubygems