About the picture pixel count

54 views
Skip to first unread message

Fatih Elitas

unread,
Mar 2, 2026, 2:17:10 PMMar 2
to DroidScript
Hello;
How can I find out the total number of pixels horizontally and vertically in an image file?

Alan Hendry

unread,
Mar 3, 2026, 3:35:52 PMMar 3
to DroidScript
HI,
If it's a jpg photo you could look at 
using an npm module to read the exif info
(was fairly slow when I tried it).
Or load into an Image and get the height and width.
(Is it native or hybrid?)
Regards, ah

Cemal

unread,
Mar 4, 2026, 1:44:01 PMMar 4
to DroidScript
Hello,

I haven't tested it, but this function might be useful for you: img.GetPixelData

This function returns a base64 string. You may need to use atob to decode it.

Dave's comment on an old post:
“rawbase64” or “pngbase64”,  “jpgbase64”, "json"

rawbase64 can also be combined with the 'grayscale' option which is faster and results in a smaller image (useful for image processing)

Alan Hendry

unread,
Mar 4, 2026, 4:00:59 PMMar 4
to DroidScript
HI,
This should get width and height in pixels
Regards, ah

function OnStart() {
lay = app.CreateLayout( "Linear", "VCenter,FillXY" )
img = app.AddImage( lay,"/Sys/Img/AScript.png" )
txt = app.AddText(lay,"height="+img.GetAbsHeight())
txt.SetTextSize( 32 )
txt2 = app.AddText(lay,"width="+img.GetAbsWidth())
txt2.SetTextSize( 32 )
app.AddLayout( lay )
}
Reply all
Reply to author
Forward
0 new messages