Sirds AppleScript sample

Sirds

Moderators: admin, katsura

Post Reply
katsura
Posts: 1
Joined: Mon Sep 18, 2017 4:28 pm

Sirds AppleScript sample

Post by katsura » Fri Sep 22, 2017 5:40 am

Code: Select all

(*   drop generate SIRDS AppleScript droplet for Sirds 

   Copyright (c) 2006-2009 Katsura Shareware. All rights reserved. 
    
   generates stereogram image files from image files/folders dropped on to this AppleScript droplet. 
*) 

property useCrossEyedView : false 

on processFile(aFile) 
    
   tell application "Sirds" 
       
      -- set all the preferences first 
      set pattern mode to random 
      set random dot color to full color 
      set random dot shape to random shapes 
      set resolution to 85 
      if useCrossEyedView is true then 
         set view mode to cross eyed -- Sirds version 1.1 or later 
         set observer distance to 28 
         set maximum depth to 14 
      else 
         set view mode to wall eyed -- Sirds version 1.1 or later 
         set observer distance to 14 
         set maximum depth to 14 
      end if 
      set eye separation to 2.5 
      set oversampling to off 
      set show guide to false 
      set invert depth to false 
       
      set anExtension to name extension of (info for aFile) 
      set aFilePOSIXPath to (POSIX path of aFile) 
      set theOffset to offset of ("." & anExtension) in aFilePOSIXPath 
      set anExportFilePath to characters 1 through (theOffset - 1) of aFilePOSIXPath 
      set anExportFilePath to (anExportFilePath as string) & "_stereo.png" 
       
      open aFilePOSIXPath 
      tell document 1 
         export stereogram to (POSIX file anExportFilePath) as "png" 
      end tell 
      close window 1 
   end tell 
end processFile 

on processFolder(aFolder) 
   set itemList to list folder aFolder without invisibles 
   repeat with anItem in itemList 
      set aFilePath to ((aFolder as text) & ":" & anItem) 
      set aFile to alias aFilePath 
      set itemInfo to info for aFile 
      if folder of itemInfo is true then 
         processFolder(aFile) 
      else 
         processFile(aFile) 
      end if 
   end repeat 
end processFolder 

-- dropped file or folder gets passed to this "on open" action 
on open aList 
   repeat with anItem in aList 
      set itemInfo to info for anItem 
      if folder of itemInfo is true then 
         -- process a folder 
         processFolder(anItem) 
      else 
         -- process a file 
         processFile(anItem) 
      end if 
       
   end repeat 
    
end open

Post Reply