origami 1.2.1 → 1.2.2
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.
- data/README +1 -1
- data/bin/gui/hexview.rb +1 -1
- data/bin/gui/menu.rb +4 -4
- data/bin/gui/textview.rb +6 -4
- data/bin/gui/treeview.rb +4 -4
- data/bin/gui/walker.rb +1 -1
- data/bin/pdf2graph +1 -1
- data/bin/pdf2pdfa +1 -1
- data/bin/pdf2ruby +1 -1
- data/bin/pdfcocoon +1 -1
- data/bin/pdfcop +1 -1
- data/bin/pdfdecompress +1 -1
- data/bin/pdfdecrypt +1 -1
- data/bin/pdfencrypt +1 -1
- data/bin/pdfextract +75 -14
- data/bin/pdfmetadata +1 -1
- data/bin/shell/.irbrc +1 -1
- data/{origami.rb → lib/origami.rb} +3 -3
- data/{origami → lib/origami}/3d.rb +0 -0
- data/{origami → lib/origami}/acroform.rb +2 -2
- data/{origami → lib/origami}/actions.rb +0 -0
- data/{origami → lib/origami}/annotations.rb +0 -0
- data/{origami → lib/origami}/array.rb +0 -0
- data/{origami → lib/origami}/boolean.rb +0 -0
- data/{origami → lib/origami}/catalog.rb +0 -0
- data/{origami → lib/origami}/destinations.rb +0 -0
- data/{origami → lib/origami}/dictionary.rb +0 -0
- data/{origami → lib/origami}/docmdp.rb +0 -0
- data/{origami → lib/origami}/encryption.rb +9 -7
- data/{origami → lib/origami}/export.rb +0 -0
- data/lib/origami/extensions/fdf.rb +257 -0
- data/{origami/adobe → lib/origami/extensions}/ppklite.rb +3 -1
- data/{origami → lib/origami}/file.rb +0 -0
- data/{origami → lib/origami}/filters.rb +0 -0
- data/{origami → lib/origami}/filters/ascii.rb +0 -0
- data/{origami → lib/origami}/filters/ccitt.rb +0 -1
- data/{origami → lib/origami}/filters/crypt.rb +0 -0
- data/{origami → lib/origami}/filters/dct.rb +0 -0
- data/{origami → lib/origami}/filters/flate.rb +0 -0
- data/{origami → lib/origami}/filters/jbig2.rb +0 -0
- data/{origami → lib/origami}/filters/jpx.rb +0 -0
- data/{origami → lib/origami}/filters/lzw.rb +0 -0
- data/{origami → lib/origami}/filters/predictors.rb +0 -0
- data/{origami → lib/origami}/filters/runlength.rb +0 -0
- data/{origami → lib/origami}/font.rb +0 -0
- data/{origami → lib/origami}/functions.rb +0 -0
- data/{origami → lib/origami}/graphics.rb +0 -0
- data/{origami → lib/origami}/graphics/colors.rb +45 -23
- data/{origami → lib/origami}/graphics/instruction.rb +0 -0
- data/{origami → lib/origami}/graphics/path.rb +0 -0
- data/{origami → lib/origami}/graphics/patterns.rb +0 -0
- data/{origami → lib/origami}/graphics/render.rb +0 -0
- data/{origami → lib/origami}/graphics/state.rb +2 -2
- data/{origami → lib/origami}/graphics/text.rb +0 -0
- data/{origami → lib/origami}/graphics/xobject.rb +219 -0
- data/{origami → lib/origami}/header.rb +0 -0
- data/{origami → lib/origami}/javascript.rb +0 -0
- data/{origami → lib/origami}/linearization.rb +0 -0
- data/{origami → lib/origami}/metadata.rb +0 -0
- data/{origami → lib/origami}/name.rb +0 -0
- data/{origami → lib/origami}/null.rb +0 -0
- data/{origami → lib/origami}/numeric.rb +0 -0
- data/{origami → lib/origami}/obfuscation.rb +0 -0
- data/{origami → lib/origami}/object.rb +7 -2
- data/{origami → lib/origami}/outline.rb +0 -0
- data/{origami → lib/origami}/outputintents.rb +0 -0
- data/{origami → lib/origami}/page.rb +0 -0
- data/{origami → lib/origami}/parser.rb +76 -51
- data/{origami → lib/origami}/parsers/fdf.rb +9 -6
- data/{origami/parsers/pdf/linear.rb → lib/origami/parsers/pdf.rb} +31 -39
- data/lib/origami/parsers/pdf/linear.rb +84 -0
- data/lib/origami/parsers/ppklite.rb +93 -0
- data/{origami → lib/origami}/pdf.rb +6 -3
- data/{origami → lib/origami}/reference.rb +0 -0
- data/{origami → lib/origami}/signature.rb +170 -19
- data/{origami → lib/origami}/stream.rb +9 -0
- data/{origami → lib/origami}/string.rb +0 -0
- data/{origami → lib/origami}/trailer.rb +0 -0
- data/{origami → lib/origami}/webcapture.rb +0 -0
- data/{origami → lib/origami}/xfa.rb +0 -0
- data/{origami → lib/origami}/xreftable.rb +3 -7
- data/samples/README.txt +45 -0
- data/samples/actions/launch/calc.rb +87 -0
- data/samples/actions/launch/winparams.rb +22 -0
- data/samples/actions/loop/loopgoto.rb +24 -0
- data/samples/actions/loop/loopnamed.rb +21 -0
- data/samples/actions/named/named.rb +31 -0
- data/samples/actions/samba/smbrelay.rb +26 -0
- data/samples/actions/triggerevents/trigger.rb +75 -0
- data/samples/actions/webbug/submitform.js +26 -0
- data/samples/actions/webbug/webbug-browser.rb +68 -0
- data/samples/actions/webbug/webbug-js.rb +67 -0
- data/samples/actions/webbug/webbug-reader.rb +90 -0
- data/samples/attachments/attach.rb +40 -0
- data/samples/attachments/attached.txt +1 -0
- data/samples/crypto/crypto.rb +28 -0
- data/samples/digsig/signed.rb +46 -0
- data/samples/exploits/cve-2008-2992-utilprintf.rb +87 -0
- data/samples/exploits/cve-2009-0927-geticon.rb +65 -0
- data/samples/exploits/exploit_customdictopen.rb +55 -0
- data/samples/exploits/getannots.rb +69 -0
- data/samples/flash/flash.rb +31 -0
- data/samples/flash/helloworld.swf +0 -0
- data/samples/javascript/attached.txt +1 -0
- data/samples/javascript/js.rb +52 -0
- data/{tests → test}/ts_pdf.rb +1 -1
- metadata +109 -95
- data/origami/adobe/fdf.rb +0 -259
- data/origami/parsers/pdf.rb +0 -27
- data/origami/parsers/ppklite.rb +0 -86
- data/tests/dataset/test.dummycrt +0 -28
- data/tests/dataset/test.dummykey +0 -27
- data/tests/tc_actions.rb +0 -32
- data/tests/tc_annotations.rb +0 -85
- data/tests/tc_pages.rb +0 -37
- data/tests/tc_pdfattach.rb +0 -24
- data/tests/tc_pdfencrypt.rb +0 -110
- data/tests/tc_pdfnew.rb +0 -32
- data/tests/tc_pdfparse.rb +0 -98
- data/tests/tc_pdfsig.rb +0 -37
- data/tests/tc_streams.rb +0 -129
|
@@ -168,7 +168,7 @@ module Origami
|
|
|
168
168
|
obj.extend(Encryption::EncryptedString)
|
|
169
169
|
obj.encryption_handler = handler
|
|
170
170
|
obj.encryption_key = encryption_key
|
|
171
|
-
obj.algorithm =
|
|
171
|
+
obj.algorithm = str_algo
|
|
172
172
|
obj.decrypted = false
|
|
173
173
|
obj.decrypt!
|
|
174
174
|
|
|
@@ -1205,17 +1205,16 @@ module Origami
|
|
|
1205
1205
|
# For version 5 and 6, _salt_ is the User Key Salt.
|
|
1206
1206
|
#
|
|
1207
1207
|
def is_user_password?(pass, salt)
|
|
1208
|
-
|
|
1209
1208
|
if self.R == 2
|
|
1210
1209
|
compute_user_password(pass, salt) == self.U
|
|
1211
1210
|
elsif self.R == 3 or self.R == 4
|
|
1212
1211
|
compute_user_password(pass, salt)[0, 16] == self.U[0, 16]
|
|
1213
1212
|
elsif self.R == 5
|
|
1214
1213
|
uvs = self.U[32, 8]
|
|
1215
|
-
Digest::SHA256.digest(pass + uvs) == self.U[0, 32]
|
|
1214
|
+
Digest::SHA256.digest(password_to_utf8(pass) + uvs) == self.U[0, 32]
|
|
1216
1215
|
elsif self.R == 6
|
|
1217
1216
|
uvs = self.U[32, 8]
|
|
1218
|
-
compute_hardened_hash(pass, uvs) == self.U[0, 32]
|
|
1217
|
+
compute_hardened_hash(password_to_utf8(pass), uvs) == self.U[0, 32]
|
|
1219
1218
|
end
|
|
1220
1219
|
end
|
|
1221
1220
|
|
|
@@ -1231,10 +1230,10 @@ module Origami
|
|
|
1231
1230
|
is_user_password?(user_password, salt)
|
|
1232
1231
|
elsif self.R == 5
|
|
1233
1232
|
ovs = self.O[32, 8]
|
|
1234
|
-
Digest::SHA256.digest(pass + ovs + self.U) == self.O[0, 32]
|
|
1233
|
+
Digest::SHA256.digest(password_to_utf8(pass) + ovs + self.U) == self.O[0, 32]
|
|
1235
1234
|
elsif self.R == 6
|
|
1236
1235
|
ovs = self.O[32, 8]
|
|
1237
|
-
compute_hardened_hash(pass, ovs, self.U[0,48]) == self.O[0, 32]
|
|
1236
|
+
compute_hardened_hash(password_to_utf8(pass), ovs, self.U[0,48]) == self.O[0, 32]
|
|
1238
1237
|
end
|
|
1239
1238
|
end
|
|
1240
1239
|
|
|
@@ -1358,7 +1357,9 @@ module Origami
|
|
|
1358
1357
|
end
|
|
1359
1358
|
|
|
1360
1359
|
def password_to_utf8(passwd) #:nodoc:
|
|
1361
|
-
Origami::ByteString.new(passwd).to_utf8[0, 127]
|
|
1360
|
+
p=Origami::ByteString.new(passwd).to_utf8[0, 127]
|
|
1361
|
+
hexprint p
|
|
1362
|
+
p
|
|
1362
1363
|
end
|
|
1363
1364
|
|
|
1364
1365
|
end
|
|
@@ -1369,6 +1370,7 @@ module Origami
|
|
|
1369
1370
|
|
|
1370
1371
|
end
|
|
1371
1372
|
|
|
1373
|
+
__END__
|
|
1372
1374
|
def hexprint(str)
|
|
1373
1375
|
hex = ""
|
|
1374
1376
|
str.each_byte do |b|
|
|
File without changes
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
= File
|
|
4
|
+
formats/fdf.rb
|
|
5
|
+
|
|
6
|
+
= Info
|
|
7
|
+
This file is part of Origami, PDF manipulation framework for Ruby
|
|
8
|
+
Copyright (C) 2010 Guillaume Delugr� <guillaume@security-labs.org>
|
|
9
|
+
All right reserved.
|
|
10
|
+
|
|
11
|
+
Origami is free software: you can redistribute it and/or modify
|
|
12
|
+
it under the terms of the GNU Lesser General Public License as published by
|
|
13
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
14
|
+
(at your option) any later version.
|
|
15
|
+
|
|
16
|
+
Origami is distributed in the hope that it will be useful,
|
|
17
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19
|
+
GNU Lesser General Public License for more details.
|
|
20
|
+
|
|
21
|
+
You should have received a copy of the GNU Lesser General Public License
|
|
22
|
+
along with Origami. If not, see <http://www.gnu.org/licenses/>.
|
|
23
|
+
|
|
24
|
+
=end
|
|
25
|
+
|
|
26
|
+
require 'origami/object'
|
|
27
|
+
require 'origami/name'
|
|
28
|
+
require 'origami/dictionary'
|
|
29
|
+
require 'origami/reference'
|
|
30
|
+
require 'origami/boolean'
|
|
31
|
+
require 'origami/numeric'
|
|
32
|
+
require 'origami/string'
|
|
33
|
+
require 'origami/array'
|
|
34
|
+
require 'origami/trailer'
|
|
35
|
+
require 'origami/xreftable'
|
|
36
|
+
|
|
37
|
+
require 'origami/parsers/fdf'
|
|
38
|
+
|
|
39
|
+
module Origami
|
|
40
|
+
|
|
41
|
+
#
|
|
42
|
+
# Class representing an AcroForm Forms Data Format file.
|
|
43
|
+
#
|
|
44
|
+
class FDF
|
|
45
|
+
|
|
46
|
+
class Header
|
|
47
|
+
|
|
48
|
+
MAGIC = /\A%FDF-(\d)\.(\d)/
|
|
49
|
+
|
|
50
|
+
attr_accessor :majorversion, :minorversion
|
|
51
|
+
|
|
52
|
+
#
|
|
53
|
+
# Creates a file header, with the given major and minor versions.
|
|
54
|
+
# _majorversion_:: Major version.
|
|
55
|
+
# _minorversion_:: Minor version.
|
|
56
|
+
#
|
|
57
|
+
def initialize(majorversion = 2, minorversion = 1)
|
|
58
|
+
@majorversion, @minorversion = majorversion, minorversion
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def self.parse(stream) #:nodoc:
|
|
62
|
+
|
|
63
|
+
if not stream.scan(MAGIC).nil?
|
|
64
|
+
maj = stream[1].to_i
|
|
65
|
+
min = stream[2].to_i
|
|
66
|
+
else
|
|
67
|
+
raise InvalidHeader, "Invalid header format"
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
FDF::Header.new(maj,min)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def to_s
|
|
74
|
+
"%FDF-#{@majorversion}.#{@minorversion}" + EOL
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def to_sym #:nodoc:
|
|
78
|
+
"#{@majorversion}.#{@minorversion}".to_sym
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def to_f #:nodoc:
|
|
82
|
+
to_sym.to_s.to_f
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
class Revision #:nodoc;
|
|
88
|
+
attr_accessor :pdf
|
|
89
|
+
attr_accessor :body, :xreftable, :trailer
|
|
90
|
+
|
|
91
|
+
def initialize(adbk)
|
|
92
|
+
@pdf = adbk
|
|
93
|
+
@body = {}
|
|
94
|
+
@xreftable = nil
|
|
95
|
+
@trailer = nil
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def trailer=(trl)
|
|
99
|
+
trl.pdf = @pdf
|
|
100
|
+
@trailer = trl
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
attr_accessor :header, :revisions
|
|
105
|
+
|
|
106
|
+
def initialize #:nodoc:
|
|
107
|
+
@header = FDF::Header.new
|
|
108
|
+
@revisions = [ Revision.new(self) ]
|
|
109
|
+
@revisions.first.trailer = Trailer.new
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def objects
|
|
113
|
+
def append_subobj(root, objset)
|
|
114
|
+
if objset.find{ |o| o.object_id == root.object_id }.nil?
|
|
115
|
+
objset << root
|
|
116
|
+
if root.is_a?(Array) or root.is_a?(Dictionary)
|
|
117
|
+
root.each { |subobj| append_subobj(subobj, objset) unless subobj.is_a?(Reference) }
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
objset = []
|
|
123
|
+
@revisions.first.body.values.each do |object|
|
|
124
|
+
unless object.is_a?(Reference)
|
|
125
|
+
append_subobj(object, objset)
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
objset
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def <<(object)
|
|
133
|
+
|
|
134
|
+
object.set_indirect(true)
|
|
135
|
+
|
|
136
|
+
if object.no.zero?
|
|
137
|
+
maxno = 1
|
|
138
|
+
while get_object(maxno) do maxno = maxno.succ end
|
|
139
|
+
|
|
140
|
+
object.generation = 0
|
|
141
|
+
object.no = maxno
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
@revisions.first.body[object.reference] = object
|
|
145
|
+
|
|
146
|
+
object.reference
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def Catalog
|
|
150
|
+
get_object(@trailer.Root)
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def save(filename)
|
|
154
|
+
|
|
155
|
+
bin = ""
|
|
156
|
+
bin << @header.to_s
|
|
157
|
+
|
|
158
|
+
lastno, brange = 0, 0
|
|
159
|
+
|
|
160
|
+
xrefs = [ XRef.new(0, XRef::LASTFREE, XRef::FREE) ]
|
|
161
|
+
xrefsection = XRef::Section.new
|
|
162
|
+
|
|
163
|
+
@revisions.first.body.values.sort.each { |obj|
|
|
164
|
+
if (obj.no - lastno).abs > 1
|
|
165
|
+
xrefsection << XRef::Subsection.new(brange, xrefs)
|
|
166
|
+
brange = obj.no
|
|
167
|
+
xrefs.clear
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
xrefs << XRef.new(bin.size, obj.generation, XRef::USED)
|
|
171
|
+
lastno = obj.no
|
|
172
|
+
|
|
173
|
+
bin << obj.to_s
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
xrefsection << XRef::Subsection.new(brange, xrefs)
|
|
177
|
+
|
|
178
|
+
@xreftable = xrefsection
|
|
179
|
+
@trailer ||= Trailer.new
|
|
180
|
+
@trailer.Size = rev.body.size + 1
|
|
181
|
+
@trailer.startxref = bin.size
|
|
182
|
+
|
|
183
|
+
bin << @xreftable.to_s
|
|
184
|
+
bin << @trailer.to_s
|
|
185
|
+
|
|
186
|
+
fd = File.open(filename, "w").binmode
|
|
187
|
+
fd << bin
|
|
188
|
+
fd.close
|
|
189
|
+
|
|
190
|
+
show_entries
|
|
191
|
+
end
|
|
192
|
+
alias saveas save
|
|
193
|
+
|
|
194
|
+
private
|
|
195
|
+
|
|
196
|
+
def rebuildxrefs #:nodoc:
|
|
197
|
+
|
|
198
|
+
startxref = @header.to_s.size
|
|
199
|
+
|
|
200
|
+
@revisions.first.body.values.each { |object|
|
|
201
|
+
startxref += object.to_s.size
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
@xreftable = buildxrefs(@revisions.first.body)
|
|
205
|
+
|
|
206
|
+
@trailer ||= Trailer.new
|
|
207
|
+
@trailer.Size = @revisions.first.body.size + 1
|
|
208
|
+
@trailer.startxref = startxref
|
|
209
|
+
|
|
210
|
+
self
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
def buildxrefs(objects) #:nodoc:
|
|
214
|
+
|
|
215
|
+
lastno = 0
|
|
216
|
+
brange = 0
|
|
217
|
+
|
|
218
|
+
xrefs = [ XRef.new(0, XRef::LASTFREE, XRef::FREE) ]
|
|
219
|
+
|
|
220
|
+
xrefsection = XRef::Section.new
|
|
221
|
+
objects.sort.each { |object|
|
|
222
|
+
if (object.no - lastno).abs > 1
|
|
223
|
+
xrefsection << XRef::Subsection.new(brange, xrefs)
|
|
224
|
+
brange = object.no
|
|
225
|
+
xrefs.clear
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
xrefs << XRef.new(get_object_offset(object.no, object.generation), object.generation, XRef::USED)
|
|
229
|
+
|
|
230
|
+
lastno = object.no
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
xrefsection << XRef::Subsection.new(brange, xrefs)
|
|
234
|
+
|
|
235
|
+
xrefsection
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
def get_object_offset(no,generation) #:nodoc:
|
|
239
|
+
|
|
240
|
+
bodyoffset = @header.to_s.size
|
|
241
|
+
|
|
242
|
+
objectoffset = bodyoffset
|
|
243
|
+
|
|
244
|
+
@revisions.first.body.values.each { |object|
|
|
245
|
+
if object.no == no and object.generation == generation then return objectoffset
|
|
246
|
+
else
|
|
247
|
+
objectoffset += object.to_s.size
|
|
248
|
+
end
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
nil
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
end
|
|
257
|
+
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
=begin
|
|
2
2
|
|
|
3
3
|
= File
|
|
4
|
-
|
|
4
|
+
formats/ppklite.rb
|
|
5
5
|
|
|
6
6
|
= Info
|
|
7
7
|
This file is part of Origami, PDF manipulation framework for Ruby
|
|
@@ -34,6 +34,8 @@ require 'origami/array'
|
|
|
34
34
|
require 'origami/trailer'
|
|
35
35
|
require 'origami/xreftable'
|
|
36
36
|
|
|
37
|
+
require 'origami/parsers/ppklite'
|
|
38
|
+
|
|
37
39
|
require 'openssl'
|
|
38
40
|
|
|
39
41
|
module Origami
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -32,38 +32,60 @@ module Origami
|
|
|
32
32
|
|
|
33
33
|
module Graphics
|
|
34
34
|
|
|
35
|
-
module RenderingIntent
|
|
36
|
-
ABSOLUTE_COLORIMETRIC = :AbsoluteColorimetric
|
|
37
|
-
RELATIVE_COLORIMETRIC = :RelativeColorimetric
|
|
38
|
-
SATURATION = :Saturation
|
|
39
|
-
PERCEPTUAL = :Perceptual
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
module BlendMode
|
|
43
|
-
NORMAL = :Normal
|
|
44
|
-
COMPATIBLE = :Compatible
|
|
45
|
-
MULTIPLY = :Multiply
|
|
46
|
-
SCREEN = :Screen
|
|
47
|
-
OVERLAY = :Overlay
|
|
48
|
-
DARKEN = :Darken
|
|
49
|
-
LIGHTEN = :Lighten
|
|
50
|
-
COLORDODGE = :ColorDodge
|
|
51
|
-
COLORBURN = :ColorBurn
|
|
52
|
-
HARDLIGHT = :HardLight
|
|
53
|
-
SOFTLIGHt = :SoftLight
|
|
54
|
-
DIFFERENCE = :Difference
|
|
55
|
-
EXCLUSION = :Exclusion
|
|
56
|
-
end
|
|
57
|
-
|
|
58
35
|
class InvalidColorError < Exception; end
|
|
59
36
|
module Color
|
|
60
37
|
|
|
38
|
+
module Intent
|
|
39
|
+
ABSOLUTE = :AbsoluteColorimetric
|
|
40
|
+
RELATIVE = :RelativeColorimetric
|
|
41
|
+
SATURATION = :Saturation
|
|
42
|
+
PERCEPTUAL = :Perceptual
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
module BlendMode
|
|
46
|
+
NORMAL = :Normal
|
|
47
|
+
COMPATIBLE = :Compatible
|
|
48
|
+
MULTIPLY = :Multiply
|
|
49
|
+
SCREEN = :Screen
|
|
50
|
+
OVERLAY = :Overlay
|
|
51
|
+
DARKEN = :Darken
|
|
52
|
+
LIGHTEN = :Lighten
|
|
53
|
+
COLORDODGE = :ColorDodge
|
|
54
|
+
COLORBURN = :ColorBurn
|
|
55
|
+
HARDLIGHT = :HardLight
|
|
56
|
+
SOFTLIGHt = :SoftLight
|
|
57
|
+
DIFFERENCE = :Difference
|
|
58
|
+
EXCLUSION = :Exclusion
|
|
59
|
+
end
|
|
60
|
+
|
|
61
61
|
module Space
|
|
62
62
|
DEVICE_GRAY = :DeviceGray
|
|
63
63
|
DEVICE_RGB = :DeviceRGB
|
|
64
64
|
DEVICE_CMYK = :DeviceCMYK
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
+
def self.cmyk_to_rgb(c, m, y, k)
|
|
68
|
+
r = 1 - (( c * ( 1 - k ) + k ))
|
|
69
|
+
g = 1 - (( m * ( 1 - k ) + k ))
|
|
70
|
+
b = 1 - (( y * ( 1 - k ) + k ))
|
|
71
|
+
|
|
72
|
+
[ r, g, b ]
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def self.gray_to_rgb(g)
|
|
76
|
+
[ g, g, g ]
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
#
|
|
80
|
+
# Class representing an embedded ICC Profile stream.
|
|
81
|
+
#
|
|
82
|
+
class ICCProfile < Stream
|
|
83
|
+
field :N, :Type => Integer, :Required => true, :Version => '1.3'
|
|
84
|
+
field :Alternate, :Type => [ Name, Array ]
|
|
85
|
+
field :Range, :Type => Array
|
|
86
|
+
field :Metadata, :Type => Stream, :Version => '1.4'
|
|
87
|
+
end
|
|
88
|
+
|
|
67
89
|
class GrayScale
|
|
68
90
|
attr_accessor :g
|
|
69
91
|
|