lib/appiconset/generator.rb in appiconset-2.4.0 vs lib/appiconset/generator.rb in appiconset-2.5.0

- old
+ new

@@ -152,10 +152,44 @@ new_image.write(output_dir + name) end end end + # icnsアイコン + def icns_platforms + return unless @width == 1024 && @height == 1024 + + show_info('icns.iconset') + + output_dir = "#{@output}icns.iconset/" + FileUtils.mkdir_p(output_dir) + + sizes = [512, 256, 128, 64, 32, 16] + sizes.each do |size| + [2, 1].each do |scale| + if scale == 2 + name = "icon_#{size}x#{size}@2x.png" + new_size = size * scale + else + name = "icon_#{size}x#{size}.png" + new_size = size + end + + image = Magick::ImageList.new(@input) + new_image = image.resize_to_fit(new_size, new_size) + new_image.format = 'PNG' + new_image.write(output_dir + name) + end + end + + return unless RUBY_PLATFORM.match(/darwin/) + + # macOSで実行可能 + show_info('icns') + system("iconutil -c icns #{output_dir}") + end + def show_info(platform_name) - puts "Created #{platform_name} icons from #{@width} x #{@height} image." + puts "Created #{platform_name} icon(s) from #{@width} x #{@height} image." end end end