languitar / drawio-batch

Command line converter for draw.io diagrams
65 stars 12 forks source link

Scale and quality features do nothing #6

Closed DanielMarchand closed 5 years ago

DanielMarchand commented 5 years ago

I notice that the 'format' and 'quality' commands don't actually do anything e.g.:

drawio-batch my_input.xml my_output.png -s 300 -q 100

When I change "-s" and "-q" the output file size remains the same and I notice not difference in image quality..

languitar commented 5 years ago

for png, quality will not make a real difference as this is a lossless format. for jpeg you should see a difference. Scale used to work previously. Maybe something has changed upstream that broke this. I will have to take a look why this happened.

DanielMarchand commented 5 years ago

Great thanks!

languitar commented 5 years ago

Strange, I thought I verified that scale doesn't work when I first looked at this bug, but now I can't reproduce the problem anymore:

languitar@jaco ~/src/drawio-batch (master)> drawio-batch -s 4 ~/thesis/img/middleware/rsb-domain.xml test.png
languitar@jaco ~/src/drawio-batch (master)> file test.png
test.png: PNG image data, 2324 x 1684, 8-bit/color RGBA, non-interlaced
languitar@jaco ~/src/drawio-batch (master)> drawio-batch -s 1 ~/thesis/img/middleware/rsb-domain.xml test.png
languitar@jaco ~/src/drawio-batch (master)> file test.png
test.png: PNG image data, 581 x 421, 8-bit/color RGBA, non-interlaced
languitar commented 5 years ago

Confusing, with a different file this doesn't work:

languitar@jaco ~/src/drawio-batch (master)> node drawio-batch.js -s 2 (pwd)/drawio/src/main/webapp/templates/uml/uml_1.xml test.png
languitar@jaco ~/src/drawio-batch (master)> file test.png
test.png: PNG image data, 612 x 792, 8-bit/color RGBA, non-interlaced
languitar@jaco ~/src/drawio-batch (master)> node drawio-batch.js -s 4 (pwd)/drawio/src/main/webapp/templates/uml/uml_1.xml test.png
languitar@jaco ~/src/drawio-batch (master)> file test.png
test.png: PNG image data, 612 x 792, 8-bit/color RGBA, non-interlaced
languitar commented 5 years ago

Alright, scale only seems to work in case "page view" is disabled. Let's see whether this is also the case in the drawio desktop app.

languitar commented 5 years ago

There things work. Very confusing. I will have to check if they have changed their backend.

languitar commented 5 years ago

Yikes, OK, in case page view is disabled, what the normal drawio clients do is to manually compute bounds of the image. These are then passed as "w" and "h" parameters to the export backend. As I don't construct a full mxGraph of the document in my script, I can't compute those dimensions beforehand. So, what I can do now is to provide those "w" and "h" params on the command line as an additional option. For non-page-view documents "scale" can still be used, but for page view docs, the maximum bounds have to be specified then with "w" and "h". The export will still ensure that aspect ratio is preserved and the given sizes are interpreted as the legal maximum.

Do you think that could be a usable plan? I don't see how to convert from scale to bounds dynamically.

languitar commented 5 years ago

Maybe @davidjgraph can also add something to this discussion?

DanielMarchand commented 5 years ago

Hi @languitar, I think this would be fine option! My background is a bit weak on draw.io but this seems good