Skip to content

Commit b87149b

Browse files
committed
ratio is now replaced by size in the parameters
1 parent 11cc577 commit b87149b

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ contain two files:
1818
* `watermark`: The watermark to apply to the image.
1919

2020
Additional parameters can be sent to customize the conversion process:
21-
* `ratio`: The ratio of the watermark to the image. The value must be a float between 0 and 1. The default value is 0.5.
21+
* `size`: The size of the watermark in relation to the image in percentage. The value must be an integer. The default value is 75.
2222
* `position`: The position of the watermark. The value must be one of `center`, `top-left`, `top`, `top-right`, `left`, `right`, `bottom-left`, `bottom`, `bottom-right`. The default value is `center`.
2323
* `padding`: The padding between the watermark and the edge of the image. The value must be an integer. The default value is 10. This is ignored if the position is `center`.
2424
* `format`: The format of the output image. The value must be one of `jpg`, `png`, `gif`. The default value is `png`.
@@ -47,7 +47,7 @@ curl -X POST http://localhost:3000/apply -F "image=@/path/to/image.png" -F "wate
4747

4848
A more complex scenario with additional parameters:
4949
```bash
50-
curl -X POST http://localhost:3000/apply -F "image=@/path/to/image.png" -F "watermark=@/path/to/watermark.png" -F "blur=3" -F "ratio=1" -F "format=jpg" -F "quality=100" -o test-watermarked.jpg
50+
curl -X POST http://localhost:3000/apply -F "image=@/path/to/image.png" -F "watermark=@/path/to/watermark.png" -F "blur=3" -F "size=100" -F "format=jpg" -F "quality=100" -o test-watermarked.jpg
5151
```
5252

5353
## Client

main.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ app.post('/apply', cpUpload, async (req, res) => {
4040
const watermarkImage = await Jimp.read(watermarkFile.path);
4141

4242
// calculating the dimensions of the watermark
43-
const ratio = parseFloat(req.body.ratio ?? .75);
43+
const ratio = (req.body.size ?? 75) / 100;
4444
let newHeight, newWidth;
4545
if ((mainImage.getHeight() / mainImage.getWidth()) < (watermarkImage.getHeight() / watermarkImage.getWidth())) {
4646
newHeight = ratio * mainImage.getHeight();

0 commit comments

Comments
 (0)