psd 3.6.0 → 3.7.0

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: b21fcce85fa8ca2b9b08cdc8cf21229c58fb021b
4
- data.tar.gz: 7b69b3e52405e5d44ad663323d355bf284c4c455
3
+ metadata.gz: d0df3c9415bc9d3724a1b47edfdd05e556486ab6
4
+ data.tar.gz: e7eaecbf86a2d7e117214dfbe024341fb70df9e8
5
5
  SHA512:
6
- metadata.gz: 05eaf2063a9814f935f558a28a2b9fa435f4e4a3ac431e66a497f4b302985d0b0bf7c9f84d69a17e31ae7bf664ac378c4aee7823155aca47e3d37fbfe2e81c53
7
- data.tar.gz: 64d5cdc4f06316b520d1b1ea13e391153a05593cc026582152e23a64d716a8fdeac34abc355d2bc95d05b38293d589773da563e27c8cdb56b57c33a5fb2e2eba
6
+ metadata.gz: 985a277130a940ccbd75f6028332a265c0a526b1db2906a8fb2d2a97a94ec13c7f399d07a610655888849fd4ab0439279bace6c53fb96767c660a2f01cdb2a1b
7
+ data.tar.gz: d8a068fe24e27e95e03c3c4f14dc8034dd0beb7c4127908287acef89d83ab667e201890374b546981fea87be06802a76bdaf10b9898274ab4fbcb26ecb7534f4
@@ -8,6 +8,7 @@ require 'psd/layer/info/color_balance'
8
8
  require 'psd/layer/info/color_lookup'
9
9
  require 'psd/layer/info/content_generator'
10
10
  require 'psd/layer/info/curves'
11
+ require 'psd/layer/info/effects_layer'
11
12
  require 'psd/layer/info/exposure'
12
13
  require 'psd/layer/info/fill_opacity'
13
14
  require 'psd/layer/info/gradient_fill'
@@ -60,6 +61,7 @@ class PSD
60
61
  color_lookup: ColorLookup,
61
62
  content_generator: ContentGenerator,
62
63
  curves: Curves,
64
+ effects_layer: EffectsLayer,
63
65
  exposure: Exposure,
64
66
  fill_opacity: FillOpacity,
65
67
  gradient_fill: GradientFill,
@@ -0,0 +1,174 @@
1
+ require 'psd/layer_info'
2
+
3
+ class PSD
4
+ # The file specification is majorly fucked for this info block. Had to make
5
+ # lots of tweaks.
6
+ class EffectsLayer < LayerInfo
7
+ def self.should_parse?(key)
8
+ key == 'lrFX'
9
+ end
10
+
11
+ BEVEL_STYLES = [
12
+ 'Outer Bevel',
13
+ 'Inner Bevel',
14
+ 'Emboss',
15
+ 'Pillow Emboss',
16
+ 'Stroke Emboss'
17
+ ].freeze
18
+
19
+ def parse
20
+ version = @file.read_short
21
+ effects_count = @file.read_short
22
+
23
+ @data = {}
24
+ effects_count.times do
25
+ sig = @file.read_string(4)
26
+ if sig != "8BIM"
27
+ PSD.logger.debug "Effect layer signature was not 8BIM, got #{sig}. Skipping."
28
+ return false
29
+ end
30
+
31
+ key = @file.read_string(4)
32
+ case key
33
+ when 'cmnS' then common_state
34
+ when 'dsdw' then shadow(:drop_shadow)
35
+ when 'isdw' then shadow(:inner_shadow)
36
+ when 'oglw' then outer_glow
37
+ when 'iglw' then inner_glow
38
+ when 'bevl' then bevel
39
+ when 'sofi' then solid_fill
40
+ end
41
+ end
42
+ end
43
+
44
+ private
45
+
46
+ # This is the most pointless block of data yet.
47
+ def common_state
48
+ @file.seek 11, IO::SEEK_CUR
49
+ @data[:visible] = true
50
+ end
51
+
52
+ def shadow(key)
53
+ @data[key] = {}
54
+ size = @file.read_int
55
+
56
+ @data[key][:version] = @file.read_int
57
+ @data[key][:size] = @file.read_short
58
+ @data[key][:spread] = @file.read_int
59
+ @data[key][:angle] = @file.read_int
60
+ @data[key][:distance] = @file.read_int
61
+
62
+ # Not sure if Photoshop or the spec is wrong, but somebody done goofed.
63
+ @file.seek 2, IO::SEEK_CUR
64
+
65
+ @data[key][:color] = @file.read_space_color
66
+
67
+ @file.seek 4, IO::SEEK_CUR # blend mode sig
68
+ @data[key][:blend_mode] = @file.read_string(4)
69
+ @data[key][:enabled] = @file.read_boolean
70
+ @data[key][:use_global_light] = @file.read_boolean
71
+ @data[key][:opacity] = (255.0 / @file.read_byte).round
72
+
73
+ if size == 51
74
+ @data[key][:native_color] = @file.read_space_color
75
+ end
76
+ end
77
+
78
+ def outer_glow
79
+ @data[:outer_glow] = {}
80
+ size = @file.read_int
81
+
82
+ @data[:outer_glow][:version] = @file.read_int
83
+ @data[:outer_glow][:size] = @file.read_short
84
+ @data[:outer_glow][:spread] = @file.read_int
85
+ @file.seek 2, IO::SEEK_CUR
86
+
87
+ @data[:outer_glow][:color] = @file.read_space_color
88
+
89
+ @file.seek 4, IO::SEEK_CUR # blend sig
90
+ @data[:outer_glow][:blend_mode] = @file.read_string(4)
91
+ @data[:outer_glow][:enabled] = @file.read_boolean
92
+ @data[:outer_glow][:opacity] = (255.0 / @file.read_byte).round
93
+
94
+ if size ==42
95
+ @data[:outer_glow][:native_color] = @file.read_space_color
96
+ end
97
+ end
98
+
99
+ def inner_glow
100
+ @data[:inner_glow] = {}
101
+ size = @file.read_int
102
+
103
+ @data[:inner_glow][:version] = @file.read_int
104
+ @data[:inner_glow][:size] = @file.read_short
105
+ @data[:inner_glow][:spread] = @file.read_int
106
+ @file.seek 2, IO::SEEK_CUR
107
+
108
+ @data[:inner_glow][:color] = @file.read_space_color
109
+
110
+ @file.seek 4, IO::SEEK_CUR # blend sig
111
+ @data[:inner_glow][:blend_mode] = @file.read_string(4)
112
+ @data[:inner_glow][:enabled] = @file.read_boolean
113
+ @data[:inner_glow][:opacity] = (255.0 / @file.read_byte).round
114
+
115
+ if @data[:inner_glow][:version] == 2
116
+ @data[:inner_glow][:invert] = @file.read_boolean
117
+ @data[:inner_glow][:native_color] = @file.read_space_color
118
+ end
119
+ end
120
+
121
+ def bevel
122
+ @data[:bevel] = {}
123
+ size = @file.read_int
124
+
125
+ @data[:bevel][:version] = @file.read_int
126
+
127
+ # Okay somebody really goofed, this is super weird.
128
+ @data[:bevel][:angle] = @file.read_short
129
+ @file.seek 2, IO::SEEK_CUR
130
+ @data[:bevel][:size] = @file.read_short
131
+ @file.seek 2, IO::SEEK_CUR
132
+ @data[:bevel][:soften] = @file.read_short
133
+ @file.seek 2, IO::SEEK_CUR
134
+
135
+ @file.seek 4, IO::SEEK_CUR
136
+ @data[:bevel][:highlight_blend] = @file.read_string(4)
137
+
138
+ @file.seek 4, IO::SEEK_CUR
139
+ @data[:bevel][:shadow_blend] = @file.read_string(4)
140
+
141
+ @data[:bevel][:highlight_color] = @file.read_space_color
142
+ @data[:bevel][:shadow_color] = @file.read_space_color
143
+
144
+ @data[:bevel][:style_id] = @file.read_byte
145
+ @data[:bevel][:style] = BEVEL_STYLES[@data[:bevel][:style_id]]
146
+
147
+ @data[:bevel][:highlight_opacity] = @file.read_byte
148
+ @data[:bevel][:shadow_opacity] = @file.read_byte
149
+ @data[:bevel][:enabled] = @file.read_boolean
150
+ @data[:bevel][:use_global_light] = @file.read_boolean
151
+ @data[:bevel][:direction] = @file.read_byte == 0 ? 'Up' : 'Down'
152
+
153
+ if @data[:bevel][:version] == 2
154
+ @data[:bevel][:real_highlight_color] = @file.read_space_color
155
+ @data[:bevel][:real_shadow_color] = @file.read_space_color
156
+ end
157
+ end
158
+
159
+ def solid_fill
160
+ @data[:solid_fill] = {}
161
+ @file.seek 4, IO::SEEK_CUR
162
+
163
+ @data[:solid_fill][:version] = @file.read_int
164
+
165
+ @file.seek 4, IO::SEEK_CUR
166
+ @data[:solid_fill][:blend_mode] = @file.read_string(4)
167
+
168
+ @data[:solid_fill][:color] = @file.read_space_color
169
+ @data[:solid_fill][:opacity] = (255.0 / @file.read_byte).round
170
+ @data[:solid_fill][:enabled] = @file.read_boolean
171
+ @data[:solid_fill][:native_color] = @file.read_space_color
172
+ end
173
+ end
174
+ end
@@ -1,3 +1,3 @@
1
1
  class PSD
2
- VERSION = "3.6.0"
2
+ VERSION = "3.7.0"
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: 3.6.0
4
+ version: 3.7.0
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: 2016-01-15 00:00:00.000000000 Z
12
+ date: 2016-01-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -174,6 +174,7 @@ files:
174
174
  - lib/psd/layer/info/color_lookup.rb
175
175
  - lib/psd/layer/info/content_generator.rb
176
176
  - lib/psd/layer/info/curves.rb
177
+ - lib/psd/layer/info/effects_layer.rb
177
178
  - lib/psd/layer/info/exposure.rb
178
179
  - lib/psd/layer/info/fill_opacity.rb
179
180
  - lib/psd/layer/info/gradient_fill.rb
@@ -299,7 +300,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
299
300
  version: '0'
300
301
  requirements: []
301
302
  rubyforge_project:
302
- rubygems_version: 2.5.1
303
+ rubygems_version: 2.4.6
303
304
  signing_key:
304
305
  specification_version: 4
305
306
  summary: General purpose library for parsing Photoshop files