Browse Source

add texture tool

master
Alison Watson 1 month ago
parent
commit
43dd9ec97d
1 changed files with 25 additions and 0 deletions
  1. +25
    -0
      tools/texture

+ 25
- 0
tools/texture View File

@@ -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