mirror of
https://github.com/openfaas/faas.git
synced 2025-06-23 07:13:23 +00:00
Allow resizing of images
This commit is contained in:
1
sample-functions/ResizeImageMagick/.gitignore
vendored
Normal file
1
sample-functions/ResizeImageMagick/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
small_gordon.png
|
10
sample-functions/ResizeImageMagick/Dockerfile
Normal file
10
sample-functions/ResizeImageMagick/Dockerfile
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
FROM v4tech/imagemagick
|
||||||
|
|
||||||
|
ADD https://github.com/alexellis/faas/releases/download/0.5.2-alpha/fwatchdog /usr/bin
|
||||||
|
RUN chmod +x /usr/bin/fwatchdog
|
||||||
|
|
||||||
|
ENV fprocess "convert - -resize 50% fd:1"
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
CMD [ "/usr/bin/fwatchdog"]
|
24
sample-functions/ResizeImageMagick/README.md
Normal file
24
sample-functions/ResizeImageMagick/README.md
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
## functions/resizer
|
||||||
|
|
||||||
|
To resize an image with ImageMagick do the following:
|
||||||
|
|
||||||
|
**Create your function on the FaaS UI or via `curl`**
|
||||||
|
|
||||||
|
```
|
||||||
|
$ curl -s --fail localhost:8080/system/functions -d '{"service": "stronghash", "image": "functions/alpine", "envProcess": "sha512sum", "network": "func_functions"}'
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
**Resize a picture by 50%**
|
||||||
|
|
||||||
|
Now pick an image such as the included picture of Gordon and use `curl` or a tool of your choice to send the data to the function. Pipe the result into a new file like this:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ curl localhost:8080/function/resizer --data-binary @gordon.png > small_gordon.png
|
||||||
|
```
|
||||||
|
|
||||||
|
**Customize the transformation**
|
||||||
|
|
||||||
|
If you want to customise the transformation then edit the Dockerfile and create a new image.
|
||||||
|
|
||||||
|
|
6
sample-functions/ResizeImageMagick/build.sh
Executable file
6
sample-functions/ResizeImageMagick/build.sh
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
docker build -t functions/resizer .
|
||||||
|
|
||||||
|
echo Built functions/resizer
|
||||||
|
|
BIN
sample-functions/ResizeImageMagick/gordon.png
Normal file
BIN
sample-functions/ResizeImageMagick/gordon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 200 KiB |
Reference in New Issue
Block a user