Skip to content

Instantly share code, notes, and snippets.

@dreness
Created April 23, 2020 22:06
Show Gist options
  • Save dreness/cb68ea71b841c6f1d697fd1fc55490f8 to your computer and use it in GitHub Desktop.
Save dreness/cb68ea71b841c6f1d697fd1fc55490f8 to your computer and use it in GitHub Desktop.
Ask Acorn to save every layer of an image to a separate index-numbered file.
set skipLayers to {}
set the end of skipLayers to {outter:"Window Server", inner:"Desktop"}
set outString to "Skipping layers:" & "
"
repeat with i in skipLayers
set outString to outString & " " & outter of i & "-->" & inner of i & "
"
end repeat
log outString
tell application "Acorn"
set outPathBase to "/Users/andre/Desktop/mac-layers/"
tell document 1
set layerindex to 1
repeat with thelayer in layers
set visible of thelayer to false
end repeat
repeat with thelayer in layers
set visible of thelayer to true
set toplayername to name of thelayer as string
repeat with sublayer in layers of thelayer
set visible of sublayer to false
end repeat
repeat with sublayer in layers of thelayer
repeat with skipLayer in skipLayers
if ((outter of skipLayer) is equal to (name of thelayer)) and ((inner of skipLayer as string) is equal to (name of sublayer as string)) then
log "skipping layer: " & outter of skipLayer & " : " & inner of skipLayer
exit repeat
else
set visible of sublayer to true
--display dialog toplayername & " --> " & name of sublayer as string
set outPath to POSIX file ((outPathBase & layerindex as string) & ".TIFF") of me
set layerindex to layerindex + 1
save as TIFF in outPath
set visible of sublayer to false
end if
end repeat
end repeat
set visible of thelayer to false
end repeat
end tell
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment