pallete_png 1.0.0 → 1.0.1

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: 77d085a91c6dff3c308277348b3e7378f4304589
4
- data.tar.gz: 3ad138ed12a50b9b1b84f9f7aaefe8acb7d0eb64
3
+ metadata.gz: 1552cbc483b31d1edef2bfdd39e3b65f3e17afc6
4
+ data.tar.gz: d65dd59f5707d167d9cd30bf6faabc96724f8bb0
5
5
  SHA512:
6
- metadata.gz: 3be4632c1339a4c0f5aee41a891c0882f3459c55e705a8d789de826743262aa3af0508682bb0f7334ef5720f1e2be1551a2220b5134f42fd7a9ceebe404dbec7
7
- data.tar.gz: f9fb6b87f051ca04be25969d4feb21395af86cc0487482c398b6975d8507a2c9672377377c43f1b59294db5b7098a820454789ccf5f2f9aa523cc60e419bfd9f
6
+ metadata.gz: 1a79e56cb61c0095e2efa38b39f570ea84f107b69e642f988be608f815c0394668798d25ec8effa92857cfdc99b1c2cd8c9f15550006f109dd0752ac3443f4e9
7
+ data.tar.gz: fc5c46c576d8d3b04061f144622191c045909aeba825d300a0e860f48a8b529571ce71083e369b38cb3ec2e27e86753e91e12d6ecb8dafc0aac7bf31c4177f35
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  /.bundle/
2
- /Gemfile.lock
2
+ Gemfile.lock
3
+ *.pdf
data/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # PalletePNG
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/pallete_png.svg)](https://badge.fury.io/rb/pallete_png)
3
4
  [![Build Status](https://travis-ci.org/hidakatsuya/pallete_png.svg?branch=master)](https://travis-ci.org/hidakatsuya/pallete_png)
4
5
 
5
- PalletePNG is a pure-ruby library that makes a pallete-based PNG transparency.
6
+ PalletePNG is a pure-ruby library that make it possible to render the transparent of a pallete-based PNG in PDF by converting the color-mode of the image.
6
7
 
7
8
  ## Installation
8
9
 
@@ -25,18 +26,35 @@ Or install it yourself as:
25
26
  ```ruby
26
27
  require 'pallete_png'
27
28
 
28
- image_data = File.binread('/path/to/pallete-based-w-transparency.png')
29
+ image = File.binread('/path/to/pallete-based-w-transparency.png')
30
+ converted_image = PalletePNG.to_transparency(image)
31
+ ```
32
+
33
+ ### Exception
34
+
35
+ ```ruby
36
+ require 'pallete_png'
37
+
38
+ not_a_png_image = File.binread('/path/to/not_a_png.jpg')
29
39
 
30
- PalletePNG.to_transparency(image_data) # => The converted image data
40
+ begin
41
+ converted_image = PalletePNG.to_transparency(not_a_png_image)
42
+ rescue PalletePNG::Image::NotPNG
43
+ puts 'The image is not a PNG.'
44
+ end
31
45
  ```
32
46
 
47
+ ### Use with Prawn
48
+
49
+ See [Example::Using in Prawn](https://github.com/hidakatsuya/pallete_png/tree/master/example).
50
+
33
51
  ## Supported versions
34
52
 
35
53
  Ruby 2.2, 2.3
36
54
 
37
55
  ## Contributing
38
56
 
39
- Bug reports and pull requests are welcome on GitHub at https://github.com/hidakatsuya/transparency_png.
57
+ Bug reports and pull requests are welcome on GitHub at https://github.com/hidakatsuya/pallete_png.
40
58
 
41
59
  ## License
42
60
 
data/example/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec path: '..'
4
+ gem 'prawn'
data/example/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # Example::Using in Prawn
2
+
3
+ Currently, [Prawn](https://github.com/prawnpdf/prawn) does not support a pallete-based PNG with transparency.
4
+
5
+ ```ruby
6
+ Prawn::Document.generate 'result.pdf' do
7
+ image 'images/pallete-based-w-transparency.png'
8
+ # =>
9
+ # Pallete-based transparency in PNG is not currently supported.
10
+ # (Prawn::Errors::UnsupportedImageType)
11
+ end
12
+ ```
13
+
14
+ But, you can draw the image using [PalletePNG](https://rubygems.org/gems/pallete_png) like below.
15
+
16
+ ```ruby
17
+ require 'pallete_png'
18
+
19
+ Prawn::Document.generate 'result.pdf' do |doc|
20
+ image_data = File.binread 'images/pallete-based-w-transparency.png'
21
+ doc.image StringIO.new(PalletePNG.to_transparency(image_data))
22
+ end
23
+ ```
24
+
25
+ ## How to run
26
+
27
+ $ bundle install
28
+ $ bundle exec ruby prawn_image.rb
@@ -0,0 +1,14 @@
1
+ require 'prawn'
2
+ require 'pallete_png'
3
+
4
+ Prawn::Document.generate 'result.pdf' do |pdf|
5
+ image_data = File.read 'images/pallete-based-w-transparency.png'
6
+
7
+ # If you draw the original image, you will get the following Prawn's error:
8
+ # pdf.image 'images/pallete-based-w-transparency.png'
9
+ #
10
+ # Pallete-based transparency in PNG is not currently supported.
11
+ # (Prawn::Errors::UnsupportedImageType)
12
+
13
+ pdf.image StringIO.new(PalletePNG.to_transparency(image_data))
14
+ end
@@ -1,3 +1,3 @@
1
1
  module PalletePNG
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
data/pallete_png.gemspec CHANGED
@@ -8,8 +8,11 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ['Katsuya HIDAKA']
9
9
  spec.email = ['hidakatsuya@gmail.com']
10
10
 
11
- spec.summary = 'Makes a pallete-based PNG transparency'
12
- spec.description = 'PalletePNG is a pure-ruby library that makes a pallete-based PNG transparency.'
11
+ spec.summary = 'Make it possible to render the transparent of a pallete-based PNG in PDF'
12
+ spec.description = <<-DESC
13
+ PalletePNG is a pure-ruby library that make it possible to render
14
+ the transparent of a pallete-based PNG in PDF by converting the color-mode of the image.
15
+ DESC
13
16
  spec.homepage = 'https://github.com/hidakatsuya/pallete_png'
14
17
  spec.license = 'MIT'
15
18
  spec.platform = Gem::Platform::RUBY
@@ -24,5 +27,4 @@ Gem::Specification.new do |spec|
24
27
  spec.add_development_dependency 'bundler', '>= 1.0.0'
25
28
  spec.add_development_dependency 'rake'
26
29
  spec.add_development_dependency 'minitest'
27
- spec.add_development_dependency 'rr'
28
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pallete_png
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katsuya HIDAKA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-17 00:00:00.000000000 Z
11
+ date: 2016-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chunky_png
@@ -66,21 +66,9 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: rr
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- description: PalletePNG is a pure-ruby library that makes a pallete-based PNG transparency.
69
+ description: |2
70
+ PalletePNG is a pure-ruby library that make it possible to render
71
+ the transparent of a pallete-based PNG in PDF by converting the color-mode of the image.
84
72
  email:
85
73
  - hidakatsuya@gmail.com
86
74
  executables: []
@@ -93,6 +81,10 @@ files:
93
81
  - MIT-LICENSE
94
82
  - README.md
95
83
  - Rakefile
84
+ - example/Gemfile
85
+ - example/README.md
86
+ - example/images/pallete-based-w-transparency.png
87
+ - example/prawn_image.rb
96
88
  - lib/pallete_png.rb
97
89
  - lib/pallete_png/image.rb
98
90
  - lib/pallete_png/version.rb
@@ -127,6 +119,6 @@ rubyforge_project:
127
119
  rubygems_version: 2.5.1
128
120
  signing_key:
129
121
  specification_version: 4
130
- summary: Makes a pallete-based PNG transparency
122
+ summary: Make it possible to render the transparent of a pallete-based PNG in PDF
131
123
  test_files: []
132
124
  has_rdoc: