Browse Source

add texture tool

master
Alison Watson 2 years ago
parent
commit
43dd9ec97d
  1. 25
      tools/texture

25
tools/texture

@ -0,0 +1,25 @@
#!/usr/bin/env ruby
require 'tmpdir'
require 'rmagick'
for f in $ARGV
out_name = File.realdirpath(f + ".texture")
im = Magick::Image.read(f).first
im.format = "TGA"
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
mip_num = 0
loop do
im.write "#{dir}/#{mip_num}"
mip_num += 1
im = im.minify
break if im.columns < 2 or im.rows < 2
end
files = Dir.children dir
system "tar", "--format=ustar", "-Ipigz", "-cf", out_name, *files
end
end
end
## EOF
Loading…
Cancel
Save