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

Add ppi argument #86

Merged
merged 14 commits into from
Aug 24, 2023
Merged

Add ppi argument #86

merged 14 commits into from
Aug 24, 2023

Conversation

jonmmease
Copy link
Collaborator

@jonmmease jonmmease commented Jul 17, 2023

Closes #85, relies on image-rs/image-png#403 which was released in png 0.17.10.

@jonmmease
Copy link
Collaborator Author

image-rs/image-png#403 was merged, so now we just need to wait for a release of image-png.

Also, adding the pixel dimensions metadata broke the CLI test because they are still doing exact binary comparison. So we need to either regenerate the baseline images, or use DSSIM for approximate comparison like we do with the vl-convert-rs tests.

@jonmmease
Copy link
Collaborator Author

@joelostblom, development wheel are available for this PR at https://github.com/vega/vl-convert/actions/runs/5581857544 (just download and unzip the wheels.zip artifact).

With these wheels, you can add a ppi kwarg to the vlc.vegalite_to_png and vlc.vega_to_png functions. I followed vega/vega-lite#8854 and set things up to increase the scale internally as the ppi increases, so you can leave scale at 1 and increase PPI and the resulting image in PDF export should be the same size but sharper.

When you have a chance, let me know how this works for you!

@joelostblom
Copy link

joelostblom commented Jul 18, 2023

Thanks so much for the quick PR! This is working for me and I am able to adjust both the size and ppi of the charts independently after adding a ppi argument to the the function you created previosuly. As expected, I am getting a constant size at different sharpness in JupyterBooks pdflatex output (to the left in the image below) whilst in JupyterLab, the size of the figure changes instead:

image

@jonmmease
Copy link
Collaborator Author

Thanks for trying it out @joelostblom, glad it's working as expected! The PR in image-png was merged and the next release should be in a couple of weeks, so I'll put this PR on hold until that point.

@joelostblom
Copy link

Just a heads up that I noticed that there was a new release made for image-png last week (or at least there is a new tag at https://github.com/image-rs/image-png/tags).

@jonmmease
Copy link
Collaborator Author

Oh, awesome. I had missed that go by. I'll get this PR updated soon

@jonmmease jonmmease changed the title WIP: Add ppi argument Add ppi argument Aug 24, 2023
@jonmmease jonmmease merged commit b7de0fc into main Aug 24, 2023
10 checks passed
@jonmmease jonmmease deleted the jonmmease/ppi branch August 24, 2023 23:18
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

Successfully merging this pull request may close these issues.

Support ppi argument
2 participants