Create note with 2 local images

The following script uses 2 images from a website, puts their URL into HTML and then creates a Notes file showing the two images. All working fine.

The same 2 images are also saved to my Mac and I want to create the exact same Notes file in the same way but using the saved images instead of the website URL.

This is part of a bigger problem that I am stuck with but can someone please help me with the format of the second example of LstImageURL to get it working.


-- ** Website picked at random for example purposes **

set LstImages to {}

-- Working
set LstImageURL to {"", ""}

-- Not Working
--set LstImageURL to {"Macintosh HD:Users:Myname:Images:howdenMinsterBells.jpg", "Macintosh HD:Users:Myname:Images:whitechapel-handbells.jpg"}

repeat with i from 1 to length of LstImageURL
	set ImageURL to "<img src=\"" & item i of LstImageURL & "\"<p><p>"
	copy ImageURL to the end of LstImages
end repeat

set ReportImages to items of LstImages

tell application "Notes"
	set the noteBody to "<html>
<p><span style=\"color:#FF0000\">Pictures: </span>
<p>" & ReportImages & "
<p><span style=\"color:#FF0000\">End of Pictures: </span>
	set thisAccountName to "My name" -- For testing (images appear immediately in the note)
	--set thisAccountName to "Icloud" -- (Sometimes a delay for the images to appear) 
	-- make a new note at the top application-level:
	make new note at folder "Notes" of account thisAccountName with properties {body:noteBody}
end tell


I’m assuming that the image URLs must be unix URL, not Mac HFS Paths

set LstImageURL to {"file:///Users/Myname/Images/howdenMinsterBells.jpg", "file:///Users/Myname/Images/whitechapel-handbells.jpg"}

Sorry but no joy with that. I just get the text only:


End of Pictures:

I don’t fully understand that but the files are saved on my Mac here…

Macintosh HD:Users:Myname:Images:howdenMinsterBells.jpg
(or /Users/Myname/Images/howdenMinsterBells.jpg)



First you need to know what is HTML image tag <img src=
You could get it here:

You like to use a string that is okey… but your example do not use URI schema
Here is some examples:

To access a file local on the computer you use URI Schema file://
You could find that info here:

What you are doing is using alias that you have converted to string. That is not a URI string
or same thing.

The way I do it I make absoluteString from NSURL class in ASObjC.

use framework "Foundation"
use scripting additions

set thePath to POSIX path of (path to home folder)
set theURL to (current application's |NSURL|'s fileURLWithPath:thePath)'s absoluteString() as string

Or if you do not like to use that you could do.

set thePath to POSIX path of (path to home folder)
set URISchema to "file://"
set theURL to URISchema & thePath

And if you like to get deep you could read this:

Fredrik71 - Thanks for your work on this but regrettably, I am no further forward here. I don’t really understand much of the information at the links but the 2 Scriptlets you supplied seem to just produce the same format that robertfern suggested

That just gives me the text only (no images):

I’m afraid that I am still stumped!

It is just a way the works.

To add the local image file’s content, @Fredrik71 and me already shown to you how to embed the picture into the note, using Base64 picture encoding, or using make new attachment command.

It was here: HTML Image to Notes 1,5 month ago.

When you have a image in the Notes you could do:

tell application "Notes"
	tell folder <YOUR_FOLDER_NAME> to tell note <YOUR_NOTE_NAME>
		its properties
	end tell
end tell

From the body property you could see how the core data is build and it use base64 encoding.
Same data is synced with iCloud so you are able to read it on other device. It wouldn’t be possible to read data from mobile device if the property used file:// or URL to local computer.

So any image in Notes are encoded and stored in iCloud as Base64 encoding.

It was wrong for me to suggest you could use file:// schema when I forgot you used Notes.