Skip to content

Instantly share code, notes, and snippets.

@satococoa
Created November 15, 2011 09:44
Show Gist options
  • Save satococoa/1366584 to your computer and use it in GitHub Desktop.
Save satococoa/1366584 to your computer and use it in GitHub Desktop.
sipsで画像のコピー&リサイズ。@2x.png
require 'pp'
require 'pathname'
resize_command = 'sips -z 34 34 --out out/%2$s %1$s'
copy_command = 'cp %s out/%s'
Pathname.glob('./*').sort.each_with_index do |path, idx|
next unless path.to_s.match(/png$/)
system(copy_command % [path.to_s, idx.to_s+'@2x.png'])
system(resize_command % [path.to_s, idx.to_s+'.png'])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment