New files in a loop
New files in a loop
- Subject: New files in a loop
- From: Max Frevere <email@hidden>
- Date: Thu, 3 Jan 2002 10:45:15 +1100
A Happy New Gregorian Year to everyone from smoky NSW Australia
The problem seems simple but after many hours of reading
documentation and other srcipts and numerous tries as a newbie I am
hoping the list can point me in the right direction.
I am doing some QTVR panographs with a digital camera and using VR
Worx. There is a script included that allows a folder or folders with
12 or more photographs to be dropped on the script and it will
process the images into a QTVR panoramas - one per folder. The script
does its job well. What I am trying to do is
1 - Name the panorama after the folder it is in e.g. Folder is Pano01
- movie is called Pano01.mov
2 - Put the QTVR in the folder it was created from (or maybe all in a
selected folder - outside the loop). This is not essential but keeps
things neat and tidy. The QTVRs could be just saved on the desktop.
3 - Do this automatically for the number of folders dropped on the
script.(So I can process more than 1 movie as I tend the vegies or
sleep - at least something more productive than sitting waiting for
the script to process one QTVR and then wait for more input from me.
The current script will allow this to happen but each movie - which
takes about 4-5 minutes to process has to be named and positioned
individually.
This is the original script with my -- HELP requests
on open droppedItems
set folderCount to 0
-- Set up the loop !!!
repeat with i in droppedItems
activate
set droppedFileInfo to info for i
-- HELP This is where the naming of the file is done !!!
if folder of droppedFileInfo is true then
set folderCount to folderCount + 1
set promptText to "Name a destination QTVR
movie file from folder '" & name of droppedFileInfo & "':"
set defaultNameText to "Pano QTVR " &
folderCount & ".mov"
try
-- HELP this is where the new file is
created !!!
-- is it possible to tell AS to click
on the "Save" button ???
set destFile to new file with prompt
promptText default name defaultNameText
on error
return
end try
if BuildPanorama(i, destFile) = false then
return
end if
end if
end repeat
end open
-- This is for setting the file name when the script is RUN rather
than dropped on !!!
on run
try
set sourceFolder to choose folder with prompt "Select
the folder containing images:"
set destFile to new file with prompt "Name a
destination QTVR movie file:" default name "Pano QTVR.mov"
on error -- e.g. user cancelled
return
end try
BuildPanorama(sourceFolder, destFile)
end run
-- This is where VR Works takes over and processes the file into a
QTVR panorama.
-- This works well at this stage.
-- This is where the new file info is used !!!
on BuildPanorama(sourceFolder, destFile)
try
set validFileTypes to {"PICT", "GIFf", "GIF ",
"JPEG", "TIFF", "BMP ", "BMPf", "PNGf", "PNG ", "PNTG", "8BPS",
"qdgx", "qtif", "SGI ", "clpp", "TPIC"}
set sourceFilePathList to {}
set sourceFolderContents to list folder sourceFolder
repeat with x in sourceFolderContents
set sourceFilePath to alias ((sourceFolder as
text) & x)
set sourceFileInfo to info for sourceFilePath
set sourceFileType to file type of sourceFileInfo
if sourceFileType is in validFileTypes then
set sourceFilePathList to
sourceFilePathList & {sourceFilePath}
end if
end repeat
set sourceFileCount to number of items in sourceFilePathList
launch application "The VR Worx 2.0"
tell application "The VR Worx 2.0"
activate
-- Determine the source image dimensions. If
image is landscape, assume a -900 rotation
set sourceDims to dimensions of (item 1 of
sourceFilePathList)
if (item 1 of sourceDims) > (item 2 of sourceDims) then
set sourceRotation to -90
set sourceDims to {item 2 of
sourceDims, item 1 of sourceDims}
else
set sourceRotation to 0
end if
-- Create a new project document
make new panorama project
set docName to name of document 1
-- Setup the document based on source imagery
set columns of imagery of document docName to
sourceFileCount
set image dims of imagery of document docName
to sourceDims
-- try to find an appropriate FOV
set testFocalLength to 50
repeat
set focal length of imagery of
document docName to testFocalLength
if overlap of imagery of document
docName 0.45 then
exit repeat
end if
set testFocalLength to testFocalLength - 1
end repeat
-- Import all images from the folder
set panel of document docName to 2
set targetCol to 1
repeat with x in sourceFilePathList
set column of target of document
docName to targetCol
import target of document docName
from x rotation sourceRotation
set targetCol to targetCol + 1
end repeat
-- The following sequence off commands could
take a while to complete on slower machines
-- hence the increased timeout
with timeout of 600 seconds -- Ten minutes!
-- Now stitch the images
set panel of document docName to 3
invoke "Stitch"
-- Now blend the panorama
set panel of document docName to 4
invoke "Blend"
-- Now compose the QTVR
set panel of document docName to 6
invoke "Compress"
-- Now export the QTVR
set panel of document docName to 7
export movie of document 1 in
destFile with replacing and optimized
end timeout
-- Close the project document without saving
close document docName without warning
return true
end tell
on error
return false
end try
end BuildPanorama
End of Post - Thankyou for your help
Max Frevere