ExpressJS API to help you resize images from a directory and generate new ones in the resized
subfolder.
See the
curl
examples below and parameters to understand how to use it
npm installl
npm start
With directory, where you provide the absolute path where the images are stored
curl -0 -v -X POST localhost:9000/resize \
-H 'Content-Type: application/json; charset=utf-8' \
--data-binary @- << EOF
{
"width": 1200,
"quality": 90,
"numberPrefixOnly": false,
"imgDir": "/Users/ama/projects/bitcoinrun/bitcoinrun.art/assets/images/runs/27-lausanne/city",
"outputImgExt": "jpg"
}
EOF
If no image directory (
imgDir
) is provided, then the images from images folder of the project are used.
In the following example only images starting with a number and dash are resized (numberPrefixOnly
is true
):
curl -0 -v -X POST localhost:9000/resize \
-H 'Content-Type: application/json; charset=utf-8' \
--data-binary @- << EOF
{
"width": 1200,
"quality": 90,
"numberPrefixOnly": true
}
EOF
Parameters
width
- required desired width list (height is automatically scaled)quality
- (0 to 100)numberPrefixOnly
false
- default all images in the directory are considered for resizingtrue
- ONLY images with number prefixes are resized (e.g.4-good-view-zweisimmen-north.jpeg
)
imgDir
(optional) - absolute path where the images are stored- the resized images are placed in the
${imgDir}/resized
sub-directory - if this parameter is not provided the program expects that the images are placed in the images directory. Resized images are then generated in images/resized directory
- tested only in MacOS. Should work fine in Linux OS. For Windows place the images in the
input
directory as mentioned above
- the resized images are placed in the
You can use Postman or similar tools to execute the POST commands above if you are more comfortable with these tools
The following command generates a blog post template page (e.g. 2021-07-14-change-me.md
) with images from
the list in input/image-paths.txt
curl -0 -v -X POST localhost:9000/generate-blogpost