psd 3.3.3 → 3.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/psd/header.rb +5 -1
- data/lib/psd/image_formats/layer_rle.rb +2 -2
- data/lib/psd/layer/info.rb +11 -1
- data/lib/psd/layer/position_and_channels.rb +2 -2
- data/lib/psd/layer_mask.rb +17 -4
- data/lib/psd/nodes/group.rb +1 -0
- data/lib/psd/version.rb +1 -1
- data/spec/files/example.psb +0 -0
- data/spec/psb_parsing_spec.rb +57 -0
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d022d5b521a64f3578c5755ba18d5bbc1f419ea
|
4
|
+
data.tar.gz: 3f72cd4899c112f55171eab1f96629e354d1eb9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed4a582c87fd81ee3a6a19d487cea8fa6e388740e16097e185268581af549d032c125b3d66fde8dfe52ec0af2f4d67c57bce0990030e3eb7b8f06b18b1b62c51
|
7
|
+
data.tar.gz: dce119bc89f527695fbd46229fbd82447d23722b60f19002afb0984bb10e3c7aee992ba301ad7f53cdd15ea4ad6277e47a2842ec21ca9bc17941e5ff4d561475
|
data/lib/psd/header.rb
CHANGED
@@ -7,7 +7,7 @@ class PSD
|
|
7
7
|
def parse_byte_counts!
|
8
8
|
byte_counts = []
|
9
9
|
height.times do
|
10
|
-
byte_counts << @file.read_short
|
10
|
+
byte_counts << (@header.big? ? @file.read_int : @file.read_short)
|
11
11
|
end
|
12
12
|
|
13
13
|
return byte_counts
|
@@ -21,4 +21,4 @@ class PSD
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
24
|
-
end
|
24
|
+
end
|
data/lib/psd/layer/info.rb
CHANGED
@@ -51,6 +51,8 @@ class PSD
|
|
51
51
|
gradient_fill: GradientFill
|
52
52
|
}.freeze
|
53
53
|
|
54
|
+
BIG_LAYER_INFO_KEYS = %w{ LMsk Lr16 Lr32 Layr Mt16 Mt32 Mtrn Alph FMsk lnk2 FEid FXid PxSD }
|
55
|
+
|
54
56
|
attr_reader :adjustments
|
55
57
|
alias :info :adjustments
|
56
58
|
|
@@ -60,6 +62,14 @@ class PSD
|
|
60
62
|
|
61
63
|
private
|
62
64
|
|
65
|
+
def parse_additional_layer_info_length(key)
|
66
|
+
if @header.big? && BIG_LAYER_INFO_KEYS.include?(key)
|
67
|
+
Util.pad2 @file.read_longlong
|
68
|
+
else
|
69
|
+
Util.pad2 @file.read_int
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
63
73
|
# This section is a bit tricky to parse because it represents all of the
|
64
74
|
# extra data that describes this layer.
|
65
75
|
def parse_layer_info
|
@@ -73,7 +83,7 @@ class PSD
|
|
73
83
|
key = @file.read_string(4)
|
74
84
|
@info_keys << key
|
75
85
|
|
76
|
-
length =
|
86
|
+
length = parse_additional_layer_info_length(key)
|
77
87
|
pos = @file.tell
|
78
88
|
|
79
89
|
key_parseable = false
|
@@ -21,7 +21,7 @@ class PSD
|
|
21
21
|
|
22
22
|
@channels.times do
|
23
23
|
channel_id = @file.read_short
|
24
|
-
channel_length = @file.read_int
|
24
|
+
channel_length = @header.big? ? @file.read_longlong : @file.read_int
|
25
25
|
|
26
26
|
@channels_info << {id: channel_id, length: channel_length}
|
27
27
|
end
|
@@ -40,4 +40,4 @@ class PSD
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
43
|
-
end
|
43
|
+
end
|
data/lib/psd/layer_mask.rb
CHANGED
@@ -18,13 +18,14 @@ class PSD
|
|
18
18
|
# Allows us to skip this section because it starts with the length of the section
|
19
19
|
# stored as an integer.
|
20
20
|
def skip
|
21
|
-
@file.seek
|
21
|
+
@file.seek parse_mask_size, IO::SEEK_CUR
|
22
22
|
return self
|
23
23
|
end
|
24
24
|
|
25
25
|
# Parse this section, including all of the layers and folders.
|
26
26
|
def parse
|
27
|
-
mask_size =
|
27
|
+
mask_size = parse_mask_size
|
28
|
+
|
28
29
|
start_position = @file.tell
|
29
30
|
finish = start_position + mask_size
|
30
31
|
|
@@ -49,8 +50,20 @@ class PSD
|
|
49
50
|
|
50
51
|
private
|
51
52
|
|
53
|
+
def parse_mask_size
|
54
|
+
@header.big? ? @file.read_longlong : @file.read_int
|
55
|
+
end
|
56
|
+
|
57
|
+
def parse_layer_info_size
|
58
|
+
Util.pad2(@header.big? ? @file.read_longlong : @file.read_int)
|
59
|
+
end
|
60
|
+
|
61
|
+
def channel_information_length
|
62
|
+
@header.big? ? 10 : 6
|
63
|
+
end
|
64
|
+
|
52
65
|
def parse_layers
|
53
|
-
layer_info_size =
|
66
|
+
layer_info_size = parse_layer_info_size
|
54
67
|
|
55
68
|
if layer_info_size > 0
|
56
69
|
layer_count = @file.read_short
|
@@ -60,7 +73,7 @@ class PSD
|
|
60
73
|
@merged_alpha = true
|
61
74
|
end
|
62
75
|
|
63
|
-
if layer_count * (18 +
|
76
|
+
if layer_count * (18 + channel_information_length * @header.channels) > layer_info_size
|
64
77
|
PSD.logger.error "Unlikely number of layers parsed: #{layer_count}"
|
65
78
|
end
|
66
79
|
|
data/lib/psd/nodes/group.rb
CHANGED
data/lib/psd/version.rb
CHANGED
Binary file
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Photoshop Big parsing' do
|
4
|
+
before(:each) do
|
5
|
+
@psd = PSD.new('spec/files/example.psb')
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'parses without error' do
|
9
|
+
@psd.parse!
|
10
|
+
expect(@psd).to be_parsed
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'Header' do
|
14
|
+
before(:each) do
|
15
|
+
@psd.parse!
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should contain data' do
|
19
|
+
expect(@psd.header).not_to be_nil
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should be the proper version' do
|
23
|
+
expect(@psd.header.version).to eq(2)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe 'Layer Mask' do
|
28
|
+
before(:each) do
|
29
|
+
@psd.parse!
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'contains data' do
|
33
|
+
expect(@psd.layer_mask).to_not be_nil
|
34
|
+
expect(@psd.layer_mask).to be_an_instance_of(PSD::LayerMask)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'contains layers' do
|
38
|
+
expect(@psd.layer_mask.layers.size).to be > 0
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe 'Layers' do
|
43
|
+
before(:each) do
|
44
|
+
@psd.parse!
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'contains each layer' do
|
48
|
+
expect(@psd.layer_mask.layers.size).to eq(2)
|
49
|
+
expect(@psd.layers).to be @psd.layer_mask.layers
|
50
|
+
@psd.layers.each { |l| expect(l).to be_an_instance_of(PSD::Layer) }
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'shows the proper layer names' do
|
54
|
+
expect(@psd.layers.map(&:name)).to match_array(['summer', 'haze'])
|
55
|
+
end
|
56
|
+
end
|
57
|
+
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.
|
4
|
+
version: 3.4.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: 2015-
|
12
|
+
date: 2015-10-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -234,6 +234,7 @@ files:
|
|
234
234
|
- spec/files/blendmodes.psd
|
235
235
|
- spec/files/empty-layer-subgroups.psd
|
236
236
|
- spec/files/empty-layer.psd
|
237
|
+
- spec/files/example.psb
|
237
238
|
- spec/files/example.psd
|
238
239
|
- spec/files/guides.psd
|
239
240
|
- spec/files/locked.psd
|
@@ -249,6 +250,7 @@ files:
|
|
249
250
|
- spec/lazy_execute_spec.rb
|
250
251
|
- spec/locked_spec.rb
|
251
252
|
- spec/parsing_spec.rb
|
253
|
+
- spec/psb_parsing_spec.rb
|
252
254
|
- spec/psd_spec.rb
|
253
255
|
- spec/slices_spec.rb
|
254
256
|
- spec/spec_helper.rb
|
@@ -273,7 +275,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
273
275
|
version: '0'
|
274
276
|
requirements: []
|
275
277
|
rubyforge_project:
|
276
|
-
rubygems_version: 2.4.
|
278
|
+
rubygems_version: 2.4.6
|
277
279
|
signing_key:
|
278
280
|
specification_version: 4
|
279
281
|
summary: General purpose library for parsing Photoshop files
|
@@ -282,6 +284,7 @@ test_files:
|
|
282
284
|
- spec/files/blendmodes.psd
|
283
285
|
- spec/files/empty-layer-subgroups.psd
|
284
286
|
- spec/files/empty-layer.psd
|
287
|
+
- spec/files/example.psb
|
285
288
|
- spec/files/example.psd
|
286
289
|
- spec/files/guides.psd
|
287
290
|
- spec/files/locked.psd
|
@@ -297,6 +300,7 @@ test_files:
|
|
297
300
|
- spec/lazy_execute_spec.rb
|
298
301
|
- spec/locked_spec.rb
|
299
302
|
- spec/parsing_spec.rb
|
303
|
+
- spec/psb_parsing_spec.rb
|
300
304
|
- spec/psd_spec.rb
|
301
305
|
- spec/slices_spec.rb
|
302
306
|
- spec/spec_helper.rb
|