pdftoimage 0.3.0 → 0.3.1
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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +91 -0
- data/lib/pdftoimage/image.rb +6 -0
- data/lib/pdftoimage/version.rb +1 -1
- metadata +3 -3
- data/README.rdoc +0 -51
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 382ac5bc0e37e99acc44c9b7b40883ca8ca0a7b72595229e460fd4c0d4f6ee27
|
|
4
|
+
data.tar.gz: 6163c9afa9cc35a3bf6231af43eaf7ee1a5ae490c946b886f2904f63af2af9b6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 640b7bbd60b1a15db121c27c1d56b360dbb509c6cdce62d525ed3ea8aceeed3e67ee359eae9db350e0d031c06b178ad5723cc29990075b96f762ad075627c614
|
|
7
|
+
data.tar.gz: 76a9559c9e50853022d5ef8748f1a0733bd065e5a832e47d3cb5106f8825b9860b786d5c1d87edb495fa511f62efc55b41b089e947bae3fc39c7e3dcd6ef4599
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com).
|
|
6
6
|
|
|
7
|
+
## [0.3.1] - 2026-03-21
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- `Image#crop(x, y, w, h)` for extracting a rectangular region from a PDF page
|
|
11
|
+
|
|
7
12
|
## [0.3.0] - 2026-03-20
|
|
8
13
|
|
|
9
14
|
### Added
|
data/README.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# pdftoimage
|
|
2
|
+
|
|
3
|
+
A Ruby gem for converting PDF documents into images using [poppler_utils](https://poppler.freedesktop.org/) and [MiniMagick](https://github.com/minimagick/minimagick).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
gem install pdftoimage
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### Requirements
|
|
12
|
+
|
|
13
|
+
- [poppler_utils](https://poppler.freedesktop.org/)
|
|
14
|
+
- [ImageMagick](https://imagemagick.org/)
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
### From a file
|
|
19
|
+
|
|
20
|
+
```ruby
|
|
21
|
+
require 'pdftoimage'
|
|
22
|
+
|
|
23
|
+
images = PDFToImage.open('somefile.pdf')
|
|
24
|
+
images.each do |page|
|
|
25
|
+
page.resize('50%').save("output/page-#{page.page}.jpg")
|
|
26
|
+
end
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### With a block
|
|
30
|
+
|
|
31
|
+
```ruby
|
|
32
|
+
PDFToImage.open('report.pdf') do |page|
|
|
33
|
+
page.resize('150').quality('80%').save("out/thumbnail-#{page.page}.jpg")
|
|
34
|
+
end
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### From a URL
|
|
38
|
+
|
|
39
|
+
```ruby
|
|
40
|
+
pages = PDFToImage.open('https://example.com/report.pdf')
|
|
41
|
+
pages[0].save('first_page.png')
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### From an IO object
|
|
45
|
+
|
|
46
|
+
```ruby
|
|
47
|
+
File.open('report.pdf', 'rb') do |io|
|
|
48
|
+
pages = PDFToImage.open(io)
|
|
49
|
+
pages[0].save('first_page.png')
|
|
50
|
+
end
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### From binary data
|
|
54
|
+
|
|
55
|
+
```ruby
|
|
56
|
+
pdf_data = download_pdf_from_s3(key)
|
|
57
|
+
pages = PDFToImage.from_blob(pdf_data)
|
|
58
|
+
pages[0].save('first_page.png')
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Saving to an IO object
|
|
62
|
+
|
|
63
|
+
```ruby
|
|
64
|
+
pages = PDFToImage.open('report.pdf')
|
|
65
|
+
|
|
66
|
+
io = StringIO.new(''.b)
|
|
67
|
+
pages[0].save(io)
|
|
68
|
+
io.rewind
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Cropping a region
|
|
72
|
+
|
|
73
|
+
```ruby
|
|
74
|
+
PDFToImage.open('report.pdf') do |page|
|
|
75
|
+
page.crop(0, 300, 100, 300).save("out/cropped-#{page.page}.jpg")
|
|
76
|
+
end
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Setting resolution
|
|
80
|
+
|
|
81
|
+
```ruby
|
|
82
|
+
PDFToImage.open('report.pdf') do |page|
|
|
83
|
+
page.r(350).save("out/hires-#{page.page}.jpg")
|
|
84
|
+
end
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## License
|
|
88
|
+
|
|
89
|
+
Copyright (c) 2026 Rob Flynn
|
|
90
|
+
|
|
91
|
+
See [LICENSE](LICENSE) for details.
|
data/lib/pdftoimage/image.rb
CHANGED
data/lib/pdftoimage/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pdftoimage
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Rob Flynn
|
|
@@ -46,7 +46,7 @@ extra_rdoc_files: []
|
|
|
46
46
|
files:
|
|
47
47
|
- CHANGELOG.md
|
|
48
48
|
- LICENSE
|
|
49
|
-
- README.
|
|
49
|
+
- README.md
|
|
50
50
|
- lib/pdftoimage.rb
|
|
51
51
|
- lib/pdftoimage/image.rb
|
|
52
52
|
- lib/pdftoimage/version.rb
|
|
@@ -54,7 +54,7 @@ homepage: https://github.com/robflynn/pdftoimage
|
|
|
54
54
|
licenses:
|
|
55
55
|
- MIT
|
|
56
56
|
metadata:
|
|
57
|
-
changelog_uri: https://github.com/robflynn/pdftoimage/blob/
|
|
57
|
+
changelog_uri: https://github.com/robflynn/pdftoimage/blob/main/CHANGELOG.md
|
|
58
58
|
source_code_uri: https://github.com/robflynn/pdftoimage/
|
|
59
59
|
rdoc_options: []
|
|
60
60
|
require_paths:
|
data/README.rdoc
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
= pdftoimage
|
|
2
|
-
|
|
3
|
-
* {Homepage}[http://rubygems.org/gems/pdftoimage]
|
|
4
|
-
|
|
5
|
-
== Description
|
|
6
|
-
|
|
7
|
-
PDFToImage is a ruby gem which allows for conversion of a PDF document into
|
|
8
|
-
images. It uses poppler_utils to first convert the document to PNG and then
|
|
9
|
-
allows usage of ImageMagick to convert the image into other formats.
|
|
10
|
-
|
|
11
|
-
The reasoning behind using poppler_utils is due to the fact that ghostscript
|
|
12
|
-
occasionally has trouble with certain PDF documents which poppler_utils seems
|
|
13
|
-
to be able to parse without error.
|
|
14
|
-
|
|
15
|
-
== Examples
|
|
16
|
-
|
|
17
|
-
require 'pdftoimage'
|
|
18
|
-
images = PDFToImage.open('somefile.pdf')
|
|
19
|
-
images.each do |img|
|
|
20
|
-
img.resize('50%').save("output/page-#{img.page}.jpg")
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
require 'pdftoimage'
|
|
24
|
-
PDFToImage.open('anotherpdf.pdf') do |page|
|
|
25
|
-
page.resize('150').quality('80%').save('out/thumbnail-#{page.page}.jpg")
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
require 'pdftoimage'
|
|
29
|
-
PDFToImage.open('anotherpdf.pdf') do |page|
|
|
30
|
-
# Set the resolution to 350dpi
|
|
31
|
-
page.r(350).save('out/thumbnail-#{page.page}.jpg")
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
== Requirements
|
|
37
|
-
|
|
38
|
-
poppler_utils
|
|
39
|
-
|
|
40
|
-
ImageMagick
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
== Install
|
|
44
|
-
|
|
45
|
-
$ gem install pdftoimage
|
|
46
|
-
|
|
47
|
-
== Copyright
|
|
48
|
-
|
|
49
|
-
Copyright (c) 2023 Rob Flynn
|
|
50
|
-
|
|
51
|
-
See LICENSE for details.
|