Skip to main content
Participant
November 2, 2016
Answered

Script to rotate image inside a frame

  • November 2, 2016
  • 1 reply
  • 1233 views

Hello,  reaching out before I fall completely down the rabbit hole. 

I have a script that downloads puzzles and comics daily.  I have one puzzle that when downloaded, needs to be placed 90CCW.  A sample of the code i'm trying is here:

                // LA TIMES SUNDAY

                if (pageItem.label == "LA_TIMES_SUNDAY_CROSSWORD")

                try{

                    name = "20" + myDate.text + "pzsxw-a.tif"

                    var myFile = new File(imagePath+name);

  if (myFile.exists)

                    {

  pageItem.place(myFile);

  pageItem.rotationAngle = 90;

  // pageItem.fit(FitOptions.CONTENT_TO_FRAME);

                        }

                   

This works but it moves my frame way up and resizes it.  Any ideas how I can only have the image rotate within the frame, keeping everything else in the template static?

Hope this makes sense.

Doug

This topic has been closed for replies.
Correct answer Trevor:

Hi Doug

You can use

var tm = app.transformationMatrices.add(undefined, undefined, undefined, 90);

pageItem.transform(CoordinateSpaces.pasteboardCoordinates, AnchorPoint.centerAnchor, tm);

instead of

pageItem.rotationAngle = 90;

HTH

Trevor

1 reply

Trevor:
Trevor:Correct answer
Legend
November 3, 2016

Hi Doug

You can use

var tm = app.transformationMatrices.add(undefined, undefined, undefined, 90);

pageItem.transform(CoordinateSpaces.pasteboardCoordinates, AnchorPoint.centerAnchor, tm);

instead of

pageItem.rotationAngle = 90;

HTH

Trevor

Trevor:
Legend
November 3, 2016

Easier to remember is

app.layoutWindows[0].transformReferencePoint = AnchorPoint.CENTER_ANCHOR;

pageItem.rotationAngle  = 90;