psd 1.4.4 → 1.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/lib/psd.rb +3 -1
- data/lib/psd/layer/channel_image.rb +4 -1
- data/lib/psd/lazy_execute.rb +7 -1
- data/lib/psd/mask.rb +49 -20
- data/lib/psd/node_layer.rb +1 -1
- 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: 3c9491d68bacd47bd02b6ef1ebd95679de8f780d
|
4
|
+
data.tar.gz: 3890b2b104af1b45d7754005cf91736cfd88c2fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03d6f9c5332ca2b8ac5e981743e3955f0b26d5cd8f6b3ec7643602cebd4d7f0ac766190e1ca7d4e6618c9784d33d319a7ab8b548919bd491079096290ca74166
|
7
|
+
data.tar.gz: e94c59785c2d9e6cac71e44e2f5a4efc8961e32da61f8382e36682af3a9ab6c58dba757a4411f383f87c6bc1a69cd9eaf9a5eedaa87ce4b2e6163b1d8e26a842
|
data/.travis.yml
CHANGED
data/lib/psd.rb
CHANGED
@@ -120,7 +120,9 @@ class PSD
|
|
120
120
|
# The image is the last section in the file, so we don't have to
|
121
121
|
# bother with skipping over the bytes to read more data.
|
122
122
|
image = Image.new(@file, @header)
|
123
|
-
LazyExecute.new(image, @file)
|
123
|
+
LazyExecute.new(image, @file)
|
124
|
+
.later(:parse)
|
125
|
+
.ignore(:width, :height)
|
124
126
|
)
|
125
127
|
end
|
126
128
|
|
@@ -5,7 +5,10 @@ class PSD
|
|
5
5
|
|
6
6
|
def parse_channel_image(header)
|
7
7
|
image = PSD::ChannelImage.new(@file, header, self)
|
8
|
-
@image = LazyExecute.new(image, @file)
|
8
|
+
@image = LazyExecute.new(image, @file)
|
9
|
+
.now(:skip)
|
10
|
+
.later(:parse)
|
11
|
+
.ignore(:width, :height)
|
9
12
|
end
|
10
13
|
end
|
11
14
|
end
|
data/lib/psd/lazy_execute.rb
CHANGED
@@ -9,6 +9,7 @@ class PSD
|
|
9
9
|
@loaded = false
|
10
10
|
@load_method = nil
|
11
11
|
@load_args = []
|
12
|
+
@passthru = []
|
12
13
|
|
13
14
|
PSD.logger.debug "Marked #{@obj.class.name} at position #{@start_pos} for lazy execution"
|
14
15
|
end
|
@@ -25,12 +26,17 @@ class PSD
|
|
25
26
|
return self
|
26
27
|
end
|
27
28
|
|
29
|
+
def ignore(*args)
|
30
|
+
@passthru += args
|
31
|
+
return self
|
32
|
+
end
|
33
|
+
|
28
34
|
def loaded?
|
29
35
|
@loaded
|
30
36
|
end
|
31
37
|
|
32
38
|
def method_missing(method, *args, &block)
|
33
|
-
load!
|
39
|
+
load! if !loaded? && !@passthru.include?(method.to_sym)
|
34
40
|
@obj.send(method, *args, &block)
|
35
41
|
end
|
36
42
|
|
data/lib/psd/mask.rb
CHANGED
@@ -1,45 +1,74 @@
|
|
1
1
|
class PSD
|
2
|
-
|
3
|
-
|
4
|
-
endian :big
|
2
|
+
class Mask
|
3
|
+
attr_reader :size, :top, :left, :bottom, :right, :default_color
|
5
4
|
|
6
|
-
|
5
|
+
def self.read(file)
|
6
|
+
mask = Mask.new(file)
|
7
|
+
mask.parse
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
mask
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(file)
|
13
|
+
@file = file
|
14
|
+
@top = 0
|
15
|
+
@left = 0
|
16
|
+
@bottom = 0
|
17
|
+
@right = 0
|
18
|
+
end
|
19
|
+
|
20
|
+
def parse
|
21
|
+
@size = @file.read_int
|
22
|
+
return if @size == 0
|
23
|
+
|
24
|
+
@mask_end = @file.tell + @size
|
14
25
|
|
15
|
-
|
16
|
-
|
26
|
+
@top = @file.read_int
|
27
|
+
@left = @file.read_int
|
28
|
+
@bottom = @file.read_int
|
29
|
+
@right = @file.read_int
|
17
30
|
|
18
|
-
|
19
|
-
|
20
|
-
|
31
|
+
@default_color = @file.read_byte
|
32
|
+
@flags = @file.read_byte
|
33
|
+
|
34
|
+
@file.seek @mask_end # Useless info/padding
|
21
35
|
end
|
22
36
|
|
23
|
-
# Width of the mask
|
24
37
|
def width
|
25
38
|
right - left
|
26
39
|
end
|
27
40
|
|
28
|
-
# Height of the mask
|
29
41
|
def height
|
30
42
|
bottom - top
|
31
43
|
end
|
32
44
|
|
33
45
|
def relative
|
34
|
-
flags & 0x01
|
46
|
+
(@flags & 0x01) > 0
|
35
47
|
end
|
36
48
|
|
37
49
|
def disabled
|
38
|
-
(flags & (0x01 << 1)) > 0
|
50
|
+
(@flags & (0x01 << 1)) > 0
|
39
51
|
end
|
40
52
|
|
41
53
|
def invert
|
42
|
-
(flags & (0x01 << 2)) > 0
|
54
|
+
(@flags & (0x01 << 2)) > 0
|
55
|
+
end
|
56
|
+
|
57
|
+
def to_hash
|
58
|
+
return {} if @size == 0
|
59
|
+
|
60
|
+
{
|
61
|
+
top: top,
|
62
|
+
left: left,
|
63
|
+
bottom: bottom,
|
64
|
+
right: right,
|
65
|
+
width: width,
|
66
|
+
height: height,
|
67
|
+
default_color: default_color,
|
68
|
+
relative: relative,
|
69
|
+
disabled: disabled,
|
70
|
+
invert: invert
|
71
|
+
}
|
43
72
|
end
|
44
73
|
end
|
45
74
|
end
|
data/lib/psd/node_layer.rb
CHANGED
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.5
|
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-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|