Action extension with photos

I would like to share a photo from the Photos app and do some processing with it in Scriptable.

I’m reading the photo with args.images but I cannot see the photo with QuickLook.present() because it is of type JSValue.

Am I correctly reading the image? I can only get to see the size but not display the image.

How should I visualise the image or how should I change the data type?

See if this helps.

//Get the images passed in - there could be more than one
let arrImgs = args.images;
//Resort to using a for loop for this example rather than forEach due to asynchronicity
let intCount;
for (intCount = 0; intCount < arrImgs.length; intCount++) { 
  await QuickLook.present(arrImgs[intCount]);
};

It assumes you are setting the script as a share sheet destination for imags in Scriptable.

This should then give you something like this to step through each image on selection of ‘Done’.

Hope that helps.

3 Likes

Thanks! It helped. Stupid me, I wasn’t accessing the image with the brackets.

Also, how could I extract RGB values of each of the pixels?

Scriptable doesn’t provide an easy way to do that. However, you can get the JPEG or PNG data of an image. I would imagine that you can deduce the RGB values from that.

2 Likes

That’s a pity… Thank you anyway!

I was willing to write a script that would give me the color palette of an image, but I guess it won’t be possible for the moment.

I’ll play with the raw data and see if I can get it to work.