cgbi_to_png 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/cgbi_to_png.gemspec +1 -1
- data/lib/cgbi_to_png.rb +1 -1
- data/lib/cgbi_to_png/chunk.rb +3 -1
- data/lib/cgbi_to_png/png_file.rb +3 -2
- data/lib/cgbi_to_png/version.rb +2 -2
- 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: 42d5dec26066b1dcbf497c8d78b8e4bb3d861a66
|
4
|
+
data.tar.gz: 1253b792583843cbaf911b54446f5dc3e205ac90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd468f8bf7ccf2ec4234d066dbb2bb4587a29542552c59d48302518ba39c0ed670b480f9c67a44f0237b30f61ee338eb8a36fd2d28dcfa5fc93a914fcfd6357e
|
7
|
+
data.tar.gz: b3bb61f55ce6fef210028237e3ffa3047a8e8365aaff23f16ec59321a7a25e7672c964d76c0daef79a8d7734bf242bf364aaae2d633feafad6c66b5589b7b650
|
data/cgbi_to_png.gemspec
CHANGED
@@ -5,7 +5,7 @@ require 'cgbi_to_png/version'
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "cgbi_to_png"
|
8
|
-
spec.version =
|
8
|
+
spec.version = CgBItoPNG::VERSION
|
9
9
|
spec.authors = ["Jon Appelberg"]
|
10
10
|
spec.summary = %q{Convert Apple optimized PNG images to standard PNG images}
|
11
11
|
spec.description = %q{This Gem allows converting CgBI (Apple's optimized PNG) images into 'standard' PNG images. See http://iphonedevwiki.net/index.php/CgBI_file_format}
|
data/lib/cgbi_to_png.rb
CHANGED
@@ -2,7 +2,7 @@ require 'cgbi_to_png/version'
|
|
2
2
|
require 'cgbi_to_png/png_file.rb'
|
3
3
|
|
4
4
|
module CgBItoPNG
|
5
|
-
PNG_HEADER = "\x89PNG\r\n\x1a\n".force_encoding('ASCII-8BIT')
|
5
|
+
PNG_HEADER = "\x89PNG\r\n\x1a\n".force_encoding('ASCII-8BIT').freeze
|
6
6
|
LEN_HEADER = 8
|
7
7
|
LEN_LENGTH = 4
|
8
8
|
LEN_CHUNK_TYPE = 4
|
data/lib/cgbi_to_png/chunk.rb
CHANGED
@@ -87,7 +87,9 @@ module CgBItoPNG
|
|
87
87
|
def self.get_chunks(data_blob)
|
88
88
|
pngheader = PNG_HEADER
|
89
89
|
blob_header = data_blob[0..7]
|
90
|
-
|
90
|
+
hex_head = pngheader.unpack("H*").first
|
91
|
+
hex_blob_head = blob_header.unpack("H*").first
|
92
|
+
raise ArgumentError.new("Data is not a valid PNG file. Header missmatch (#{hex_head} != #{hex_blob_head})") unless pngheader == blob_header
|
91
93
|
chunks = {}
|
92
94
|
index = LEN_HEADER
|
93
95
|
while index < data_blob.length
|
data/lib/cgbi_to_png/png_file.rb
CHANGED
@@ -3,7 +3,7 @@ require 'cgbi_to_png/chunk'
|
|
3
3
|
module CgBItoPNG
|
4
4
|
class PNGfile
|
5
5
|
def initialize(data_blob)
|
6
|
-
@blob = data_blob
|
6
|
+
@blob = data_blob.force_encoding('ASCII-8BIT')
|
7
7
|
@chunks = Chunk.get_chunks(data_blob)
|
8
8
|
@ihdr = @chunks['IHDR'].first.get_dimensions
|
9
9
|
@width = @ihdr[:width]
|
@@ -22,7 +22,8 @@ module CgBItoPNG
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def to_blob
|
25
|
-
blob =
|
25
|
+
blob = ""
|
26
|
+
blob << PNG_HEADER
|
26
27
|
@chunks.each do |_k, v|
|
27
28
|
v.each do |chunk|
|
28
29
|
next if chunk.type == 'CgBI'
|
data/lib/cgbi_to_png/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module
|
2
|
-
VERSION = "0.0.
|
1
|
+
module CgBItoPNG
|
2
|
+
VERSION = "0.0.2"
|
3
3
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cgbi_to_png
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Appelberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|