0

How I can get pixel of image in gjs/gnome-extensions? I tried Image() but it undefined in system.

Renattele Renattele
  • 1,626
  • 2
  • 15
  • 32

1 Answers1

1

You should use GdkPixbuf.Pixbuf for this. The get_pixels() method will return a Uint8Array with the image data, and you can index an individual pixel with pixels[y * pixbuf.rowstride + x * pixbuf.nChannels].

(Image is part of the HTML DOM. GNOME extensions don't run in a browser environment, so there's no DOM, just the same as in Node.js.)

ptomato
  • 56,175
  • 13
  • 112
  • 165