Temporary labels for images

Participant ,
Mar 29, 2021 Mar 29, 2021

Copy link to clipboard

Copied

I am working on a layout for a book of photos with about 680 photos which I wanted to be more or less in chronological order for the subject.  The filenames for the photos do not indicate when they were taken.  I tried to organize them in folders for each year, but I now find that I was mistaken about the year of many of the photos.  I want to rearrange them in the layout.  I am looking for an efficient way to see quickly what year a photo belongs in.  I have had two ideas:

1) Rename all the files so that proper year is part of the filename and will be visible in the Links panel.  This would of course require relinking the renamed photos individually, although I wonder if the relinking could be automated with a script using the old and new filenames.  

2) Paste a temporary label on each photo with the proper date.  I'd like to figure out a script to do this automatically if it is possible.

I'd also like to hear any other suggestions for accomplishing my goal.  I created a Filemaker database for all the photos I have.  The 680 I am currently using are just a selection from the 2,600 photos in the database.  I have managed to use Applescript to tie together In Design and Filemaker or the finder, but I am spending more time trying to solve the logistical problems with the photos than I am trying to do the layout.

 

TOPICS
How to, Scripting

Views

205

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 4 Correct Answers

Adobe Community Professional , Mar 31, 2021 Mar 31, 2021
Ah! So you have to fill in the year in that label without a script? To add the labels ( text frames ) on top of every visible graphic, run this ExtendScript code on your document: // Define the name of the object style and the name of the layer of the "labels": var labelObjectStyleName = "LabelStyle"; var labelLayerName = "LabelLayer"; var doc = app.documents[0]; var labelObjectStyle = doc.objectStyles.itemByName( labelObjectStyleName ); var labelLayer = doc.layers.itemByName( labelLayerName )...

Likes

translate

Translate

Translate
Adobe Community Professional , Mar 31, 2021 Mar 31, 2021
You can customize the display in the Links panel to show folder names. Not just the name of the folder an image is in but the name of the folder that folder is in, and so on. If all your photos from 2007 are in one folder you can configure the panel to show Folder 0, then sort by that column by clicking on the column heading. You can use Bridge to view metadata and help organize images by year.

Likes

translate

Translate

Translate
Participant , Mar 31, 2021 Mar 31, 2021
Thank you.  That's very helpful.

Likes

translate

Translate

Translate
Participant , Apr 04, 2021 Apr 04, 2021
Whenever I manage to solve a problem with help from people on a forum like this or with examples and explanations posted in personal websites or blogs, my faith in humanity goes back ut another notch.  The only thing I can do in return is to post the solution that I came up with in the hope that someone else may find some snippet in it useful.I tried to follow both approaches renaming and relinking the files and pasting an easily visible label on each photo showing its year.  In both these I has...

Likes

translate

Translate

Translate
Adobe Community Professional ,
Mar 30, 2021 Mar 30, 2021

Copy link to clipboard

Copied

I like your idea #1. BTW, are all your 680 photos the same size?

Mike Witherell

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 30, 2021 Mar 30, 2021

Copy link to clipboard

Copied

No the photos vary in size.  The original files sizes may be similar in many cases as they are mostly scans of prints, negatives and slides from the last 45 years, but they are individually cropped and resized when I place them in the layout.  I tried renaming about 30 images as a test to see how tedious it was to relink them all.  It is tedious enough to make me think about spending the time re-learning Javascript or trying to find sufficient documentation about using Applescript to change the filename and path in the link info for images that have been renamed.  Any help in this task would be greatly appreciated.

Thanks.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

Hi RGPatt,

so you want to arrange all the images in order of the modification date of the placed image files?

 

I'd do this with InDesign's ExtendScript (JavaScript). You could loop the document's links collection where all placed and linked items are stored. Test if a file for a given link is there, test if the file is an image and finally store its modification date to an array; together with the graphic frame that holds the image in the layout. When done sort the array by the stored date value and move the graphic frame accordingly.

 

However, what's unclear to me and would be very important:

How is your layout?

Can you show some screenshots?

 

Regards,
Uwe Laubender

( ACP )

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

The date I am interested in is not the modification date but the year the photo was originally taken and which I have to guess by looking at the contents of the photo.  They were all scanned and some edited this past year so any metadata associated with the photo is useless for my purposes.

I'd love to see a sample script that uses Extend Script to loop through the links for a document.  I'm having trouble getting startedwith Extend Script although 15 years ago I used to routinely write JavaScript for After Effects.

There is no way the repositioning of the photos could be done automatically.  I layout each page individually with a different number of photos which vary in size.  I'm perfectly willing to re-do the layout manually, but I need to be able to see immediately the year I've assigned to each photo in order to do this efficiently.  That's why I thought about using a second layer with a label for each photo showing the year.  If there is a sample Extend Script that might help me see how to place a text layer on a lable in the center of each photo, I'd love to see it.  

Thanks for you interest and your suggestions.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

Here's some code to get started with links: 

var myDoc = app.activeDocument;
var myLinks = myDoc.links.everyItem().getElements();
var aLink;
for (var i = 0; i < myLinks.length; i++) { 
    aLink = myLinks[i];
}

Here are all the methods and properties available to an individual link: 

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Link.html

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

Thank you.  That's very helpful.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

Ah! So you have to fill in the year in that label without a script?

To add the labels ( text frames ) on top of every visible graphic, run this ExtendScript code on your document:

// Define the name of the object style and the name of the layer of the "labels": 
var labelObjectStyleName = "LabelStyle";
var labelLayerName = "LabelLayer";

var doc = app.documents[0];
var labelObjectStyle = doc.objectStyles.itemByName( labelObjectStyleName );
var labelLayer = doc.layers.itemByName( labelLayerName );

// Add the object style if it does not exist:
if( !labelObjectStyle.isValid )
{
	labelObjectStyle = doc.objectStyles.add({ name : labelObjectStyleName });
};

// Add labelLayer if it does not exist:
if( !labelLayer.isValid )
{
	labelLayer = doc.layers.add( { name : labelLayerName } );
	labelLayer.move( LocationOptions.BEFORE , doc.layers[0] );
};

// Get and loop all graphics in the document:.
// Add a text frame on top of every graphic.

var allGraphics = doc.allGraphics;
var allGraphicsLength = allGraphics.length;

for( var n=0; n<allGraphicsLength; n++ )
{
	// In case graphic is in overset text: do nothing:
	// If not get its geometric bounds:
	try{
	var gB = allGraphics[n].parent.geometricBounds;
	}catch(e){ continue };
	
	// Duplicate the graphic frame of the graphic to get the spread 
	// where the graphic is positioned:
	var tempItem = allGraphics[n].parent.duplicate();
	
	var spread = tempItem.parent;
	spread.textFrames.add
	(
		{
			geometricBounds: gB ,
			itemLayer : labelLayer ,
			appliedObjectStyle : labelObjectStyle
		}
	);
	
	// Remove the dup item:
	tempItem.remove();
	
};

 

After running the script define the new object style.

If you are using auto height and auto width together with an inset you automatically get centered label text frames with a minimum size after you typed in the year the image was taken.

 

Before running the script:

AddTextFrameToEachGraphic-1.PNG

 

After running the script, text frames are added to every graphic on a new layer, a new object style is added and applied to every text frame:

AddTextFrameToEachGraphic-2.PNG

 

Let's define the object style: fill color set to yellow, transparency set to the fill, paragraph style added, text is now centered in the text frame and auto height and auto width are enabled together with a inset value for the text frame:

AddTextFrameToEachGraphic-3.PNG

 

In the moment you type to a text frame auto height and auto width kick in and center the frame to the graphic:

AddTextFrameToEachGraphic-4.PNG

 

Definition of the object style's auto height and auto width:

AddTextFrameToEachGraphic-5.PNG

 

A slightly different approach would be to add the text frame inside the frame holding the graphic so that yet another script could easily do the renaming of the graphic's file name based on the contents you are writing to the text frame. Later when done the object style of the text frames could be changed to non-printing for example. The following screenshot is showing this with Operprint Preview enabled:

AddTextFrameToEachGraphic-6.PNG

 

Regards,
Uwe Laubender

( ACP )

 

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

Here some screenshots with a different variant of my script, code not posted here, where I added a text frame to every graphic's graphic frame that is not in overset text or that has no text frame yet.

 

After running that other script. Text frame inside every graphic frame added:

 

AddTextFrameToEachGraphic-v2-2.PNG

 

After changing some properties of the new object style that is applied to the text frames and typing in one frame:

AddTextFrameToEachGraphic-v2-3.PNG

 

Because the contents of the text frames is tied directly with the graphic frames that are holding the images, another script could easily read out the contents and would be able to rename the graphics accordingly.

 

Regards,
Uwe Laubender

( ACP )

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

Thank you so much for all of this.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

You can customize the display in the Links panel to show folder names. Not just the name of the folder an image is in but the name of the folder that folder is in, and so on. If all your photos from 2007 are in one folder you can configure the panel to show Folder 0, then sort by that column by clicking on the column heading.

Screenshot 2021-03-31 at 12.24.22 PM.png

You can use Bridge to view metadata and help organize images by year.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

Thanks.  I hadn't noticed that possibility and it may prove very helpful.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 04, 2021 Apr 04, 2021

Copy link to clipboard

Copied

Whenever I manage to solve a problem with help from people on a forum like this or with examples and explanations posted in personal websites or blogs, my faith in humanity goes back ut another notch.  The only thing I can do in return is to post the solution that I came up with in the hope that someone else may find some snippet in it useful.

I tried to follow both approaches renaming and relinking the files and pasting an easily visible label on each photo showing its year.  In both these I has helped by the fact that I had originally tried to separate all the photos into folders named for the year I thought it was taken.

I gave up trying to use JavaScript in Visual Studio Code because I could never set it up properly to work for debugging and just went with Applescript which I had already used to link together images in the InDesign document and the corresponding image in a database of all my images.  

If I decided I had the wrong year for an image and moved it to a different folder this obviously broke the link in InDesign.  The only solution I could figure out for this was to add a field to the database which stored the old name of the file so that I could trigger a search for it from the link information in InDesign and then find the new name and path to use for relinking it.  I am attaching the _RelinkerFull.scpt that managed to relink about 30 missing files, before I decided to stop renaming them in favor of just labeling them.  One problem I had with the script is that Applescript's do script command for Filemaker does not seem to be smart enough to wait until the sub-script has finished and I finally found advice to put a delay in the script.  I could probably have avoided this is I had just done the search with Applescripts own ability to tell Filemaker to search, but I already had a Filemaker script to do the search.

Applying the labels to each image was done with the attached _YearLabelAll.scpt which goes through the links for all the images, finds the year as the name of the folder in which the image is stored and adds a textbox with the year centered over the frame of the cropped image on the page.  Sometimes the seemingly basic or trivial things pose the biggest problems for me and in this case it was specifying the color for the font in the textbox. I had to create a swatch in InDesign in order to do this, but I am sure it must be possible some other way.  I tried to also group the textbox and the image, but then realized that this prevented me from keeping the image visible when I made the layer for the text box invisible.  This script also failed on images that were on the pasteboard rather than on a page, but I only had four of those and I was able to move them to a temporary page and use _YearLabelSelected.scpt to put a lable on just the selected images.

I am sure my scripts are not the most robust or elegant scripts possible for this task, but they worked and I felt I should share them for whatever they may be worth. 

I now have discovered that I cannot attach .scpt files to this post so I am attaching a single text file containing all three scripts.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines