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

want to have Resolution Unit #847

Open
tictaqqn opened this issue Oct 18, 2022 · 0 comments
Open

want to have Resolution Unit #847

tictaqqn opened this issue Oct 18, 2022 · 0 comments

Comments

@tictaqqn
Copy link

tictaqqn commented Oct 18, 2022

Hi
Imagemagick returns resolution with both unit PixcelsPerInch and PixcelsPerCentimeter and gm.res returns different unit of values, so I want this gm library to return Resolution Unit, too.

ex)

$ identify -verbose resolution.png | grep 'Resolution\|Units'
  Resolution: 118.11x118.11
  Units: PixelsPerCentimeter
$ identify -verbose resolution.jpg | grep 'Resolution\|Units'
  Resolution: 300x300
  Units: PixelsPerInch

and in gm

const GM = gm.subClass({ imageMagick: true })
export function getResolution(buf: Buffer): Promise<string | undefined> {
  return new Promise((resolve, reject) => {
    GM(buf).res((err, value: string | undefined) => {
      if (err) {
        reject(err)
        return
      }
      resolve(value)
    })
  })
}
const buf = await fs.promises.readFile('test/assets/resolution.png')
const res = await getResolution(buf) // = '118.11x118,11' in PixelsPerCentimeter
////
const buf = await fs.promises.readFile('test/assets/resolution.jpg')
const res = await getResolution(buf) // '300x300' in PixelsPerInch
@tictaqqn tictaqqn changed the title want it to return Resolution Unit want to have Resolution Unit Oct 18, 2022
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