AnsweredAssumed Answered

Applescript performs differently from within Filemaker

Question asked by jarvphot on Jan 6, 2016
Latest reply on Jan 14, 2016 by MacCarl

Hello, thanks in advance for any help.

 

I have an Applescript that opens Photoshop and converts an image to a jpeg proof. The script adds the job name and the filename to the face of the photograph so it's easier for clients to tell me which image they want as their final selection.

 

When I run the script from Script Editor it performs correctly, adding this text to the face of the image:

Smith_John 02

 

However, when I run the same Applescript from within a Filemaker script, I get this instead:

Smith_John 0<<2

 

This only happens if the applescript is called by the Filemaker script using the Run Applescript command.

 

Here is a simplified version of the applescript:

 

--GET DATA FROM FILEMAKER

tell application "FileMaker Pro Advanced"

  set jobFolder to cell "Paths::Path to Job folder" of current record

  set jobType to cell "Jobs::JobType" of current record

  set jobDescription to cell "Jobs::JobDescription" of current record

end tell

 

 

--SET OUTPUT PATH

set targetFolder to path to desktop

 

 

--SELECT IMAGES FOR PROCESSING

choose file of type "public.image" with prompt ¬

  "Select Images" with multiple selections allowed

 

set fileList to result

 

--CONVERT IMAGES

with timeout of 60 * 60 * 24 seconds

  tell application "Adobe Photoshop CC 2015"

  set ruler units of settings to pixel units

  repeat with aFile in fileList

  open aFile showing dialogs never

  set background color to {class:RGB color, red:255, green:255, blue:255}

 

  tell the current document

 

  set fName to name

  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

 

  flatten

 

  if height > width then

  resize image height 1500

  else

  resize image width 1500

  end if

 

  set docHeight to height

  set docWidth to width

 

  make new art layer with properties {kind:normal, opacity:30}

  select region {{0, (docHeight - 60)}, {docWidth, (docHeight - 60)}, {docWidth, (docHeight - 170)}, {0, (docHeight - 170)}} without antialiasing

  fill selection with contents {class:RGB hex color, hex value:"000000"}

  deselect

 

  make new art layer with properties {kind:normal, opacity:30}

  select region {{0, (docHeight - 5)}, {docWidth, (docHeight - 5)}, {docWidth, (docHeight - 52)}, {0, (docHeight - 52)}} without antialiasing

  fill selection with contents {class:RGB hex color, hex value:"000000"}

  deselect

 

  make new art layer with properties {kind:text layer, opacity:100}

  tell text object of art layer 1

  set {contents, size, stroke color, position, justification} to {"Jarvis Photography Lake Tahoe", 13.0, {class:RGB hex color, hex value:"FFFFFF"}, {(docWidth * 0.5), (docHeight - 120)}, center}

  end tell

  set font of text object of art layer 1 to "TrajanPro-Regular"

 

  make new art layer with properties {kind:text layer, opacity:100}

  tell text object of art layer 1

  set {contents, size, stroke color, font, position, justification} to {"Unretouched Proof", 12.0, {class:RGB hex color, hex value:"FFFFFF"}, "Scala Sans Bold", {(docWidth * 0.5), (docHeight - 70)}, center}

  end tell

 

  make new art layer with properties {kind:text layer}

  tell text object of art layer 1

  set {contents, size, stroke color, font, position, justification} to {jobDescription & "  " & baseName, 10.0, {class:RGB hex color, hex value:"FFFFFF"}, "Scala Sans Regular", {(docWidth * 0.5), (docHeight - 15)}, center}

  end tell

 

  set myOptions to {class:JPEG save options, embed color profile:true, quality

  save in ((targetFolder as string) & name) as JPEG with options myOptions with copying

 

  end tell

  close the current document saving no

  end repeat

  end tell

end timeout

 

If anyone can help me eliminate the extra characters in the name it would be greatly appreciated. Thanks!

 

Eric

Outcomes