Skip to content

Proportional dimensions (page size, font), dealing with scanned images #415

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

Closed
eloops opened this issue Aug 24, 2015 · 0 comments
Closed

Comments

@eloops
Copy link

eloops commented Aug 24, 2015

This isn't so much an issue as a comment, feel free to close it.

Similar to this issue, what I was trying to do was:

  • determine the page size (in point) from the dimensions of a scanned image
  • set everything proportionate to the page size

Unfortunately my scanned images are all done at 300dpi. This means when proportionally sizing the page, it gets up over 10000 points in size.

Proportional fonts get scaled up to over 1500 points in size (at which point they won't display). Inserted images will stretch no matter what.

In PDF land, 72 points (per inch ...) is the standard when looking at things like page sizes. For example, an A4 portrait page is 595x842 points (see: here). So, instead of increasing the size of everything, I decreased it in proportion to the difference between the given dpi of the scanned image and 72.

In practice this looks like:

var dpi = 300

var px2pt = function(pxl) {
    return parseFloat(pxl * (72 / dpi))
}

So when translating given (pixel) dimensions, you just pass it through the function.

Sorry if this is really obvious, it took me a while to get my head around it.

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

1 participant