Jump to content
Server Maintenance This Week. ×

FM/Photoshop Automation


This topic is 6633 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I have an applescript, that "processes" images, I want to know if there is a way to do this with VBScripting, or anything else on the Windows side. Here is my applescript.






ConvertFiles()







on ConvertFiles()

	

	-- set the folders that you want to use 

	set inputfolder to "Macintosh HD:O_Images:input:"

	set outputFolder to "Macintosh HD:O_Images:hires:"

	set copyFoldername to "Macintosh HD:O_Images:thumbs:"

	

	tell application "Finder"

		set filesList to files in folder inputfolder

	end tell

	

	tell application "Adobe Photoshop CS"

		set display dialogs to never

		close every document saving no

	end tell

	

	repeat with aFile in filesList

		try

			set fileIndex to 0

			tell application "Finder"

				-- The step below is important because the 'aFile' reference as returned by 

				-- Finder associates the file with Finder and not Photoshop. By converting 

				-- the reference below 'as alias', the reference used by 'open' will be 

				-- correctly handled by Photoshop rather than Finder. 

				set theFile to aFile as alias

				set theFileName to name of theFile

			end tell

						tell application "Adobe Photoshop CS"

				set display dialogs to never

				try

with timeout of 15 seconds

					open theFile

end timeout

					try

						set docRef to the current document

						if (mode of docRef is not RGB) then

							change mode docRef to RGB

						end if

						resize image docRef resolution 300 resample method none

						set infoRef to get info of docRef

						set docName to name of docRef

						set docBaseName to getBaseName(docName) of me

						set fileIndex to fileIndex + 1

						set newFileName to (outputFolder as string) & docBaseName

						save docRef in file newFileName as JPEG with options {quality:10} appending lowercase extension with copying

						resize image docRef resolution 72 resample method bicubic

						resize image current document width 1.5 resample method bicubic

						set newFileName to (copyFoldername as string) & docBaseName

						save docRef in file newFileName as JPEG appending lowercase extension

						close current document without saving

					on error

						try

							set docRef to the current document

							set infoRef to get info of docRef

							set docName to name of docRef

							set docBaseName to getBaseName(docName) of me

							set fileIndex to fileIndex + 1

							set newFileName to (outputFolder as string) & docBaseName

							save docRef in file newFileName as JPEG appending lowercase extension

							close current document without saving

							open newFileName

							try

								set docRef to the current document

								if (mode of docRef is not RGB) then

									change mode docRef to RGB

								end if

								resize image docRef resolution 300 resample method none

								set infoRef to get info of docRef

								set docName to name of docRef

								set docBaseName to getBaseName(docName) of me

								set fileIndex to fileIndex + 1

								set newFileName to (outputFolder as string) & docBaseName

								save docRef in file newFileName as JPEG with options {quality:10} appending lowercase extension with copying

								resize image docRef resolution 72 resample method bicubic

								resize image current document width 1.5 resample method bicubic

								set newFileName to (copyFoldername as string) & docBaseName

								save docRef in file newFileName as JPEG appending lowercase extension

								close current document without saving

							on error

								tell application "Finder"

									delete theFile

								end tell

							end try

							

						on error

							tell application "Finder"

								delete theFile

							end tell

						end try

					end try

				on error

					tell application "Finder"

						delete theFile

					end tell

				end try

			end tell

		end try

		

	end repeat

	tell application "FileMaker Pro Advanced" to activate

	

end ConvertFiles



-- Returns the document name without extension (if present) 

on getBaseName(fName)

	set baseName to fName

	repeat with idx from 1 to (length of fName)

		if (item idx of fName = ".") then

			set baseName to (items 1 thru (idx - 1) of fName) as string

			exit repeat

		end if

	end repeat

	return baseName

end getBaseName

any help is appreciated.

Link to comment
Share on other sites

According to these:

http://partners.adobe.com/public/developer/en/photoshop/sdk/PhotoshopScriptingGuide.pdf

http://partners.adobe.com/public/developer/en/photoshop/sdk/VisualBasicReferenceGuide.pdf

You can use VBscript.

The first part of your AS: look in the Solutions index for the demo file I posted there a few weeks ago. It uses VBscript to get all the files from a specified folder.

Link to comment
Share on other sites

Wim ( or anyone else ) can you suggest a GOOD VBscripting book, I need one that teaches me the very basics, and then the syntax. I keep finding books that talk about using teaching you to use VBScripts on the web, I don't want this right now. I'm a quick learner, with other programming knowledge. Just need a good book to help me get started here.

Link to comment
Share on other sites

Start with what's on your computer already: Script56.CHM is the help file for VBscript 5.6 (the latest version). It has some introduction and a full language reference.

The Photoshop PDFs will tell you what PhotoShop objects you can use.

Another good starting place is www.microsoft.com/scripting

Link to comment
Share on other sites

This topic is 6633 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.