Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
joanfabregat committed Feb 23, 2024
1 parent 37a0e9b commit f8cb610
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ All requests must by send in POST to the `/convert` endpoint with a `multipart/f
* `width`: The width of the output images. Default is 1000.
* `background`: The background color of the output images. Default is white.
* `quality`: The quality of the output images in percentage. Default is 80.
* `page`: The page to convert starting at 0. Default is 0.
* `page`: The page to convert starting at 1. Default is 1.

The server returns `200` if the conversion was successful and the images are available in the response body. In case of error, the server returns a `400` status code with a JSON object containing the error message (format: `{error: string}`).

Expand All @@ -38,7 +38,7 @@ curl -X POST -F "file=@/path/to/file.pdf" http://localhost:3000/convert -o examp
```
Conversion with custom params (page 2 to JPEG with an orange background):
```bash
curl -X POST -F "file=@/path/to/file.pdf" -F "page=1" -F "format=jpg" -F "background=#F60" http://localhost:3000/convert -o example.jpg
curl -X POST -F "file=@/path/to/file.pdf" -F "page=2" -F "format=jpg" -F "background=#F60" http://localhost:3000/convert -o example.jpg
```

## Client
Expand Down
2 changes: 1 addition & 1 deletion main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ app.post('/convert', upload.single('file'), (req, res) => {
+ `-flatten `
+ `-resize ${+(req.body.width ?? 800)}x${+(req.body.height ?? 600)} `
+ `-quality ${+(req.body.quality ?? 80)}% `
+ `pdf:${pdfPath}[${+(req.body.page ?? 0)}] `
+ `pdf:${pdfPath}[${(+(req.body.page ?? 1) - 1)}] `
+ `${req.body.format ?? 'webp'}:${imagePath}`);

// sending the images as a response
Expand Down

0 comments on commit f8cb610

Please sign in to comment.