psd 3.1.3 → 3.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/psd/layer/info.rb +4 -3
- data/lib/psd/layer_info/gradient_fill.rb +14 -0
- data/lib/psd/layer_mask.rb +42 -39
- data/lib/psd/nodes/build_preview.rb +1 -1
- data/lib/psd/nodes/root.rb +0 -4
- data/lib/psd/renderer.rb +5 -2
- data/lib/psd/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb7572d17b8e7e05b8b8b6843c83a22762494919
|
4
|
+
data.tar.gz: 6a818b7de688fb558af6beebebf08c09c302b2df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d91325e567d009ced2d66206c893ec04685ce4c10ed59353f6aba0487bf8934e32af53937f81e1aa4559a92672fa1948059f69fdb57a33194f0cdaeb2320695
|
7
|
+
data.tar.gz: 4ed05ad62147b7b47ca313288edfcce737e7da0dc5470f25b01d9b539494f1842c6f7d51ac1b4d4431c4d45eebf0e2353a6b79a97eb02017c6134c10d24169b8
|
data/lib/psd/layer/info.rb
CHANGED
@@ -23,7 +23,8 @@ class PSD
|
|
23
23
|
vector_mask: VectorMask,
|
24
24
|
vector_origination: VectorOrigination,
|
25
25
|
vector_stroke: VectorStroke,
|
26
|
-
vector_stroke_content: VectorStrokeContent
|
26
|
+
vector_stroke_content: VectorStrokeContent,
|
27
|
+
gradient_fill: GradientFill
|
27
28
|
}.freeze
|
28
29
|
|
29
30
|
attr_reader :adjustments
|
@@ -59,7 +60,7 @@ class PSD
|
|
59
60
|
|
60
61
|
i = info.new(self, length)
|
61
62
|
@adjustments[name] = LazyExecute.new(i, @file).now(:skip).later(:parse)
|
62
|
-
|
63
|
+
|
63
64
|
key_parseable = true and break
|
64
65
|
end
|
65
66
|
|
@@ -73,4 +74,4 @@ class PSD
|
|
73
74
|
end
|
74
75
|
end
|
75
76
|
end
|
76
|
-
end
|
77
|
+
end
|
data/lib/psd/layer_mask.rb
CHANGED
@@ -12,7 +12,7 @@ class PSD
|
|
12
12
|
|
13
13
|
@layers = []
|
14
14
|
@merged_alpha = false
|
15
|
-
@global_mask = nil
|
15
|
+
@global_mask = nil
|
16
16
|
end
|
17
17
|
|
18
18
|
# Allows us to skip this section because it starts with the length of the section
|
@@ -25,10 +25,29 @@ class PSD
|
|
25
25
|
# Parse this section, including all of the layers and folders.
|
26
26
|
def parse
|
27
27
|
mask_size = @file.read_int
|
28
|
-
|
28
|
+
start_position = @file.tell
|
29
|
+
finish = start_position + mask_size
|
29
30
|
|
30
31
|
return self if mask_size <= 0
|
31
32
|
|
33
|
+
parse_layers
|
34
|
+
parse_global_mask
|
35
|
+
|
36
|
+
consumed_bytes = @file.tell - start_position
|
37
|
+
parse_layer_tagged_blocks(mask_size - consumed_bytes)
|
38
|
+
|
39
|
+
# Layers are parsed in reverse order
|
40
|
+
layers.reverse!
|
41
|
+
|
42
|
+
# Ensure we're at the end of this section
|
43
|
+
@file.seek finish
|
44
|
+
|
45
|
+
self
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def parse_layers
|
32
51
|
layer_info_size = Util.pad2(@file.read_int)
|
33
52
|
|
34
53
|
if layer_info_size > 0
|
@@ -52,59 +71,43 @@ class PSD
|
|
52
71
|
layer.parse_channel_image(@header)
|
53
72
|
end
|
54
73
|
end
|
55
|
-
|
56
|
-
# Layers are parsed in reverse order
|
57
|
-
layers.reverse!
|
58
|
-
group_layers
|
59
|
-
|
60
|
-
parse_global_mask
|
61
|
-
|
62
|
-
# Ensure we're at the end of this section
|
63
|
-
@file.seek finish
|
64
|
-
|
65
|
-
return self
|
66
74
|
end
|
67
75
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
76
|
+
def parse_layer_tagged_blocks(remaining_length)
|
77
|
+
end_pos = @file.tell + remaining_length
|
78
|
+
|
79
|
+
while @file.tell < end_pos
|
80
|
+
res = parse_additional_layer_info_block
|
81
|
+
break unless res
|
73
82
|
end
|
83
|
+
end
|
74
84
|
|
75
|
-
|
76
|
-
|
85
|
+
def parse_additional_layer_info_block
|
86
|
+
sig = @file.read_string(4)
|
77
87
|
|
78
|
-
|
79
|
-
|
88
|
+
unless %w(8BIM 8B64).include?(sig)
|
89
|
+
@file.seek(-4, IO::SEEK_CUR)
|
90
|
+
return false
|
80
91
|
end
|
81
92
|
|
82
|
-
|
83
|
-
end
|
84
|
-
|
85
|
-
private
|
93
|
+
key = @file.read_string(4)
|
86
94
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
if layer.folder?
|
91
|
-
group_layer = layer
|
92
|
-
elsif layer.folder_end?
|
93
|
-
group_layer = nil
|
94
|
-
else
|
95
|
-
layer.group_layer = layer
|
96
|
-
end
|
95
|
+
if %w(Lr16 Lr32 Mt16).include?(key)
|
96
|
+
parse_layers
|
97
|
+
return true
|
97
98
|
end
|
99
|
+
|
100
|
+
false
|
98
101
|
end
|
99
102
|
|
100
103
|
def parse_global_mask
|
101
104
|
length = @file.read_int
|
102
|
-
|
105
|
+
|
103
106
|
PSD.logger.debug "Global Mask: length = #{length}"
|
104
107
|
return if length <= 0
|
105
108
|
|
106
109
|
mask_end = @file.tell + length
|
107
|
-
|
110
|
+
|
108
111
|
@global_mask = {}
|
109
112
|
@global_mask[:overlay_color_space] = @file.read_short
|
110
113
|
@global_mask[:color_components] = 4.times.map { |i| @file.read_short >> 8 }
|
@@ -119,4 +122,4 @@ class PSD
|
|
119
122
|
@file.seek mask_end
|
120
123
|
end
|
121
124
|
end
|
122
|
-
end
|
125
|
+
end
|
data/lib/psd/nodes/root.rb
CHANGED
data/lib/psd/renderer.rb
CHANGED
@@ -7,6 +7,7 @@ class PSD
|
|
7
7
|
def initialize(node, opts = {})
|
8
8
|
@root_node = node
|
9
9
|
@opts = opts
|
10
|
+
@render_hidden = opts.delete(:render_hidden)
|
10
11
|
|
11
12
|
# Our canvas always starts as the full document size because
|
12
13
|
# all measurements are relative to this size. We can later crop
|
@@ -35,8 +36,10 @@ class PSD
|
|
35
36
|
def execute_pipeline
|
36
37
|
PSD.logger.debug "Executing pipeline on #{active_node.debug_name}"
|
37
38
|
children.reverse.each do |child|
|
38
|
-
# We skip over hidden nodes.
|
39
|
-
|
39
|
+
# We skip over hidden nodes unless explicitly set otherwise.
|
40
|
+
# If rendering a single PSD::Node::Layer, this is automatically
|
41
|
+
# set so that hidden layers will render.
|
42
|
+
next if !@render_hidden && !child.visible?
|
40
43
|
|
41
44
|
if child.group?
|
42
45
|
push_node(child)
|
data/lib/psd/version.rb
CHANGED
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.1.
|
4
|
+
version: 3.1.4
|
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: 2014-
|
12
|
+
date: 2014-05-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -186,6 +186,7 @@ files:
|
|
186
186
|
- lib/psd/layer_info/blend_clipping_elements.rb
|
187
187
|
- lib/psd/layer_info/blend_interior_elements.rb
|
188
188
|
- lib/psd/layer_info/fill_opacity.rb
|
189
|
+
- lib/psd/layer_info/gradient_fill.rb
|
189
190
|
- lib/psd/layer_info/layer_group.rb
|
190
191
|
- lib/psd/layer_info/layer_id.rb
|
191
192
|
- lib/psd/layer_info/layer_name_source.rb
|
@@ -282,7 +283,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
282
283
|
version: '0'
|
283
284
|
requirements: []
|
284
285
|
rubyforge_project:
|
285
|
-
rubygems_version: 2.2.
|
286
|
+
rubygems_version: 2.2.2
|
286
287
|
signing_key:
|
287
288
|
specification_version: 4
|
288
289
|
summary: General purpose library for parsing Photoshop files
|