cgbi_to_png 0.0.1 → 0.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f4ad6bde43d1022a868cb745aadaf43a1e3ecbeb
4
- data.tar.gz: a5bccff0fd3ed467a7fb7ecdbb7fd4def2fb961c
3
+ metadata.gz: 42d5dec26066b1dcbf497c8d78b8e4bb3d861a66
4
+ data.tar.gz: 1253b792583843cbaf911b54446f5dc3e205ac90
5
5
  SHA512:
6
- metadata.gz: c1791c19c73e9a83a995704bf1d63bc1e97bad31470f68c13e7547abdc248a90e3a61063d48d2b6512f1b26fbfd648463d41de4e528f0eb327ea9e0381e0fa66
7
- data.tar.gz: 7bfc27e6f153637b96021ad00396cf708eb4d52a1fd78123037ee276e6046545661ae1e9fa92940dcd56e9c3a97c81d8a8623a6e7a0430fdfb9af90b10acbdb8
6
+ metadata.gz: bd468f8bf7ccf2ec4234d066dbb2bb4587a29542552c59d48302518ba39c0ed670b480f9c67a44f0237b30f61ee338eb8a36fd2d28dcfa5fc93a914fcfd6357e
7
+ data.tar.gz: b3bb61f55ce6fef210028237e3ffa3047a8e8365aaff23f16ec59321a7a25e7672c964d76c0daef79a8d7734bf242bf364aaae2d633feafad6c66b5589b7b650
@@ -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 = OptimizedPngs::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}
@@ -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
@@ -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
- raise ArgumentError.new("Data is not a valid PNG file. Header missmatch (#{pngheader} != #{blob_header})") unless pngheader == blob_header
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
@@ -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 = PNG_HEADER
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'
@@ -1,3 +1,3 @@
1
- module OptimizedPngs
2
- VERSION = "0.0.1"
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.1
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-10 00:00:00.000000000 Z
11
+ date: 2015-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler