I’m attempting to make a script that will find the resolution of an image loaded by the user. The problem that I’m having is that once I’ve loaded the image I can’t really get anything from it except throw it into a QuickLook. When I look up how to get image height or width I get results that tell me to do things like this:
var realWidth = myImg.naturalWidth;
var realHeight = myImg.naturalHeight;
This does not work for me, I assume, because I’m not in a browser, or because of the way I brought the image in.
// This will find the aspect ratio of an
// image that the user chooses
let imagepath = await DocumentPicker.open(["public.image"]);
let imagePath = imagepath[0];
let localFM = FileManager.local();
let imageData = localFM.readImage(imagePath);
I’m brand new to JavaScript (just decided to try it out after listening to the Automators episode). If anyone could help me out with getting to the point where I can query the loaded image for its height or width I would appreciate it.
P.S. My prior scripting experience is almost exclusively in Python