Applescripts for generating sets of image links for Markdown files

This GitHub repository contains another two Applescripts,

  • “Generate image set (Markdown).applescript” and
  • “Generate image set (HTML).applescript”,

that are part of my image workflow for Markdown files. For the currently selected images, they generate a set of image links arranged in a desired grid size. The links are saved to the clipboard and can be easily pasted into the desired Markdown file. Available grid options are:

grid 1 (100% width): Arranges one image per row with an image width of 100%.

grid 2 (50% width): Arranges two images per row with an image width of 49%.

grid 3 (33% width): Arranges three images per row with an image width of 32%.

enter individual width: Arranges as many images per row, as the custom entered image width allows, i.e., 100//entered value ("//" = integer division). E.g., a width of 24% allows four images per row, a width of 19% five images per row, and so forth.

"+ caption" options: The “+ caption” option extracts the image annotations from the images’ Finder comments and adds them (if available) as captions under each image. In the HTML version, this option is only available for image widths ≥25%.

The image links contain an additional link to the corresponding image file. This enables the opening of the images in a new tab in DEVONthink and the full-size view of the images in DEVONthink To Go.

The Markdown version of the script generates Markdown image links, e.g., as follows:



**Left**: Enso 0 – **Middle**: Enso 1 – **Right**: Enso 2

[img058627]: x-devonthink-item://80581B4F-2509-4ADE-9720-B0C77A5B758A style="width:32%;"
[img058628]: x-devonthink-item://440D0398-C1F1-4F7A-BD6B-1EA212294404 style="width:32%;"
[img058629]: x-devonthink-item://4C074346-878B-463C-A000-3CC824420BB3 style="width:32%;"

Left: Enso 0 – Middle: Enso 1 – Right: Enso 2

I think, the Markdown version makes the most sense when it is used in combination with the Image auto-rename and annotate script (please find it in the same repository). Otherwise the image reference links could become too long and the unambiguity of the references is not ensured.

The HTML version of the script generates HTML image links, e.g., as follows:

<div style='text-align: center;'>
<a href='x-devonthink-item://80581B4F-2509-4ADE-9720-B0C77A5B758A'><img src='x-devonthink-item://80581B4F-2509-4ADE-9720-B0C77A5B758A' style='width: 32%;'></a>
<a href='x-devonthink-item://440D0398-C1F1-4F7A-BD6B-1EA212294404'><img src='x-devonthink-item://440D0398-C1F1-4F7A-BD6B-1EA212294404' style='width: 32%;'></a>
<a href='x-devonthink-item://4C074346-878B-463C-A000-3CC824420BB3'><img src='x-devonthink-item://4C074346-878B-463C-A000-3CC824420BB3' style='width: 32%;'></a>

**Left**: Enso 0 – **Middle**: Enso 1 – **Right**: Enso 2
1 Like

I have absolutely no need for this. I don’t think. It looks so useful that I want to need it. Badly. Thank you for sharing your knowledge and work with all of use here!

1 Like

thanks Blanc! :rofl: I mostly use this script to add image galleries (some kind of) in my Markdown files.

1 Like