psd 3.8.0 → 3.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 43595c7e888f62819c37d2d678a3c14f8091333e
4
- data.tar.gz: d2c512bdc4e9f0803bec3c8451494e9778b0e34d
2
+ SHA256:
3
+ metadata.gz: 1199316b606804a9a2c3812a1fcddc5e62d4171693ad201475ce833774bff52f
4
+ data.tar.gz: de991a2e3bb3c6eae0998d31baff59223510b6c07b0baebd41cea6e485656cab
5
5
  SHA512:
6
- metadata.gz: f9a5fdc682dbacd83626a68802abd8b485ef7257cf7b6e487851fcb94e56aaa0dfba3ccc4fe2fec1e4810eae0d50a8b7218e9466633b73a686422b6289463f3d
7
- data.tar.gz: 0ed23ff08f47f66251b3853e884d9f7e197358ad19d83175583be1d568f8a530923834d4693bbf4a8e4110457204a3c9eb5ad331d95504b51170f12742ba4344
6
+ metadata.gz: 3299a64c6b5b21dd38d844bea52ae6d42c1ddd864e8b9a9e0bdccc6690d0340beae15852c3c682d74ef1fe658813aff233c350b3daf2e9dad97cca8d228cc4e1
7
+ data.tar.gz: ad77e3095d489ad3799a61d95b35e37a72e48adb6fd76b89b0160cb425e4b87c23132b4a3c998c3179d1ad0c9a5910a8c88d4f7a16d6ffbe140a5d2c8d69dca4
@@ -19,6 +19,7 @@ class PSD
19
19
  case @record_type
20
20
  when 0, 3 then read_path_record
21
21
  when 1, 2, 4, 5 then read_bezier_point
22
+ when 6 then read_path_fill_rule_record
22
23
  when 7 then read_clipboard_record
23
24
  when 8 then read_initial_fill
24
25
  else @file.seek(24, IO::SEEK_CUR)
@@ -93,6 +94,10 @@ class PSD
93
94
  @leaving_horiz = @file.read_path_number
94
95
  end
95
96
 
97
+ def read_path_fill_rule_record
98
+ @file.seek(24, IO::SEEK_CUR)
99
+ end
100
+
96
101
  def read_clipboard_record
97
102
  @clipboard_top = @file.read_path_number
98
103
  @clipboard_left = @file.read_path_number
@@ -107,4 +112,4 @@ class PSD
107
112
  @file.seek(22, IO::SEEK_CUR)
108
113
  end
109
114
  end
110
- end
115
+ end
@@ -2,9 +2,15 @@ class PSD
2
2
  class Resource
3
3
  module Section
4
4
  def self.factory(file, resource)
5
+ if path_resource?(resource)
6
+ section = Section::SavedPath.new(file, resource)
7
+ section.parse
8
+ return section.name
9
+ end
10
+
5
11
  Section.constants.each do |c|
6
12
  next if c == :Base
7
-
13
+
8
14
  section = Section.const_get(c)
9
15
  next unless section.resource_id == resource.id
10
16
 
@@ -14,6 +20,10 @@ class PSD
14
20
 
15
21
  return nil
16
22
  end
23
+
24
+ def self.path_resource?(resource)
25
+ resource.id >= 2000 && resource.id <= 2997
26
+ end
17
27
  end
18
28
  end
19
- end
29
+ end
@@ -7,7 +7,7 @@ class PSD
7
7
  class Resources
8
8
  attr_reader :resources
9
9
  alias :data :resources
10
-
10
+
11
11
  def initialize(file)
12
12
  @file = file
13
13
  @resources = {}
@@ -47,6 +47,13 @@ class PSD
47
47
  end
48
48
  end
49
49
 
50
+ # Paths exist between resource ID 2000 and 2997
51
+ def saved_paths
52
+ @resources.
53
+ select { |id, r| id >= 2000 && id <= 2997 }.
54
+ map { |id, r| r }
55
+ end
56
+
50
57
  def by_type(id)
51
58
  @resources[@type_index[id]]
52
59
  end
@@ -26,5 +26,8 @@ end
26
26
 
27
27
  require 'psd/resources/guides'
28
28
  require 'psd/resources/layer_comps'
29
+ require 'psd/resources/resolution_info'
30
+ require 'psd/resources/saved_path'
29
31
  require 'psd/resources/slices'
32
+ require 'psd/resources/work_path'
30
33
  require 'psd/resources/xmp_metadata'
@@ -0,0 +1,48 @@
1
+ require 'psd/resources/base'
2
+
3
+ class PSD
4
+ class Resource
5
+ module Section
6
+ class ResolutionInfo < Base
7
+ RES_UNIT_NAMES = %w(pixel/inch pixel/cm).freeze
8
+ UNIT_NAMES = %w(in cm pt picas columns).freeze
9
+
10
+ resource_id 1005
11
+ name :resolution_info
12
+
13
+ attr_reader :h_res, :h_res_unit, :width_unit
14
+ attr_reader :v_res, :v_res_unit, :height_unit
15
+
16
+ def parse
17
+ # 32-bit fixed-point number (16.16)
18
+ @h_res = @file.read_uint.to_f / (1 << 16)
19
+ @h_res_unit = @file.read_ushort
20
+ @width_unit = @file.read_ushort
21
+
22
+ # 32-bit fixed-point number (16.16)
23
+ @v_res = @file.read_uint.to_f / (1 << 16)
24
+ @v_res_unit = @file.read_ushort
25
+ @height_unit = @file.read_ushort
26
+
27
+ @resource.data = self
28
+ end
29
+
30
+ def h_res_unit_name
31
+ RES_UNIT_NAMES.fetch(h_res_unit - 1, 'unknown')
32
+ end
33
+
34
+ def v_res_unit_name
35
+ RES_UNIT_NAMES.fetch(v_res_unit - 1, 'unknown')
36
+ end
37
+
38
+ def width_unit_name
39
+ UNIT_NAMES.fetch(width_unit - 1, 'unknown')
40
+ end
41
+
42
+ def height_unit_name
43
+ UNIT_NAMES.fetch(height_unit - 1, 'unknown')
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,19 @@
1
+ require 'psd/resources/base'
2
+
3
+ class PSD
4
+ class Resource
5
+ module Section
6
+ class SavedPath < Base
7
+ def parse
8
+ paths = []
9
+ record_count = @resource.size / 26
10
+ record_count.times do
11
+ paths << PathRecord.new(@file)
12
+ end
13
+
14
+ @resource.data = paths
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,22 @@
1
+ require 'psd/resources/base'
2
+
3
+ class PSD
4
+ class Resource
5
+ module Section
6
+ class WorkPath < Base
7
+ resource_id 1025
8
+ name :work_path
9
+
10
+ def parse
11
+ paths = []
12
+ record_count = @resource.size / 26
13
+ record_count.times do
14
+ paths << PathRecord.new(@file)
15
+ end
16
+
17
+ @resource.data = paths
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -1,3 +1,3 @@
1
1
  class PSD
2
- VERSION = "3.8.0"
2
+ VERSION = "3.9.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: psd
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.8.0
4
+ version: 3.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan LeFevre
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-01-29 00:00:00.000000000 Z
12
+ date: 2018-01-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -249,7 +249,10 @@ files:
249
249
  - lib/psd/resources/base.rb
250
250
  - lib/psd/resources/guides.rb
251
251
  - lib/psd/resources/layer_comps.rb
252
+ - lib/psd/resources/resolution_info.rb
253
+ - lib/psd/resources/saved_path.rb
252
254
  - lib/psd/resources/slices.rb
255
+ - lib/psd/resources/work_path.rb
253
256
  - lib/psd/resources/xmp_metadata.rb
254
257
  - lib/psd/slice.rb
255
258
  - lib/psd/slices.rb
@@ -301,33 +304,33 @@ required_rubygems_version: !ruby/object:Gem::Requirement
301
304
  version: '0'
302
305
  requirements: []
303
306
  rubyforge_project:
304
- rubygems_version: 2.4.6
307
+ rubygems_version: 2.7.0
305
308
  signing_key:
306
309
  specification_version: 4
307
310
  summary: General purpose library for parsing Photoshop files
308
311
  test_files:
309
- - spec/files/alignment_modes.psd
310
- - spec/files/blendmodes.psd
311
- - spec/files/empty-layer-subgroups.psd
312
+ - spec/spec_helper.rb
313
+ - spec/psb_parsing_spec.rb
314
+ - spec/slices_spec.rb
315
+ - spec/guides_spec.rb
316
+ - spec/parsing_spec.rb
317
+ - spec/image_spec.rb
318
+ - spec/lazy_execute_spec.rb
319
+ - spec/locked_spec.rb
320
+ - spec/text_spec.rb
321
+ - spec/files/slices.psd
312
322
  - spec/files/empty-layer.psd
313
- - spec/files/example.psb
314
- - spec/files/example.psd
315
- - spec/files/guides.psd
316
- - spec/files/locked.psd
317
- - spec/files/one_layer.psd
318
323
  - spec/files/path.psd
319
324
  - spec/files/pixel.psd
325
+ - spec/files/one_layer.psd
326
+ - spec/files/alignment_modes.psd
327
+ - spec/files/locked.psd
320
328
  - spec/files/simplest.psd
321
- - spec/files/slices.psd
329
+ - spec/files/blendmodes.psd
330
+ - spec/files/example.psd
322
331
  - spec/files/text.psd
323
- - spec/guides_spec.rb
332
+ - spec/files/example.psb
333
+ - spec/files/empty-layer-subgroups.psd
334
+ - spec/files/guides.psd
324
335
  - spec/hierarchy_spec.rb
325
- - spec/image_spec.rb
326
- - spec/lazy_execute_spec.rb
327
- - spec/locked_spec.rb
328
- - spec/parsing_spec.rb
329
- - spec/psb_parsing_spec.rb
330
336
  - spec/psd_spec.rb
331
- - spec/slices_spec.rb
332
- - spec/spec_helper.rb
333
- - spec/text_spec.rb