https://github.com/kurama622/pdf2img
Convert pdf to images.
https://github.com/kurama622/pdf2img
Last synced: 8 months ago
JSON representation
Convert pdf to images.
- Host: GitHub
- URL: https://github.com/kurama622/pdf2img
- Owner: Kurama622
- Created: 2021-02-05T07:24:01.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-02-07T09:16:37.000Z (over 4 years ago)
- Last Synced: 2025-01-11T18:47:06.777Z (9 months ago)
- Language: Python
- Size: 1.61 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# pdf2img
## Introduction
Convert pdf to images.
## Requires
- pdf2image
- python3```shell
pip install pdf2image
```## Show

## Install
```shell
git clone https://github.com/demonlord1997/pdf2img
```( If you only use it in [ranger](https://github.com/ranger/ranger), you don't need to install it. )
## Usage
### Use In Shell| Parameters | Description |
|:-------------------|:-------------------------------------------|
| `--inputfile`/`-i` | PDF file |
| `--dpi`/`-d` | Resolution of images, default value is 600 |
| `--outfolder`/`-f` | Path of outputing images |
| `--outfile`/`-o` | image's name |For example:
```shell
python pdf2img.py -i example.pdf -d 600 -f . -o example```
### Use In Ranger
If you want to use pdf2img in ranger, you don't need to clone the repository. I have prepared the class named `pdf2img` for you:
```python
class pdf2img(Command):
"""
:pdf2imgConvert PDF-file to image
"""
def execute(self):
import tempfile
from pdf2image import convert_from_path,convert_from_bytesif not self.arg(1):
pdf_file = self.fm.thisfile.path
else:
pdf_file = self.rest(1)output = pdf_file[0:-4]
with tempfile.TemporaryDirectory() as path:
image_from_path = convert_from_path(pdf_file, dpi=400, fmt='png', output_folder='.', output_file=output)def tab(self, tabnum):
return self._tab_directory_content()
```
You can copy the class into `commands.py` of ranger. (~/.config/ranger/commands.py)Then you can input `:pdf2img ` in ranger.
