Help! Slow Script!
Help! Slow Script!
- Subject: Help! Slow Script!
- From: "Sprague, Graham" <email@hidden>
- Date: Tue, 9 Jul 2002 09:53:33 -0400
Hey all,
I've written a droplet script that uses Photoshop 7 to extract dimensions
and create thumbnails which are then placed into a FileMaker File. It all
works fine but seems so damn slow. Funny thing is the slow spots are when
one app finishes a task and another is about to start one. I tried adding
"activate" statements but that made the delay even longer!? I think I may be
doing something I shouldn't. If anyone can offer any suggestions I would
greatly appreciate it. Code listed below...
--Start Code
--Raster or not Raster List
property noRasterList : {"JPEG", "TIFF", "8BPS"}
property rasterList : {"PDF ", "EPSF", "????"}
property imagePath : ""
property curFile : ""
--returned of getFileData
property theType : ""
property theCreator : ""
property theName : ""
--returned of getFileHeader
property fileContents : ""
--returned of processPSFile
property printHeight : ""
property printWidth : ""
property typeFlag : ""
--start main
on open filesDragged
--Check to see if user is logged in...
tell application "FileMaker Pro"
--Check to see if Dropper Database is open
if database "CSD_2_Dropper" exists then
else
--display dialog "Login is next"
loginCSD() of me
end if
go to window "CSD_2_Dropper"
tell database "CSD_2_Dropper"
do script " Prepare for Import"
end tell
end tell
repeat with curFile in filesDragged
--get data from finder
getFileData(curFile) of me
--process the image using photoshop
processPSFile(curFile) of me
--Populate FileMaker with Data
populateFileMaker() of me
end repeat
end open
----------------------Functions Below this
Line-------------------------------------------------
--**Login to CSD
on loginCSD()
tell application "FileMaker Pro"
--get URL "fmp5://email@hidden/CSD_Session"
open file "Macintosh HD:Desktop Folder:CSD Rev 2:CSD_2_Session" with
password "wheelie"
end tell
end loginCSD
--**Get File Data from Finder
on getFileData(curFile)
tell application "Finder"
set theType to the file type of curFile
set theCreator to the creator type of curFile
set theName to the name of curFile
end tell
end getFileData
on getFileHeader(curFile)
tell application "Finder"
set fileContents to read curFile from 1 to 500
end tell
end getFileHeader
--**Process image using Photoshop
on processPSFile(curFile)
tell application "Adobe Photoshop 7.0"
set rulerUnits to ruler units of settings
set rulerUnits to rulerUnits as string
if theType is in noRasterList then
set typeFlag to "Raster Image"
open file (curFile as string) showing dialogs never
else
if theType is in rasterList then
getFileHeader(curFile) of me
if theType is equal to "EPSF" and "Illustrator" is
not in fileContents then
set typeFlag to "Raster Image"
open file (curFile as string) showing
dialogs never
else
set typeFlag to "Vector Image"
if theType contains "PDF " then
open file curFile showing dialogs
never as PDF with options ,
{class:PDF open options,
height:inches 3, width:inches 3, mode:RGB, resolution:300, use
antialias:true, page:1, constrain proportions:true} ,
else
open file curFile showing dialogs
never as EPS with options ,
{class:EPS open options,
height:inches 3, width:inches 3, mode:RGB, resolution:300, constrain
proportions:true}
end if
end if
end if
end if
set curDoc to document theName
--set imageProperties to info of curDoc
set imageRes to (resolution) of curDoc
set imageHeight to height of curDoc
set imagewidth to width of curDoc
tell curDoc
resize image curDoc width 3 resolution 72
select all
activate
copy selection
end tell
--convert units to determine max print size
if rulerUnits contains "pixel" then
set displayHeight to imageHeight
end if
if rulerUnits contains "inch" then
set pixelHeight to imageHeight * imageRes
set pixelWidth to imagewidth * imageRes
end if
if rulerUnits contains "cm units" then
set pixelHeight to (imageHeight * 0.3937) * imageRes
set pixelWidth to (imagewidth * 0.3937) * imageRes
end if
if rulerUnits contains "mm units" then
set pixelHeight to (imageHeight * 0.03937) * imageRes
set pixelWidth to (imagewidth * 0.03937) * imageRes
end if
if rulerUnits contains "point units" then
set pixelHeight to (imageHeight / 72) * imageRes
set pixelWidth to (imagewidth / 72) * imageRes
end if
if rulerUnits contains "pica units" then
set pixelHeight to (imageHeight / 6) * imageRes
set pixelWidth to (imagewidth / 6) * imageRes
end if
set printHeight to (pixelHeight / 300)
set printWidth to (pixelWidth / 300)
if pixelHeight is equal to "" then
display dialog "Pixel Height is null!" & "File Type is " &
theType
else
set theHeight to printHeight as string
set theWidth to printWidth as string
end if
close curDoc without saving
end tell
end processPSFile
on populateFileMaker()
tell application "FileMaker Pro"
activate
tell database "CSD_2_Dropper"
go to (create new record at end)
go to cell "imageThumb" of current record
paste
--set cell "Units" of current record to rulerUnits
set cell "formatType" of current record to typeFlag
if typeFlag does not contain "Vector Image" then
set cell "printHeight" of current record to
printHeight
set cell "printWidth" of current record to
printWidth
set cell "imageName" of current record to theName as
string
set cell "imagePath" of current record to curFile as
string
end if
end tell
end tell
end populateFileMaker
--End Code
Graham Sprague
Advertising Sr. Systems Administrator
Staples, Inc.
500 Staples Drive
Framingham, MA 01702
508-253-8170
email@hidden
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.