image-processinggnome-shell-extensionsgjs

How to analyze image in gjs/gnome-extensions?


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


Solution

  • 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.)