Skip to main content
pathblaster
Participating Frequently
June 28, 2013
Question

Scale Photoshop layer using AppleScript

  • June 28, 2013
  • 1 reply
  • 2030 views

Obviously, this is a Mac PS issue.

I am trying to script scaling a Photoshop layer (a smart object layer) to a specified percentage that I calculate from a layout in InDesign.

However, I am stumped on the syntax I should use to actually get the layer to resize, or perhaps I don't know how to call out the layer properly.

Here is my code (it is very simple at this point in time:

tell application "Adobe InDesign CS6"

          set mySelect to selection

  --error trap to make sure I have graphic content selected

 

          tell active spread of active window

                    set thisBox to item 1 of mySelect

                    set HScale to the absolute horizontal scale of thisBox

 

          end tell

end tell

myScaleConversion(HScale)

set PSScaled to result as real

tell application "Adobe Photoshop CS6"

          set thisLayer to current layer of current document

          set scaleSet to {horizontal scale:PSScaled, vertical scale:PSScaled, anchor:"top left"}

  scale current layer of current document with scaleSet

 

end tell

on myScaleConversion(HScale)

          set ScaleRatio to 2.5 as real

          set PSScale to (ScaleRatio * HScale)

          return PSScale

 

end myScaleConversion

I would appreciate any help with this. I run this script and no error messages occur, but then again, nothing happens to the Photoshop layer I have targeted.

This topic has been closed for replies.

1 reply

Inspiring
June 28, 2013

There are 2 things I see that are not right… top right should a compiled word pair from the apps dictionary… You have it as string…

Now anchor should be anchor position but I can't get this to compile inside your list… hum… if I take it out it works just fine…

tell application "Adobe InDesign CS5"

  activate

          set mySelect to selection

  --error trap to make sure I have graphic content selected

 

          tell active spread of active window

                    set thisBox to item 1 of mySelect

                    set HScale to the absolute horizontal scale of thisBox

 

          end tell

end tell

myScaleConversion(HScale)

set PSScaled to result as real

tell application "Adobe Photoshop CS5"

  activate

          set thisLayer to current layer of current document

  --set scaleSet to {horizontal scale:PSScaled, vertical scale:PSScaled, anchor position:top left}

  scale current layer of current document ¬

  horizontal scale PSScaled ¬

  vertical scale PSScaled ¬

  anchor position top left

 

end tell

on myScaleConversion(HScale)

          set ScaleRatio to 2.5 as real

          set PSScale to (ScaleRatio * HScale)

          return PSScale

 

end myScaleConversion

pathblaster
Participating Frequently
June 28, 2013

Thanks Mark,

Thanks for your help, Mark. It gets me a lot closer than I was.

I thought that this was what I needed. The syntax is doing something, but the scale command is multiplying the original scale percentage ( the layer is a smart object) by the calculated scale percentage. What I need is to set the layer to the calculated scale percentage.

Inspiring
June 29, 2013

I could not work out what the point of your sub-routine myScaleConversion was…?

If you want the ID scale % the same value passed to PS then remove the sub call…?

On both sides they are given as percentage value…