Created
November 16, 2012 12:35
-
-
Save srgtuszy/4086991 to your computer and use it in GitHub Desktop.
A script for resizing retina images for regular screens
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
require 'RMagick' | |
def resize_image (image_path, write_path) | |
image = Magick::Image.read(image_path).first | |
new_image = image.scale(0.5) | |
puts "Writing image #{write_path}..." | |
new_image.write(write_path) | |
end | |
directory_path = ARGV[0] | |
dir_contents = Dir.entries(directory_path) | |
dir_contents.each do |f| | |
next if f.include?("@2x") == false | |
puts "Resizing #{f}..." | |
new_name = f.sub("@2x", "") | |
image_path = "#{directory_path}#{f}" | |
write_path = "#{directory_path}#{new_name}" | |
resize_image(image_path, write_path) | |
end | |
puts "Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment