Last active
March 9, 2016 23:15
-
-
Save peterkappus/b79e583dce84c834c70b to your computer and use it in GitHub Desktop.
Easily convert an SVG file into the various files required to sell things on Society 6.
This file contains 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
#usage: ruby build... [INPUT_FILE] | |
#what it does: makes a folder named after the input file and builds the necessary versions for S6 | |
#requirements: rsvg-convert to rasterise the SVG and imagemagick to make the versions | |
file = ARGV[0] or abort ("No input file specified.") | |
big_width = 6500 | |
basename = File::basename(file,".svg") | |
Dir::mkdir(basename,0700) unless File.exists? basename | |
#make initial big version | |
#puts "rsvg-convert #{file} -o #{basename}_master.jpg -w #{big_width}" | |
out = "#{basename}/master.jpg" | |
puts "building #{out}" | |
`rsvg-convert #{file} -o #{basename}/master.jpg -w #{big_width}` | |
sizes = { | |
:thumbnail => "600x", | |
:laptop_case => "4600x3000", | |
:t_shirt => "3300x5100", | |
:mobile_device => "1300x2000", | |
:throw_pillow_or_clock => "6500x6500", | |
:all_over_shirt => "6000x6000", | |
:tapestry_portrait => "5525x6500", | |
:tapestry_landscape => "6500x5525", | |
:travel_mug => "2697x1518px", | |
:mug => "4600x2000" | |
} | |
#make all sizes | |
sizes.keys.each do |key| | |
output = "#{basename}/#{key.to_s}.jpg" | |
puts "Building #{output}" | |
`convert #{basename}/master.jpg -resize #{sizes[key]}^ -gravity center -extent #{sizes[key]} #{output}` | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment