icc_parser 0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/icc_parser.rb +27 -0
  3. metadata +44 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fe902ac9e92c4b113faf852b2229ff8d8e446932
4
+ data.tar.gz: e2a62c93e204111303dd00e0d0a540aafbf694eb
5
+ SHA512:
6
+ metadata.gz: 34cfd5ef8fa72ec505aba684a209135a90b62e8eda3b47cc941a8fa0f580f45dc4de0e8e22f9f189ba0a294c8478700e4adbbd496b5728a44634695cb9e538ad
7
+ data.tar.gz: 0798dc6cdbdf4b70dff21386881d57687274d14525834e6f4eed1859d26ee93f7d0fac22e4b37590712ad4df171a275d4a670d77541b9f37f33f9b04397b3f78
@@ -0,0 +1,27 @@
1
+ class ICCParser # Copyright and description are parsed, at least. And content is divided to tags...
2
+ def self.parse icc_profile
3
+ icc_profile = icc_profile.b
4
+ ret = {}
5
+ ret[:creator] = icc_profile[80..83]
6
+ pos = 127 # End of header
7
+ tagnum = icc_profile[128..131].unpack("C*").inject { |r, n| r << 8 | n }
8
+ pos = 132
9
+ ret[:tags] = {}
10
+ for i in 1..tagnum
11
+ name = icc_profile[pos..pos+3]
12
+ offset = icc_profile[pos+4..pos+7].unpack("C*").inject { |r, n| r << 8 | n }
13
+ size = icc_profile[pos+8..pos+11].unpack("C*").inject { |r, n| r << 8 | n }
14
+ if name == "cprt"
15
+ value = icc_profile[offset+8..offset+size-2]
16
+ elsif name == "desc"
17
+ textsize = icc_profile[offset+10..offset+11].unpack("C*").inject { |r, n| r << 8 | n }
18
+ value = icc_profile[offset+12..offset+10+textsize]
19
+ else
20
+ value = icc_profile[offset..offset+size]
21
+ end
22
+ ret[:tags][name.to_sym] = value
23
+ pos += 12
24
+ end
25
+ return ret
26
+ end
27
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: icc_parser
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Piotr Żurek
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-09 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A simple Ruby parser for ICC profiles
14
+ email: piotr@sology.eu
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/icc_parser.rb
20
+ homepage: https://github.com/Sology/icc_parser
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 2.0.0
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.2.0
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Ruby ICC Profile Parser
44
+ test_files: []