Extract Alpha from Image [JS1]
iOS 15: Works (iOS 15.2 beta 1)
The shortcut extracts silently the masks from any images received as input, giving them the same name/s. These masks can be directly used with the "Mask Image" action in Shortcuts.
When run without input, the shortcut works as a demo, allowing the user to select one or more files and showing the result of the conversion.
- No error checking
Alpha (alpha channel)documentation at MDN
globalCompositeOperationdocumentation at MDN
Don't download the shortcut
If you just want the code, there's no need to download the shortcut. Copy this and paste it in a "URL" action:
REPLACETHISWITHBASE64IMAGE fragment with the base64-encoded image, add a "Get File of Type" with type
com.apple.webarchive below, and decode the base64 output to get the mask.
I use "Get File of Type" instead of "Get Contents of Webpage" to avoid that the user is misleading told that the shortcut uses Safari.
Latest Release Notes
1.0.0 - Nov. 8, 2021, 9:07 p.m.
First public version