Jimp: Getting image width/height

Created on 29 Aug 2017  路  1Comment  路  Source: oliver-moran/jimp

Hey guys,

Perhaps I skipped over this in the docs, but is there a way to capture the image's width and height? I'm trying to center text in the image and need the overall dimensions to calculate the positioning.

Most helpful comment

I found for myself this way: image.bitmap.height
So f.e.:

Jimp.read(imagePath).then((image) => {
    image
    image.print(font, 10, 10, imageFirstWord, image.bitmap.height)
               .resize(Jimp.AUTO, 1920)
               .write(imagePath)
  }).catch((err) => {
    console.error(err)
  })

>All comments

I found for myself this way: image.bitmap.height
So f.e.:

Jimp.read(imagePath).then((image) => {
    image
    image.print(font, 10, 10, imageFirstWord, image.bitmap.height)
               .resize(Jimp.AUTO, 1920)
               .write(imagePath)
  }).catch((err) => {
    console.error(err)
  })
Was this page helpful?
0 / 5 - 0 ratings

Related issues

chancein007 picture chancein007  路  5Comments

Jimbly picture Jimbly  路  5Comments

dtrofimov picture dtrofimov  路  5Comments

Yimiprod picture Yimiprod  路  5Comments

PainKKKiller picture PainKKKiller  路  5Comments