psd 1.4.0 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/psd/clipping_mask.rb +16 -7
- data/lib/psd/compose.rb +3 -3
- data/lib/psd/nodes/build_preview.rb +2 -2
- data/lib/psd/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c280041aec3dddd0d1d36ffc6ed04a508fee595b
|
4
|
+
data.tar.gz: fb26c8a487af49e440b1f33c1fb22d439ffbe2af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95b60cce05f150433a0b62eb87bb33cd6a77c437ef49ab133b8c9ad44934f2112a74ef5c3de12f53495857eb252c108af38942737030d65c52bfcc6182ac56f2
|
7
|
+
data.tar.gz: bafa5dd0214d03bd39c34e19218a76d72c33b50bd4a9e2a3e33358be4b8d3a49d344f161a5d8896b5138b7ccbc36c187968fe76b4ba6d558bf63d976bbd7f9da
|
data/README.md
CHANGED
@@ -217,7 +217,11 @@ PSD.debug = true
|
|
217
217
|
|
218
218
|
You can build previews of any subset or version of the PSD document. This is useful for generating previews of layer comps or exporting individual layer groups as images.
|
219
219
|
|
220
|
+
**NOTE: You MUST initialize with the parse_layer_images option set to true, as shown below.**
|
221
|
+
|
220
222
|
``` ruby
|
223
|
+
psd = PSD.new(file, parse_layer_images: true)
|
224
|
+
|
221
225
|
# Save a layer comp
|
222
226
|
psd.tree.filter_by_comp("Version A").save_as_png('./Version A.png')
|
223
227
|
|
data/lib/psd/clipping_mask.rb
CHANGED
@@ -8,13 +8,10 @@ class PSD
|
|
8
8
|
def apply
|
9
9
|
return @png unless @layer.clipped?
|
10
10
|
|
11
|
-
mask = @layer.next_sibling
|
12
|
-
|
13
11
|
PSD.logger.debug "Applying clipping mask #{mask.name} to #{@layer.name}"
|
14
12
|
|
15
13
|
width, height = @layer.document_dimensions
|
16
|
-
full_png =
|
17
|
-
full_png.compose!(@png, @layer.left, @layer.top)
|
14
|
+
full_png = compose_to_full
|
18
15
|
|
19
16
|
height.times do |y|
|
20
17
|
width.times do |x|
|
@@ -28,13 +25,25 @@ class PSD
|
|
28
25
|
alpha = pixel.nil? ? 0 : ChunkyPNG::Color.a(pixel)
|
29
26
|
end
|
30
27
|
|
31
|
-
color =
|
32
|
-
|
33
|
-
full_png[x, y] = ChunkyPNG::Color.rgba(*color)
|
28
|
+
color = full_png[x, y]
|
29
|
+
full_png[x, y] = (color & 0xffffff00) | (ChunkyPNG::Color.a(color) * alpha / 255)
|
34
30
|
end
|
35
31
|
end
|
36
32
|
|
37
33
|
full_png.crop!(@layer.left, @layer.top, @layer.width, @layer.height)
|
38
34
|
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def mask
|
39
|
+
@mask ||= @layer.next_sibling
|
40
|
+
end
|
41
|
+
|
42
|
+
def compose_to_full
|
43
|
+
width, height = @layer.document_dimensions
|
44
|
+
full_png = ChunkyPNG::Canvas.new(width.to_i, height.to_i, ChunkyPNG::Color::TRANSPARENT)
|
45
|
+
full_png.compose!(@png, @layer.left, @layer.top)
|
46
|
+
full_png
|
47
|
+
end
|
39
48
|
end
|
40
49
|
end
|
data/lib/psd/compose.rb
CHANGED
@@ -84,9 +84,9 @@ class PSD
|
|
84
84
|
|
85
85
|
mix_alpha, dst_alpha = calculate_alphas(fg, bg, DEFAULT_OPTS.merge(opts))
|
86
86
|
|
87
|
-
new_r = blend_channel(r(bg), r(fg) < (255 - r(bg)) ? 0 : r(fg) - 255 - r(bg), mix_alpha)
|
88
|
-
new_g = blend_channel(g(bg), g(fg) < (255 - g(bg)) ? 0 : g(fg) - 255 - g(bg), mix_alpha)
|
89
|
-
new_b = blend_channel(b(bg), b(fg) < (255 - b(bg)) ? 0 : b(fg) - 255 - b(bg), mix_alpha)
|
87
|
+
new_r = blend_channel(r(bg), (r(fg) < (255 - r(bg))) ? 0 : r(fg) - (255 - r(bg)), mix_alpha)
|
88
|
+
new_g = blend_channel(g(bg), (g(fg) < (255 - g(bg))) ? 0 : g(fg) - (255 - g(bg)), mix_alpha)
|
89
|
+
new_b = blend_channel(b(bg), (b(fg) < (255 - b(bg))) ? 0 : b(fg) - (255 - b(bg)), mix_alpha)
|
90
90
|
|
91
91
|
rgba(new_r, new_g, new_b, dst_alpha)
|
92
92
|
end
|
@@ -45,8 +45,8 @@ class PSD
|
|
45
45
|
LayerStyles.new(layer, other).apply!
|
46
46
|
other = ClippingMask.new(layer, other).apply
|
47
47
|
|
48
|
-
|
49
|
-
|
48
|
+
other.height.times do |y|
|
49
|
+
other.width.times do |x|
|
50
50
|
base_x = x + offset_x
|
51
51
|
base_y = y + offset_y
|
52
52
|
|
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: 1.4.
|
4
|
+
version: 1.4.1
|
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: 2013-11-
|
12
|
+
date: 2013-11-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|