Created
May 11, 2016 14:20
-
-
Save lassebunk/3c122fe9501ad1cb24e7f8229566469c to your computer and use it in GitHub Desktop.
Ruby script for converting Glyphish SVG files to PDF for vector usage in Xcode
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
#!/usr/bin/env ruby | |
require "fileutils" | |
indir, outdir = ARGV | |
unless indir && !indir.empty? && outdir && !outdir.empty? | |
puts "Usage: glyphish-convert.rb <indir> <outdir>" | |
exit | |
end | |
FileUtils.mkdir_p outdir | |
Dir.glob("#{indir}/**/*.svg").each do |file| | |
filename = File.basename(file) | |
destfile = filename.gsub(/^\d+-/, "").gsub("@2x", "").gsub(/\.svg$/, ".pdf") | |
puts "#{filename}..." | |
`rsvg-convert -f pdf -z 0.5 -o "#{outdir}/#{destfile}" "#{file}"` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
glyphish-convert.rb <indir> <outdir>
. Directory will be traversed recursively.chmod +x glyphish-convert.rb
rsvg-convert
can be installed usingbrew install librsvg