Open NITEMAN opened 4 years ago
extend
is for compatibility for new versions or not commonly used args.
the new version committed, please try.
quality is int type
"quality": 94
Maybe because we're wrapping it in docker (https://github.com/sbitio/docker-wkhtmltox), but still doesn't work (image sizes are are plain explicative if you try my example)
can you try https://github.com/idocking/go-wkhtmltox
?
It doesn't work either using that container (and container is somehow broken):
niteman@teg:~/tmp$ ls -lah
total 8,0K
drwxr-xr-x 2 niteman niteman 4,0K mar 13 15:07 .
drwxr-xr-x 49 niteman niteman 4,0K mar 13 14:46 ..
niteman@teg:~/tmp$ # container doesn't work as expected
niteman@teg:~/tmp$ docker run --rm -it -d -p 9080:8080 idocking/go-wkhtmltox:latest
fbce9ef927dd7dc4867a190700c4eeac42d93b8dfe253b4eeaf472f8411d7362
niteman@teg:~/tmp$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b387fe76ebc2 traefik "/traefik --api --do…" 7 months ago Up 3 weeks 0.0.0.0:80->80/tcp, 0.0.0.0:8080->8080/tcp traefik_proxy
niteman@teg:~/tmp$ # make container work
niteman@teg:~/tmp$ docker run --rm -it -d -p 9080:8080 --entrypoint=/app/go-wkhtmltox idocking/go-wkhtmltox:latest run
200b7d50728292f1c3707b95f76b4adad4e20e6cbef8fa962eec32a52689e92c
niteman@teg:~/tmp$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
200b7d507282 idocking/go-wkhtmltox:latest "/app/go-wkhtmltox r…" 4 seconds ago Up 3 seconds 0.0.0.0:9080->8080/tcp ecstatic_grothendieck
b387fe76ebc2 traefik "/traefik --api --do…" 7 months ago Up 3 weeks 0.0.0.0:80->80/tcp, 0.0.0.0:8080->8080/tcp traefik_proxy
niteman@teg:~/tmp$ curl -s -X POST \
> "http://127.0.0.1:9080/v1/convert" \
> -H 'accept-encoding: gzip' \
> -H 'cache-control: no-cache' \
> -H 'content-type: application/json' \
> -d '{
> "to" : "image",
> "converter":{
> "format" : "png",
> "quality": 0,
> "uri": "https://sbit.io"
>
> },
> "template": "binary"
> }' --compressed -o sbit_using_quality.png
niteman@teg:~/tmp$ file sbit_using_quality.png
sbit_using_quality.png: PNG image data, 1024 x 1061, 8-bit/color RGBA, non-interlaced
niteman@teg:~/tmp$ curl -s -X POST \
> "http://127.0.0.1:9080/v1/convert" \
> -H 'accept-encoding: gzip' \
> -H 'cache-control: no-cache' \
> -H 'content-type: application/json' \
> -d '{
> "to" : "image",
> "converter":{
> "format" : "png",
> "extend": {"quality": "0" },
> "uri": "https://sbit.io"
>
> },
> "template": "binary"
> }' --compressed -o sbit_using_extend.png
niteman@teg:~/tmp$ file sbit_using_extend.png
sbit_using_extend.png: PNG image data, 1024 x 1061, 8-bit/color RGBA, non-interlaced
niteman@teg:~/tmp$ ls -lah *
-rw-r--r-- 1 niteman niteman 243K mar 13 15:09 sbit_using_extend.png
-rw-r--r-- 1 niteman niteman 4,2M mar 13 15:08 sbit_using_quality.png
This should be fairly plain to reproduce anywhere
I'm new to Go so I'm gessing, but it seems quality is not added to
args
in ToImageOptions.The fact is that calling the API as README suggest doesn't work as espected:
But calling the API with extend works:
Please note that 0 is a must param for PNG images as indicated in https://github.com/wkhtmltopdf/wkhtmltopdf/issues/2608
/cc @jonhattan @facine