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 +4 -4
- data/README.md +1 -1
- data/lib/dragonfly_pdf/processors/page_thumb.rb +13 -6
- data/lib/dragonfly_pdf/version.rb +1 -1
- 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: 095237a6a9622212369e843513a40d2b24ace6f8
|
4
|
+
data.tar.gz: 98e29ab37babf917c59201b240cb8d8ea55ea362
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
"#{
|
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
|
30
|
-
"
|
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
|
-
|
34
|
-
|
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
|
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.
|
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-
|
11
|
+
date: 2016-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dragonfly
|