dragonfly_pdf 0.2.6 → 0.2.7

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: 2fc722543b372f865b8d4eb0ab182770d4653316
4
- data.tar.gz: 1e0738ba31044b375180d60cae924da0fe43ca9e
3
+ metadata.gz: 095237a6a9622212369e843513a40d2b24ace6f8
4
+ data.tar.gz: 98e29ab37babf917c59201b240cb8d8ea55ea362
5
5
  SHA512:
6
- metadata.gz: cb1121c63fe16f5d364f098e23ed4edb46740b1c871622dea3da541e85b1e56f6b929fe54c5275432e48b43517fea1eb49733ff5438717f79911b9e9355f4bc2
7
- data.tar.gz: 6704887572f6b7620b2bbb3f87d4d725fe06492c4902b81b7725d8b8858d7d2a0a1976529534ba79f569780449a2cf09817898ba2b4ed583b89d6d3e1825feac
6
+ metadata.gz: d88ef57e725191fb64fe36949160e7119c66bcbde69a1d8b3d4d84083f479e15f3a0b7e53f434da9a5bcf11781ae321566582afa05242384b75673ce24a1685e
7
+ data.tar.gz: 9b574a0ef3a50dfb4f28f63c61bcf7f22e0111cb41c99f4635fd014eb05ee1ef90042cce7e1d5e35c5551758d5cf3c0e18718eeef3c458f23637a067c0f8c71c
data/README.md CHANGED
@@ -77,7 +77,7 @@ pdf.page(page_number=1)
77
77
 
78
78
  ### Page Thumb
79
79
 
80
- Generates thumbnail of a specified page, in defined density (dpi) and format.
80
+ Generates thumbnail of a specified page, in defined density (dpi) and format, using GhostScript.
81
81
 
82
82
  ```ruby
83
83
  pdf.page_thumb(page_number=1, opts={})
@@ -3,15 +3,16 @@ require_relative '../analysers/pdf_properties'
3
3
  module DragonflyPdf
4
4
  module Processors
5
5
  class PageThumb
6
+ attr_reader :content, :density, :page_number, :format
7
+
6
8
  def call(content, page_number = 1, opts = {})
7
9
  @content = content
8
10
  @page_number = page_number
9
11
  @format = opts['format'] || :png
10
12
  @density = opts['density'] || 150
11
- @crop_args = opts['crop_args']
12
13
 
13
14
  content.shell_update(ext: @format) do |old_path, new_path|
14
- "#{convert_command} #{old_path}[#{pdf_page_number}] #{new_path}"
15
+ "#{gs_command} -o '#{new_path}' -f '#{old_path}'"
15
16
  end
16
17
 
17
18
  @content.meta['format'] = @format.to_s
@@ -26,12 +27,18 @@ module DragonflyPdf
26
27
 
27
28
  private # =============================================================
28
29
 
29
- def convert_command
30
- "convert -alpha deactivate -background white -colorspace sRGB -density #{@density}x#{@density} -define pdf:use-cropbox=true -define pdf:use-trimbox=true #{@crop_args}"
30
+ def gs_command
31
+ "gs -sDEVICE=#{gs_format} -r#{density} -dTextAlphaBits=4 -dUseArtBox -dFirstPage=#{page_number} -dLastPage=#{page_number}"
31
32
  end
32
33
 
33
- def pdf_page_number
34
- @page_number - 1
34
+
35
+ def gs_format
36
+ case @format
37
+ when :png then :png16m
38
+ when :jpg, :jpeg then :jpeg
39
+ when :tif, :tiff then :tiff48nc
40
+ else :jpeg
41
+ end
35
42
  end
36
43
  end
37
44
  end
@@ -1,3 +1,3 @@
1
1
  module DragonflyPdf
2
- VERSION = '0.2.6'.freeze
2
+ VERSION = '0.2.7'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dragonfly_pdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Celizna
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-15 00:00:00.000000000 Z
11
+ date: 2016-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dragonfly