Return to table of contents

AppleScript Scripting

Release 2.5.3 has full AppleScript scripting support in WebPics. The following is currently supported:

Adding Pictures

Use the 'add pictures' event to add a picture to the list.

	add picture file "MacOS X:Users:splons:Pictures:PC281379.JPG" as alias

Starting the Build Process

A specific event has been added to start the web page building process. Here is the dictionary entry for the 'buildpages' event:

	build pages  reference  -- document to build pages for
			[into  alias]  -- folder to build web pages in

If you do not use the optional 'into' part build pages will attempt to use the folder used to build the document previously. If there is no previous folder an error is returned.

Sample Script

Here is a sample script that demonstrates adding pictures, setting properties (options) and then building the web pages. Copy and paste this text into Script Editor to try it out. You will need to edit the file paths to be appropriate for your Macintosh.

-- Sample script for WebPics 2.5.3 
-- this script exercises all of the available scripting events and properties

property backcolor : {50000, 60000, 60000}
property titleColor : {20000, 30000, 0}

tell application "WebPics"
	-- get the front document
	set doc to the front document
	tell doc
		-- remove all pictures from the list
		repeat until picture count = 0
			remove picture at index 1
		end repeat

		-- add some pictures to the list
		add picture file "MacOS X:Users:splons:Pictures:PC281379.JPG" as alias with caption "first picture in list"
		add picture file "MacOS X:Users:splons:Pictures:PC281387.JPG" as alias before 1 with caption "new first picture"
		add picture file "MacOS X:Users:splons:Pictures:PB071279.JPG" as alias
		-- manipulate the pictures as needed
		rotate picture at index 1 by 90
		rotate picture at index 2 by 270
		dont use picture named "PB071279.JPG"
		use picture named "PB071279.JPG"
		remove picture at index 3
		-- setup the Text tab fields
		set page title to "page title for this sample"
		set page title font to "Palatino"
		set page title color to titleColor
		set page title size to 6
		set page title bold to false
		set page title italic to false
		set top description to "«<a href=\"http://www.splons.com/m3/webpics\">an embedded link</a>»"
		set bottom description to "text for the bottom description"
		set description font to "Serif"
		set description color to {50000, 30000, 0}
		set description size to 6
		set description bold to true
		set description italic to true
		set previous link text to "prev pict link text"
		set next link text to "next pict link text"
		set return link text to "return link text"
		set close link text to "close link text"
		set previous page text to "prev page link text"
		set next page text to "next page link text"
		set display links at to topandbottom --topofpage/bottomofpage/topandbottom
		set copyright text to "Copyright  2002 Joe Photo"
		-- setup the Graphics tab fields
		set background color to backcolor
		set use background image to false
		set background image to "MacOS X:Users:splons:Pictures:back.JPG" as alias
		set dont scroll background to false
		set use custom link colors to true
		set link color to {0, 0, 0}
		set active link color to {0, 40000, 0}
		set visited link color to {40000, 0, 0}
		set rollover link color to {60000, 60000, 0}
		-- setup the Thumbnails tab fields
		set thumbs per row to 3
		set thumbs per page to 0
		set thumb spacing to 33
		set caption position to leftofthumb --leftofthumb/rightofthumb/abovethumb/belowthumb/nocaptions
		set caption font to "Palatino"
		set caption size to 5
		set caption color to {60000, 60000, 0}
		set caption bold to true
		set caption italic to true
		set thumbnail size to xlarge --tiny/smaller/small/medium/large/xlarge
		set thumb border width to 3
		set thumb border bevel to 5
		set thumb border color to {30000, 60000, 40000}
		set show link borders to true
		set show file names to true
		set show image size to true
		set show image creation date to true
		-- setup the Output tab fields
		set gallery file name to "index.html"
		set make HTML picture pages to false
		set open pictures in new window to true
		set image size type to scaletomaximums -- originalsize/scaletomaximums/scaletopercentage 
		set max image width to 800 -- maximum image width if sizing by maximums
		set max image height to 600 -- maximum image height if sizing by maximums
		set image scale percentage to 70 -- scale factor if sizing by percentage
		set image quality type to targetsize -- percentagequality/targetsize 
		set image quality percentage to 61 -- image quality if using percentage setting
		set image target size to 29 -- target file size (in KBytes) for images
		set FTP files to false
		set FTP server to "ftp.my_isp.com"
		set FTP path to "webpages/test"
		set FTP user to "my_user_name"
		set FTP password to "my_password"
		-- setup the Advanced Fields
		set head description to "head description text"
		set head keywords to "key1,key2,key3"
		set robots NOINDEX to true
		set robots NOFOLLOW to true
		set head end include to "<!-- head end code -->"
		set body start include to "<!-- body start code -->"
		set body end include to "<!-- body end code -->"
	end tell
	-- save the document to a file
	if has been saved of doc is false then
		set docfile to ("MacOS X:Users:splons:Desktop:sampledoc.wpic" as file specification)
		save doc in docfile
		save doc
	end if
	-- build the web pages for this document - NOTE: the 'samplebuild' folder must already exist
	set buildfolder to "MacOS X:Users:splons:Desktop:samplebuild" as alias
	build pages of doc into buildfolder
end tell


If you have a specific task that you are trying to script with WebPics let us know. We will try help with the scripting or add new events and properties as they are needed.

Return to table of contents

© 1998-2006 M3 Software Developers, Steve Splonskowski, all rights reserved.