Class: RubySpriter::MetadataManager
- Inherits:
-
Object
- Object
- RubySpriter::MetadataManager
- Defined in:
- lib/ruby_spriter/metadata_manager.rb
Overview
Manages PNG metadata for spritesheets
Constant Summary collapse
- METADATA_PREFIX =
'SPRITESHEET'- METADATA_VERSION =
RubySpriter::VERSION
Class Method Summary collapse
-
.embed(input_file, output_file, columns:, rows:, frames:, debug: false) ⇒ Object
Embed metadata into PNG file.
-
.read(file) ⇒ Hash?
Read metadata from PNG file.
-
.verify(file) ⇒ Object
Verify and print metadata from file.
Class Method Details
.embed(input_file, output_file, columns:, rows:, frames:, debug: false) ⇒ Object
Embed metadata into PNG file
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ruby_spriter/metadata_manager.rb', line 18 def self.(input_file, output_file, columns:, rows:, frames:, debug: false) Utils::FileHelper.validate_readable!(input_file) = (columns, rows, frames) cmd = (input_file, output_file, ) if debug Utils::OutputFormatter.indent("DEBUG: Metadata command: #{cmd}") end stdout, stderr, status = Open3.capture3(cmd) unless status.success? raise ProcessingError, "Failed to embed metadata: #{stderr}" end Utils::FileHelper.validate_exists!(output_file) end |
.read(file) ⇒ Hash?
Read metadata from PNG file
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/ruby_spriter/metadata_manager.rb', line 41 def self.read(file) Utils::FileHelper.validate_readable!(file) cmd = build_read_command(file) stdout, stderr, status = Open3.capture3(cmd) return nil unless status.success? (stdout) end |
.verify(file) ⇒ Object
Verify and print metadata from file
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/ruby_spriter/metadata_manager.rb', line 54 def self.verify(file) Utils::OutputFormatter.header("Spritesheet Metadata Verification") puts "File: #{file}" puts "Size: #{Utils::FileHelper.format_size(File.size(file))}\n\n" = read(file) if Utils::OutputFormatter.success("Metadata Found") puts "\n Grid Layout:" Utils::OutputFormatter.indent("Columns: #{[:columns]}") Utils::OutputFormatter.indent("Rows: #{[:rows]}") Utils::OutputFormatter.indent("Total Frames: #{[:frames]}") Utils::OutputFormatter.indent("Metadata Version: #{[:version]}") else Utils::OutputFormatter.warning("No spritesheet metadata found in this file") puts "\nThis file may not have been created by Ruby Spriter," puts "or the metadata was stripped during processing." end puts "\n" + "=" * 60 + "\n" end |