In Pages, there is a difference in the default behavior between creating a new image and replacing an existing placeholder image.
CREATE IMAGE: When a script creates a new image, the image container is automatically wrapped to fit the image, regardless of any sizing indicated during the execution of the make command.
REPLACE IMAGE: When a script replaces a placeholder image with an image file, the imported image is scaled and centered so that its shortest side fits within the placeholder view.
The example script on this page demonstrates image placeholder replacement by importing photos from a chosen iPhoto album into a tabloid-sized template containing rows of square image placeholders. (⬇ see below )
Populate Thumbnail Template
DO THIS ►Before opening and running this script, DOWNLOAD and install the “Thumbnail Poster” template.
Here’s the script:
Populate Thumbnail Grid Template
01
propertythisTemplateName : "Thumbnail Poster"
02
03
tellapplication "Pages"
04
activate
05
try
06
-- check for the required template
07
set thetemplateNamesto thenameof everytemplate
08
ifthisTemplateNameis not in thetemplateNamesthen errornumber 1000
09
10
-- prompt user to pick the source album
11
setalbumNamesto myiPhotoalbumNames()
12
ifalbumNamesisfalsethen errornumber 1001
13
setchosenAlbumto ¬
14
(choose from listalbumNameswith prompt ¬
15
"Pick the album containing images to import:")
16
ifchosenAlbumisfalsethen errornumber -128
17
18
-- get a list of file paths to the album images
19
tellapplication "iPhoto"
20
-- using previews reduces time required for script to complete
21
-- use the "image path" property for higher resolution
TIP: This template can be populated because the description for each placeholder image contains a number indicating its position in the order of placeholders on the page.
For a complete overview of performing standard image editing tasks, such as scale, pad, rotate, and crop, using AppleScript, visit this webpage on this site.
DISCLAIMER
THIS WEBSITE IS NOT HOSTED BY APPLE INC.
Mention of third-party websites and products is for informational purposes only and constitutes neither an endorsement nor a recommendation. MACOSXAUTOMATION.COM assumes no responsibility with regard to the selection, performance or use of information or products found at third-party websites. MACOSXAUTOMATION.COM provides this only as a convenience to our users. MACOSXAUTOMATION.COM has not tested the information found on these sites and makes no representations regarding its accuracy or reliability. There are risks inherent in the use of any information or products found on the Internet, and MACOSXAUTOMATION.COM assumes no responsibility in this regard. Please understand that a third-party site is independent from MACOSXAUTOMATION.COM and that MACOSXAUTOMATION.COM has no control over the content on that website. Please contact the vendor for additional information.