Accessing pixel data from an Image loaded in the browser

Hi all, I'm trying to access the pixel data of an Image that I'm uploading on the client-side using the drop() method.

Using createImg() creates a p5.dom img object, as opposed to a p5.image, so I attempted to use loadImage(file.data) where file.data is the src as opposed to a string pointing to a local file. This returns a p5.image object, however the pixels[] array returns as pixels: Uint8ClampedArray[4] instead of 'pixels:Array[0]' when the same image is loaded in setup using var img = loadImage("test.jpg");, though my assumption is that there's no real difference between the two as it's just returning information about the buffer being used.

The interesting thing is that console logging the width and height of the image loaded in setup reads 1920 x 1080, whereas the width and height of the image loaded using drop() reads as 1 x 1, despite showing up in the debugger as having the same properties..

Screen Shot 2016-03-29 at 12.39.41 PM

Any thoughts?

Answers

Sign In or Register to comment.