diff --git a/PlistExplorer b/PlistExplorer new file mode 100755 index 0000000..58491b0 Binary files /dev/null and b/PlistExplorer differ diff --git a/find-unused-images b/find-unused-images new file mode 100755 index 0000000..dc1ce31 --- /dev/null +++ b/find-unused-images @@ -0,0 +1,9 @@ +#!/bin/bash + +for i in `find . -name "*.png" -o -name "*.jpg"`; do + file=`basename -s .jpg "$i" | xargs basename -s .png | xargs basename -s @2x | xargs basename -s @3x` + result=`ack -i "$file"` + if [ -z "$result" ]; then + echo "$i" + fi +done diff --git a/generate-xcode-imageset b/generate-xcode-imageset new file mode 100755 index 0000000..60a39d0 --- /dev/null +++ b/generate-xcode-imageset @@ -0,0 +1,48 @@ +#!/usr/bin/env ruby -w + +require 'json' + +def main + while dir = ARGV.shift + unless File.directory? dir + puts "[warn] Skipping non-directory: #{dir}" + next + end + + all_images = Dir[File.join(dir, '*@[23]x.png')].map { |f| File.basename f } + image3x = File.basename Dir[File.join(dir, '*@3x.png')].first + image2x = File.basename Dir[File.join(dir, '*@2x.png')].first + image1x = (all_images - [image2x, image3x]).first + unless [2, 3].include?(all_images.size) && image2x && image3x + puts "[warn] Skipping #{dir} because 2x and 3x images are required. 1x image is optional. Max 3 images." + next + end + + images = [image1x, image2x, image3x] + scale = 0 + imageset_images = images + .map { |filename| + scale += 1 + filename && { + idiom: 'universal', + filename: filename, + scale: "#{scale}x" + } + } + .compact + imageset = { + images: imageset_images, + info: { + version: 1, + author: 'generate-xcode-imageset' + } + } + json = JSON.pretty_generate(imageset) + path = File.join(dir, 'Contents.json') + File.write(path, json) + images_written = images.compact + puts "* Wrote #{images_written.size} images to #{path}: #{images_written.join(', ')}" + end +end + +main if $0 == __FILE__ diff --git a/svg-to-ios-pngs.rb b/svg-to-ios-pngs.rb new file mode 100755 index 0000000..43ec021 --- /dev/null +++ b/svg-to-ios-pngs.rb @@ -0,0 +1,24 @@ +#!/usr/bin/env ruby -w + +svg_path = ARGV.shift +png_path = ARGV.shift + +png_test_path = "/tmp/identify.png" +File.unlink(png_test_path) if File.exist?(png_test_path) +puts `inkscape -z -e '#{png_test_path}' -d 72 '#{svg_path}'` +info = `identify '#{png_test_path}'` +File.unlink(png_test_path) if File.exist?(png_test_path) +dimensions = info.split[2] +width, height = dimensions.split('x').map(&:to_i) +if width == 0 || height == 0 + $stderr.puts "Failed to get SVG dimensions" + exit 1 +end + +name = File.basename(svg_path).sub /\.svg$/, '' + +png_2x_path = File.join(png_path, "#{name}@2x.png") +puts `inkscape -z -e '#{png_2x_path}' -w #{2 * width} -h #{2 * height} -d 72 '#{svg_path}'` + +png_3x_path = File.join(png_path, "#{name}@3x.png") +puts `inkscape -z -e '#{png_3x_path}' -w #{3 * width} -h #{3 * height} -d 27 '#{svg_path}'`