Place Image in OmniGraffle

Here is a useful Shortcut workflow for the Share menu that imports the selected image or image file into the current OmniGraffle document.

Available by tapping the Shortcuts Share menu item  1  in the Photos app, Files app, or any app supporting photos, when an image or image file is selected, and then the “Place Image in OmniGraffle” shortcut  2  in the list of available shortcuts. (see below)

share-sheet

The workflow will scale the image copy to the percentage value you choose, and then place the scaled version in either the currently selected graphic solid or a newly created gra[hic that is sized-to-fit the scaled image.

The Place Image Script

The Omni Automation script performs the following two functions:

A percent-encoded version of the script containing a text placeholder for the image data is inserted into the shortcut workflow as the contents of Text action.

try { imageData = Data.fromBase64('XXXXX') sel = document.windows[0].selection cnvs = sel.canvas if (sel.solids.length === 1){ sel.solids[0].image = addImage(imageData) } else { solid = cnvs.newShape() solid.strokeThickness = 0 solid.shadowColor = null solid.fillColor = null solid.image = addImage(imageData) newGeometry = solid.geometry newGeometry.size = solid.image.originalSize solid.geometry = newGeometry } } catch (err){ new Alert(err.name,err.message).show(function(result){}) }
omnigraffle://localhost/omnijs-run?script=try%20%7B%0A%09imageData%20%3D%20Data%2EfromBase64%28%27XXXXX%27%29%0A%09sel%20%3D%20document%2Ewindows%5B0%5D%2Eselection%0A%09cnvs%20%3D%20sel%2Ecanvas%0A%09if%20%28sel%2Esolids%2Elength%20%3D%3D%3D%201%29%7B%0A%09%09sel%2Esolids%5B0%5D%2Eimage%20%3D%20addImage%28imageData%29%0A%09%7D%20else%20%7B%0A%09%09solid%20%3D%20cnvs%2EnewShape%28%29%0A%09%09solid%2EstrokeThickness%20%3D%200%0A%09%09solid%2EshadowColor%20%3D%20null%0A%09%09solid%2EfillColor%20%3D%20null%0A%09%09solid%2Eimage%20%3D%20addImage%28imageData%29%0A%09%09newGeometry%20%3D%20solid%2Egeometry%0A%09%09newGeometry%2Esize%20%3D%20solid%2Eimage%2EoriginalSize%0A%09%09solid%2Egeometry%20%3D%20newGeometry%0A%09%7D%0A%7D%20catch%20%28err%29%7B%0A%09new%20Alert%28err%2Ename%2Cerr%2Emessage%29%2Eshow%28function%28result%29%7B%7D%29%0A%7D

 02  During the execution of the shortcut, the text placeholder “XXXXX” is replaced with the image data in base64 encoded format. This statement uses the fromBase64() of the Data class to convert the encoded data into image data stored in the variable imageData.

 05-16  If a single solid shape is currently selected, the image is placed in the selected shape  06  , otherwise a new shape containing the image is created and sized to fit the image  08-15 

The Shortcut Workflow

The following image capture shows the Shortcut workflow that is triggered fro the Share sheet.

You can INSTALL the shortcut workflow file.

Screenshot
UNDER CONSTRUCTION

This webpage is in the process of being developed. Any content may change and may not be accurate or complete at this time.

DISCLAIMER