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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9cbcd0dd708df678b81c59484b465c4e83153dfd
4
- data.tar.gz: 3f8a84f7b4a8dd36c1567dd11e8e3c751a22a1a7
3
+ metadata.gz: c280041aec3dddd0d1d36ffc6ed04a508fee595b
4
+ data.tar.gz: fb26c8a487af49e440b1f33c1fb22d439ffbe2af
5
5
  SHA512:
6
- metadata.gz: e66d305e6d0157a0e4c52d2e84ea8a71ace66dbc7cbaea88469a5e1b8dc91e6e87f75e795a0eb3c612c642150b5b2ed3213e6cb45803643707d8ddb270e7d799
7
- data.tar.gz: c61813c1eeee66eb8fbe2236462b93fc988f68f864d1f60d88f3135905b0b8ba5bd5a112cdf8855d485e32615c6f1a307658c75843641ac9e160ca7d986c77be
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
 
@@ -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 = ChunkyPNG::Canvas.new(width.to_i, height.to_i, ChunkyPNG::Color::TRANSPARENT)
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 = ChunkyPNG::Color.to_truecolor_alpha_bytes(full_png[x, y])
32
- color[3] = color[3] * alpha / 255
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
- for y in 0...other.height do
49
- for x in 0...other.width do
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
@@ -1,3 +1,3 @@
1
1
  class PSD
2
- VERSION = "1.4.0"
2
+ VERSION = "1.4.1"
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: 1.4.0
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-17 00:00:00.000000000 Z
12
+ date: 2013-11-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake