Is there a way to search my TBx file for images in order to replace them with links. I have not been able to find how to build tha query that will find all notes containing one or more images. I think it should be along the lines of: $Text.contains(matchStr) where the string contains characters unique to images. Perhaps a regex is needed?
I’ve searched the Forum and the rich aTbRef without success to find how inline images are stored in a note.
I have not used images extensively but recent discussions in the Forum and email correspondence suggest the speed of the file could be boosted by removing images.
For context, I consider my file a modest one at 473 MB with 11 children, 2045 descendents, and 147,146 words with descendants.
Sample file attached with one note and one image. As I was not sensitive to storage space issues, the image in the test has not been processed in any way to reduce its size. That is also true with the images in my work file.
I’d be interested in what you’re working on. For my work, I’ve found hosting the image on my hardriving and “pulling” the image through preview/export is the most optimal approach.
Thanks for your note, Michael. I had looked at your video in 2021 but confess to having overlooked when researching for this exercise. Have rewatched Part 1 and tried to implement. The video is packed with great information. TextExpander will be a big help, especially when the $MediaFile value in included.
I use this tag: <img src=“File:////Users/doug_user/Library/CloudStorage/Dropbox/Tinderbox/CatchAllNotesImages/Medicare_DJ.png"> in a note. The folder with images is in the folder that contains the TBX file. However, when I click “Preview” I get only the line or two of unrelated text in the note and not the image. In the Preview, the tag is not visible, just open space. I tried both jpg and png versions of the image with same result.
When I try linking to an image on my local HD, the tag works. Is the location on Dropbox in the Cloud the issue? When I use the path beginning with “File:” in $URL and click the globe, it opens the image immediately in Preview.app.
I’m totally ignorant on HTML so am wondering if there are some elements there that would help TBX make the connection.
Hoping there is an easy answer but will adjust if needed.
Not, this is a VERY old video…text expander is fine to use especially when you’re working with long form documents, but so is the use of templates and ^include("note-name","tMedia template")^ is also my recommended approach. I don’t think Part 1 or Part 2 talk about the include approach.
Project completed. Query: $ImageCount>0 now has zero returns.
The method moved images to a parellel folder and used the URL attribute to call Preview or another app to open it.
The method used is clearly not the only way to work but it is low tech and met my needs.
For anyone interested in the process, here’s what worked for me:
Created folder to hold images. Folder name is same as TBX file, in same folder, with “Images” added to filename.
Created Agent: query $ImageCount>0.
When results appear, selected all results and used Export Selected Note(s). Saved in convenient location. I used a separate folder <TBX_filename>ImagesTemporary. In that folder are found two files for each note with an image: an HTML file and a JPG file. Ignore the HTML files. Each file is named with the first characters of the $Name of the originating note.
For each JPG file:
a. Drag it from the Temporary folder to the Images folder.
b. Verify it is a legal JPG file. Sometimes, images pasted into TBX were PDF or HTML. The Export process forced them into a non-standard, dysfunctional JPG format.
c. Those that could not be opened as JPGs were opened in Photoshop to analyze the issues and save as clean files. In this procedure, files can be of any type openable by the computer, e.g. JPG, PNG, PDF, HTML.
d. Copy the file with its path (Cmd+Opt+click).
e. In the master TBX file, working either with the alias or the original note with the Name, add a DisplayedAttribute “URL” with attribute type “URL” (or if needed URL2, URL3, etc.).
f. Enter the string “File://” into the URL attribute. Then paste to append the copied path.
g. When done, clicking on the globe icon will cause a JPG or PNG image to be displayed in Preview.app. (Assuming Finder has been set to open JPGs in Preview.) PDFs and HTML files will be opened in their appropriate applications.
h. Above or below the image, add a notation to the effect, “See URL(n) for illustration.”
i. Delete the image from the note. Occasionally, finding the image file in the original note may be challenging. Worst case, the content of the note may require placement in a new clean note.
j. When the agent runs again and no image is found, the selected note vanishes from the agent’s list of aliases.
When all JPG files have been processed, only HTML files will remain in the Temporary folder. The Temporary folder and its contents can be deleted.
Size of the TBX file was reduced from 473 MB noted at the outset to 6.3 MB through this exercise, a reduction of 466.7 MB. The 64 saved images, mostly JPG and PNG, occupy 92.8 MB. About a dozen images were deleted as obsolete - a trivial portion of the volume. So total space required for the TBX file and image files is 99.1 MB, a 79% reduction.
If all JPG images had been converted to PNGs, the space required for images would be even less.
This gives dimension to Mark B’s comment that an image placed in a TBX file takes way more space than expected.