This is not a JavaScript solution. However, this following AppleScript code, will download all of the images from the image URLs you define in line 1 of the code. Next, it will write to a file, the image name and its dimensions. The end of the code provides a command to delete the downloaded images and will reveal the text file, in Finder, containing the image names and their dimensions.
The folder and file paths are not hardcoded, so all you need to do is enter the image URLs to the variable in the first line of this AppleScript.
This AppleScript code works for me using the latest version of macOS Mojave.
set imageURL to {"https://i.ebayimg.com/images/g/M58AAMXQaBtRAPkA/s-l500.jpg", "https://i.imgur.com/gQQHPBn.png"} -- Can Enter Multiples
-- Downloads The Images (Defined Above) To The Folder (Defined Below)
set downloadedImagesFolder to ((path to downloads folder as text) & "Images For Dimensions") as text
set quotedFormOfDownloadedImagesFolder to quoted form of POSIX path of downloadedImagesFolder
-- Writes Name Of Image And It's Dimensions To The File (Defined Below)
set imageDimensionsFile to ((path to downloads folder as text) & "File_Dimensions.txt") as text
set quotedFormOfImageDimensionsFile to quoted form of POSIX path of imageDimensionsFile
tell application "Finder"
if not (exists of folder downloadedImagesFolder) then
make new folder at (path to downloads folder) ¬
with properties {name:"Images For Dimensions"}
end if
end tell
repeat with i in imageURL
set imageURLText to i
set text item delimiters to "https" -- shell script "lwp-download " errors with "https"
set tempURL to text items of imageURLText
set text item delimiters to "http" -- replaces "https" with "http"
set finalImgeURL to tempURL as text
set text item delimiters to ""
try
do shell script "lwp-download " & quoted form of finalImgeURL & " " & quotedFormOfDownloadedImagesFolder
end try
end repeat
tell application "Finder"
set imageFiles to files of folder downloadedImagesFolder as alias list
set quotedFormOfImageFiles to {}
repeat with i in imageFiles
set end of quotedFormOfImageFiles to quoted form of POSIX path of i
end repeat
end tell
repeat with thisItem in quotedFormOfImageFiles
delay 2 -- May Need To Increase Value If Returning Null Value Results
-- replace " >> " with " > " Below... If You Prefer To Overwrite The File Instead Of Append
do shell script "mdls -name kMDItemFSName -name kMDItemPixelHeight -name kMDItemPixelWidth " & thisItem & " >> " & quotedFormOfImageDimensionsFile
end repeat
tell application "Finder" to reveal imageDimensionsFile
(* Comment Out Or Remove The Following Line If You Don't Want To
Delete The Downloaded Images *)
tell application "Finder" to delete folder downloadedImagesFolder