Skip to content

Instantly share code, notes, and snippets.

@jikkujose
Created December 10, 2018 04:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jikkujose/0c9fd3750137b1c751c961a30a84eb36 to your computer and use it in GitHub Desktop.
Save jikkujose/0c9fd3750137b1c751c961a30a84eb36 to your computer and use it in GitHub Desktop.
DSLR image import
#! /usr/bin/env ruby
require 'fileutils'
def resize(image_file, resolution = 1920, resize_directory = "resized")
basename = File.basename(image_file, ".CR2").split(".")[0]
FileUtils.mkdir_p resize_directory
%x|sips -Z #{resolution} -s format jpeg "#{image_file}" --out "#{resize_directory}/#{basename}.jpg"|
end
p ARGV
original_directory = ARGV[0]
resized_directory = "/Users/jikkujose/Desktop/ShutterFins/#{ARGV[1]}"
resolution = ARGV[2] || 480
images = Dir.glob("#{original_directory}/*")
if (File.directory?(resized_directory))
fail 'Directory exists'
end
images.each.with_index do |image, index|
puts "#{index + 1} of #{images.length}"
resize(image, resolution, resized_directory)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment