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

Change export output resolution #304

Closed
trevorsandy opened this issue Jul 4, 2019 · 1 comment
Closed

Change export output resolution #304

trevorsandy opened this issue Jul 4, 2019 · 1 comment

Comments

@trevorsandy
Copy link
Owner

trevorsandy commented Jul 4, 2019

Subject

Change export output resolution to generate instruction document and pages with a specified resolution, for example low resolution for web usage, and high resolution for printing.

The idea would be to be able to change the dpi setting, and get exactly the same layout but with different quality levels. For bitmap, Portable Network Graphics and Joint Photographic Experts Group images, this would result in larger (more pixels) images as dpi is increased. For PDF, the size of page (in mm) would stay the same, but would allow to zoom in more and more as DPI (pixel density) is increased.

Environment

Version of LPub3D - 2.3.12
Operating system - All

Solution

Add pixel ratio input to the export dialogue to enable adjusting the exported DPI up or down for PDF, PNG, JPG and BMP exported content. The default ratio of 1.0 will export content at the rendered DPI. For PDF export, the document size remains constant but the 'device pixel ratio' is modified up or down; thus, the file size is also updated accordingly. For images (PNG, JPG and BMP), changing the pixel ratio results in both an updated file size and and updated image size which reflects the exported pixel DPI.

This capability enables the user to independently manage the rendered and exported DPI producing varying degrees of resolution quality.

PDF export dialogue - the rendered DPI is 150px.
Screenshot - 21_07_2019 , 00_24_57

PDF export completion message
Screenshot - 05_07_2019 , 18_39_37

150 DPI PDF with a pixel ratio of 2.0 exported at 300 DPI
Screenshot - 05_07_2019 , 19_02_39

PNG export dialogue
Screenshot - 21_07_2019 , 00_24_29

150 DPI PNG with pixel ratio of 2.0 exported at 300 DPI. A 150 DPI export is 259 KB for this sample file
Screenshot - 05_07_2019 , 18_28_21

A collateral behaviour of this enhancement is all exported page objects are now merged into a single page image. The reason for this is that in order to manipulate the pixel density of the PDF document, I first create an image object of each page at the specified export DPI and then write that object to the pdfWriter. This is a change from the behaviour before #304 where I directly rendered the scene to the pdfWriter so the scene's objects were individually painted. You can enable this behaviour by checking the "Use Page Image" box shown below. This setting is only shown when exporting a PDF document nd is preserved after the dialogue is closed. Furthermore, this setting is only enabled when the pixel ratio value is 1.0. A pixel ratio not equal to 1.0 will always export a single image for each page; therefore, the Use Page Image checkbox is disabled but checked as you can see in the graphic above.

LPub3D_Pixel_Ratio_Tooltip

Here is a graphic comparing a default exported pdf page with a single page image exported page.

Screenshot - 06_07_2019 , 21_44_35

Cheers,

@trevorsandy
Copy link
Owner Author

Implemented.

Cheers,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
LPub3D Maintenance
  
DEPLOYED
Development

No branches or pull requests

1 participant