Sha256: 1aacefc3d7cc25ea341e5e887f447fa09e90b67db6eacd8dbc0ec58cca35c677

Contents?: true

Size: 931 Bytes

Versions: 31

Compression:

Stored size: 931 Bytes

Contents

class PSD
  class Layer
    module Name
      # Gets the name of this layer. If the PSD file is from an even remotely
      # recent version of Photoshop, this data is stored as extra layer info and
      # as a UTF-16 name. Otherwise, it's stored in a legacy block.
      def name
        if @adjustments.has_key?(:name)
          return @adjustments[:name].data
        end

        return @legacy_name
      end

      private

      # The old school layer names are encoded in MacRoman format,
      # not UTF-8. Luckily Ruby kicks ass at character conversion.
      def parse_legacy_layer_name
        @legacy_name_start = @file.tell

        len = Util.pad4 @file.read(1).bytes.to_a[0]
        @legacy_name = @file.read_string(len)

        @legacy_name_end = @file.tell
      end

      def export_legacy_layer_name(outfile)
        outfile.write @file.read(@legacy_name_end - @legacy_name_start)
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 2 rubygems

Version Path
psd-3.9.0 lib/psd/layer/name.rb
psd-3.8.0 lib/psd/layer/name.rb
psd-3.7.0 lib/psd/layer/name.rb
psd-3.6.0 lib/psd/layer/name.rb
bench9000-0.1 vendor/psd.rb/lib/psd/layer/name.rb
psd-3.5.0 lib/psd/layer/name.rb
psd-3.4.0 lib/psd/layer/name.rb
psd-3.3.3 lib/psd/layer/name.rb
psd-3.3.2 lib/psd/layer/name.rb
psd-3.3.1 lib/psd/layer/name.rb
psd-3.2.4 lib/psd/layer/name.rb
psd-3.2.3 lib/psd/layer/name.rb
psd-3.2.2 lib/psd/layer/name.rb
psd-3.2.1 lib/psd/layer/name.rb
psd-3.2.0 lib/psd/layer/name.rb
psd-3.1.5 lib/psd/layer/name.rb
psd-3.1.4 lib/psd/layer/name.rb
psd-3.1.3 lib/psd/layer/name.rb
psd-3.1.2 lib/psd/layer/name.rb
psd-2.1.2 lib/psd/layer/name.rb