×

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.

Place Image in OmniGraffle


try { var imageData = Data.fromBase64('XXXXX') var sel = document.windows[0].selection var cnvs = sel.canvas if (sel.solids.length === 1){ sel.solids[0].image = addImage(imageData) } else { var solid = cnvs.newShape() solid.strokeThickness = 0 solid.shadowColor = null solid.fillColor = null solid.image = addImage(imageData) var newGeometry = solid.geometry newGeometry.size = solid.image.originalSize solid.geometry = newGeometry } } catch(err){ new Alert(err.name,err.message).show() }

 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