Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant