Sha256: bb2a02278b75b5db91e5aac830a74774e65fcd39ccd8dc8f152103aed322b61b
Contents?: true
Size: 1.3 KB
Versions: 2
Compression:
Stored size: 1.3 KB
Contents
#!/usr/bin/env ruby require 'optparse' require 'geohydra' def do_file fn, flags if fn =~ %r{^(.*)\.(shp|tif)\.xml$}i puts "Processing #{fn} for JPEG" if flags[:verbose] GeoHydra::Transform.extract_thumbnail fn, File.join(File.dirname(fn), 'preview.jpg') else raise OptionParser::InvalidOption, "File <#{fn}> is not ESRI metadata format" end end flags = { :datadir => '.', :recurse => false, :verbose => false } optparse = OptionParser.new do |opts| opts.banner = <<EOM Usage: #{File.basename(__FILE__)} [options] [fn [fn...]] EOM opts.on("-d", "--dir DIR", "Process all files in DIR (default: #{flags[:datadir]})") do |v| flags[:datadir] = v end opts.on("-r", "--recursive", "Process all files recurvisely") do |v| flags[:recurse] = true end opts.on("-v", "--verbose", "Run verbosely") do |v| flags[:verbose] = true end end begin optparse.parse! if ARGV.empty? raise OptionParser::InvalidOption, flags[:datadir] + ' not a directory' unless File.directory?(flags[:datadir]) Dir.glob(flags[:datadir] + (flags[:recurse] ? '/**/*.shp.xml' : '/*.shp.xml')).each {|fn| do_file fn, flags } else ARGV.each {|fn| do_file fn, flags } end rescue OptionParser::InvalidOption, OptionParser::MissingArgument => e $stderr.puts e $stderr.puts optparse exit(-1) end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
geohydra-0.3.1 | bin/extract_thumbnail.rb |
geohydra-0.3 | bin/extract_thumbnail.rb |