Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quality not appended in ToImageOptions #8

Open
NITEMAN opened this issue Dec 16, 2019 · 5 comments
Open

Quality not appended in ToImageOptions #8

NITEMAN opened this issue Dec 16, 2019 · 5 comments

Comments

@NITEMAN
Copy link

NITEMAN commented Dec 16, 2019

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:

{
    "to" : "image",
    "converter":{
      "format" : "png",
      "quality": "0",
      "uri": "https://sbit.io"
      
    },
  "template": "binary"
  }

But calling the API with extend works:

{
    "to" : "image",
    "converter":{
      "format" : "png",
      "extend": {"quality": "0" },
      "uri": "https://sbit.io"
      
    },
  "template": "binary"
  }

Please note that 0 is a must param for PNG images as indicated in wkhtmltopdf/wkhtmltopdf#2608

/cc @jonhattan @facine

@xujinzheng
Copy link
Member

extend is for compatibility for new versions or not commonly used args.

@xujinzheng
Copy link
Member

the new version committed, please try.

quality is int type

"quality": 94

@NITEMAN
Copy link
Author

NITEMAN commented Feb 4, 2020

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)

@xujinzheng
Copy link
Member

can you try https://github.com/idocking/go-wkhtmltox ?

@NITEMAN
Copy link
Author

NITEMAN commented Mar 13, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants