Read width/height of an attachment

I’m trying to read what are the width/height of a given image. The following JS code works fine outside Airtable:

const img = new Image();
img.onload = function() {
  alert(this.width + 'x' + this.height);
img.src = '';

But when writing an Airtable script, const img = new Image(); yields ReferenceError: Image is not defined.

Is there another way to know what are the width/height of an image within an Airtable script?