Skip to content

Instantly share code, notes, and snippets.

@satococoa
Created April 3, 2013 02:09
Show Gist options
  • Select an option

  • Save satococoa/5297892 to your computer and use it in GitHub Desktop.

Select an option

Save satococoa/5297892 to your computer and use it in GitHub Desktop.
@2x.png をつけてリネーム -> 1/2サイズに縮小した画像を生成
require 'pathname'
resize_command = 'sips -z 34 34 --out out/%2$s %1$s'
copy_command = 'cp %s out/%s'
Pathname.glob('./in/*').sort.each_with_index do |path|
next unless path.to_s.match(/png$/)
basename = path.basename('.png').to_s
system(copy_command % [path.to_s, basename+'@2x.png'])
system(resize_command % [path.to_s, basename+'.png'])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment