Created
July 25, 2012 02:51
-
-
Save satococoa/3174106 to your computer and use it in GitHub Desktop.
ImageMagickで50%に画像を縮小(元ファイルはファイル名に@2xつけてコピー)
This file contains hidden or 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
| require 'pp' | |
| require 'pathname' | |
| input_dir = 'orig' | |
| output_dir = 'out' | |
| Pathname.glob("#{input_dir}/**/*.png").sort.each do |path| | |
| dist = Pathname(path.to_s.gsub(input_dir, output_dir)) | |
| dist.dirname.mkpath unless dist.dirname.exist? | |
| system('cp %s %s' % [path.to_s, dist.to_s.gsub('.png', '@2x.png')]) | |
| system('convert -scale 50%%x50%% %s %s' % [path.to_s, dist.to_s]) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment