Sha256: 0ca866877c273d2a921ea956847086cd770865eb9190fdcda30d58c1316e3d38

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

require 'benchmark'
require './lib/psd'

psd = nil
file = ARGV[0] || 'examples/images/example.psd'
results = Benchmark.measure "PSD parsing" do
  psd = PSD.new(file)
  psd.parse!
end

if psd.resources[:layer_comps]
  puts "\nLayer Comps:\n===================="
  puts psd.resources[:layer_comps].data.names
end

puts "\nVisible Layers:\n===================="
psd.layers.each do |layer|
  next if layer.folder? || layer.hidden?

  puts "Name: #{layer.name}"
  puts "Position: top = #{layer.top}, left = #{layer.left}"
  puts "Size: width = #{layer.width}, height = #{layer.height}"
  puts "Mask: width = #{layer.mask.width}, height = #{layer.mask.height}"
  puts "Reference point: #{layer.reference_point.x}, #{layer.reference_point.y}"

  puts ""
end

puts "\nPSD Info:\n===================="
puts "#{psd.width}x#{psd.height} #{psd.header.mode_name}"
puts "#{psd.resources.data.size} resources parsed"
puts "#{psd.layers.size} layers, #{psd.folders.size} folders"

puts "\nBenchmark Results (seconds):\n===================="
puts " "*7 + Benchmark::CAPTION
puts "parse: " + results.to_s

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bench9000-0.1 vendor/psd.rb/examples/parse.rb