psd 1.4.2 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/psd/image_exports/png.rb +16 -4
- data/lib/psd/image_modes/greyscale.rb +2 -2
- data/lib/psd/image_modes/rgb.rb +1 -2
- data/lib/psd/nodes/build_preview.rb +12 -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: e989ef2453ff6c7b5e1c5e78590921ba53c679d6
|
4
|
+
data.tar.gz: 7b4dadc4460ad50512119776d4ca3e97f30782a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 219a65e3412907b5672831101ad86bc7ba900dee53f571261cae77a39137589028c170950f52b85e477b039aa596840abb35a6ce0506d515e7866162390eec56
|
7
|
+
data.tar.gz: 5b8436682d202ceaa47e75dccdd59470f868231473cb91c8212aefb35ed2024dfa709adddd8b650b17d8411561dfb12dadb1afeb63445aefecc64fdaea1b9780
|
@@ -36,7 +36,12 @@ class PSD::Image
|
|
36
36
|
i = 0
|
37
37
|
@layer.height.times do |y|
|
38
38
|
@layer.width.times do |x|
|
39
|
-
|
39
|
+
offset_x = x + @layer.left
|
40
|
+
offset_y = y + @layer.top
|
41
|
+
|
42
|
+
i +=1 and next if offset_x < 0 || offset_y < 0 || offset_x >= png.width || offset_y >= png.height
|
43
|
+
|
44
|
+
png[offset_x, offset_y] = @pixel_data[i]
|
40
45
|
i += 1
|
41
46
|
end
|
42
47
|
end
|
@@ -48,15 +53,22 @@ class PSD::Image
|
|
48
53
|
offset_x = @layer.mask.left + x
|
49
54
|
offset_y = @layer.mask.top + y
|
50
55
|
|
51
|
-
|
56
|
+
i += 1 and next if offset_x < 0 || offset_y < 0 || offset_x >= png.width || offset_y >= png.height
|
57
|
+
|
58
|
+
color = ChunkyPNG::Color.to_truecolor_alpha_bytes(png[offset_x, offset_y])
|
52
59
|
color[3] = color[3] * @mask_data[i] / 255
|
53
60
|
|
54
|
-
png
|
61
|
+
png[offset_x, offset_y] = ChunkyPNG::Color.rgba(*color)
|
55
62
|
i += 1
|
56
63
|
end
|
57
64
|
end
|
58
65
|
|
59
|
-
|
66
|
+
crop_left = PSD::Util.clamp(@layer.left, 0, png.width)
|
67
|
+
crop_top = PSD::Util.clamp(@layer.top, 0, png.height)
|
68
|
+
crop_width = PSD::Util.clamp(@layer.width.to_i, 0, png.width - crop_left)
|
69
|
+
crop_height = PSD::Util.clamp(@layer.height.to_i, 0, png.height - crop_top)
|
70
|
+
|
71
|
+
png.crop!(crop_left, crop_top, crop_width, crop_height)
|
60
72
|
end
|
61
73
|
|
62
74
|
def mask_to_png
|
@@ -9,11 +9,11 @@ class PSD
|
|
9
9
|
grey = @channel_data[i]
|
10
10
|
alpha = @channel_data[@channel_length + i]
|
11
11
|
|
12
|
-
@pixel_data.push ChunkyPNG::Color.
|
12
|
+
@pixel_data.push ChunkyPNG::Color.grayscale_alpha(grey, alpha)
|
13
13
|
end
|
14
14
|
else
|
15
15
|
(0...@num_pixels).step(pixel_step) do |i|
|
16
|
-
@pixel_data.push ChunkyPNG::Color.
|
16
|
+
@pixel_data.push ChunkyPNG::Color.grayscale(@channel_data[i])
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
data/lib/psd/image_modes/rgb.rb
CHANGED
@@ -10,7 +10,6 @@ class PSD
|
|
10
10
|
(0...@num_pixels).step(pixel_step) do |i|
|
11
11
|
r = g = b = 0
|
12
12
|
a = 255
|
13
|
-
mask = nil
|
14
13
|
|
15
14
|
@channels_info.each_with_index do |chan, index|
|
16
15
|
next if chan[:id] == -2
|
@@ -18,7 +17,7 @@ class PSD
|
|
18
17
|
val = @channel_data[i + (@channel_length * index)]
|
19
18
|
|
20
19
|
case chan[:id]
|
21
|
-
when -1 then a =
|
20
|
+
when -1 then a = val
|
22
21
|
when 0 then r = val
|
23
22
|
when 1 then g = val
|
24
23
|
when 2 then b = val
|
@@ -22,7 +22,13 @@ class PSD
|
|
22
22
|
compose! c, png, c.build_png, 0, 0
|
23
23
|
end
|
24
24
|
else
|
25
|
-
compose!
|
25
|
+
compose!(
|
26
|
+
c,
|
27
|
+
png,
|
28
|
+
c.image.to_png_with_mask,
|
29
|
+
PSD::Util.clamp(c.left.to_i, 0, png.width),
|
30
|
+
PSD::Util.clamp(c.top.to_i, 0, png.height)
|
31
|
+
)
|
26
32
|
end
|
27
33
|
end
|
28
34
|
|
@@ -37,7 +43,7 @@ class PSD
|
|
37
43
|
end
|
38
44
|
|
39
45
|
# Modified from ChunkyPNG::Canvas#compose! in order to support various blend modes.
|
40
|
-
def compose!(layer, base, other, offset_x
|
46
|
+
def compose!(layer, base, other, offset_x, offset_y)
|
41
47
|
blending_mode = layer.blending_mode.gsub(/ /, '_')
|
42
48
|
PSD.logger.warn("Blend mode #{blending_mode} is not implemented") unless Compose.respond_to?(blending_mode)
|
43
49
|
PSD.logger.debug("Blending #{layer.name} with #{blending_mode} blend mode")
|
@@ -45,6 +51,10 @@ class PSD
|
|
45
51
|
LayerStyles.new(layer, other).apply!
|
46
52
|
other = ClippingMask.new(layer, other).apply
|
47
53
|
|
54
|
+
blend_pixels!(blending_mode, layer, base, other, offset_x, offset_y)
|
55
|
+
end
|
56
|
+
|
57
|
+
def blend_pixels!(blending_mode, layer, base, other, offset_x, offset_y)
|
48
58
|
other.height.times do |y|
|
49
59
|
other.width.times do |x|
|
50
60
|
base_x = x + offset_x
|
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.3
|
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-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|