• Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
    Dedicated community for Japanese speakers
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
    Dedicated community for Korean speakers
Exit
2

Script to rotate selected image inside frame Data merge

Engaged ,
Jul 22, 2023 Jul 22, 2023

Copy link to clipboard

Copied

Hi

I am preparing a date merge process , I want to rotate each image of 5 images by a certain angle different from other images

I found that no object style can i apply to do that

Is there are a script to do that Automatically

TOPICS
Scripting

Views

730

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , Jul 22, 2023 Jul 22, 2023

Hi @r28071715i111, here's an idea (and a working script). First you select each graphic (can be the graphic or it's frame) and set its Script Label (see the Script Label panel under Windows > Utilities menu) to "rotate: 15" where the 15 means 15 degrees counterclockwise. Will that work in your case? Script is below, and I've attached a demo .indd also so you can test script with that first.

- Mark

Image by Alison Wang via UnsplashImage by Alison Wang via Unsplash

 

/**
 * Apply rotation to graphics with a "rotate" script label.
...

Votes

Translate

Translate
Community Expert , Jul 23, 2023 Jul 23, 2023

Hi @r28071715i111, my idea was that you set up the script labels before datamerge and then run script after datamerge. 

Votes

Translate

Translate
Engaged ,
Jul 22, 2023 Jul 22, 2023

Copy link to clipboard

Copied

Any Help here !!!!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 22, 2023 Jul 22, 2023

Copy link to clipboard

Copied

Is the rotation angle variable? If so then how is it determined? If not then can't you rotate the image frame beforehand and then do the merge?

-Manan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 23, 2023 Jul 23, 2023

Copy link to clipboard

Copied

Thanks For your Replay Manan

rotation angle is variable depends on its graphic frame )

( If the image is in graphic frame 1 , rotate it by 30 degrees )

( If the image is in graphic frame 2 , rotate it by 20 degrees )

and so on

I want to select image angle degrees of all its graphic frames before i make data merge

Or

Its is possibe after making data merge but it is necessary to add in script ( From page number (  ) to page number ( )

or apply in all pages of the document

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 22, 2023 Jul 22, 2023

Copy link to clipboard

Copied

Hi @r28071715i111, here's an idea (and a working script). First you select each graphic (can be the graphic or it's frame) and set its Script Label (see the Script Label panel under Windows > Utilities menu) to "rotate: 15" where the 15 means 15 degrees counterclockwise. Will that work in your case? Script is below, and I've attached a demo .indd also so you can test script with that first.

- Mark

Image by Alison Wang via UnsplashImage by Alison Wang via Unsplash

 

/**
 * Apply rotation to graphics with a "rotate" script label.
 * eg. if label is "rotate: 15", then the graphic will be
 * rotated by 15Ā° counter-clockwise.
 * @author m1b
 * @discussion https://community.adobe.com/t5/indesign-discussions/script-to-rotate-selected-image-inside-frame-data-merge/m-p/13955151
 */
function main() {

    var doc = app.activeDocument,
        tm = app.transformationMatrices.add({ counterclockwiseRotationAngle: 0 }),
        images = doc.allGraphics,
        matcher = /^rotate:(-?\d+\.?\d*)/i,
        label,
        value;

    for (var i = 0; i < images.length; i++) {

        label = images[i].label || images[i].parent.label;

        if (!label)
            continue;

        value = label.match(matcher);

        if (!value
            || value.length < 2
            || isNaN(value = Number(value[1]))
        )
            continue;

        images[i].transform(
            CoordinateSpaces.pasteboardCoordinates,
            AnchorPoint.centerAnchor,
            tm.rotateMatrix(-images[i].absoluteRotationAngle + value),
        );

    }

};

app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Rotate Graphics');

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 23, 2023 Jul 23, 2023

Copy link to clipboard

Copied

Thanks For your Reply mark

But I have a question : Is that script work after making data merge or before ?

Ex : I want all images across pages in graphic frame 1 rotate by 10 degress 

                  all images across pages in graphic frame 2 rotate by 23 degress 

And so on

I will try your script and tell you result

Thanks for your effort in advance

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 23, 2023 Jul 23, 2023

Copy link to clipboard

Copied

Hi @r28071715i111, my idea was that you set up the script labels before datamerge and then run script after datamerge. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 23, 2023 Jul 23, 2023

Copy link to clipboard

Copied

Very very great thanks for you

your script works like a charm

as you said i set up the script labels before datamerge then saved file and then run script after datamerge

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 23, 2023 Jul 23, 2023

Copy link to clipboard

Copied

I'm glad it worked for you! šŸ™‚

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 23, 2023 Jul 23, 2023

Copy link to clipboard

Copied

My point is if there is no logic that comes in from the merged data and we have to go to every frame one by one anyhow even  in the case of using @m1b's script then why don't we do it manually. Script could help only if we can narrow down the use case of going to each frame. Something like all graphics on page 1 rotates by 15 degrees, etc.

-Manan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 23, 2023 Jul 23, 2023

Copy link to clipboard

Copied

We can't do it manually because it takes a lot of time

suppose that we have 500 pages and each page contain 5 graphic frames each of them rotate by certain angle that mean 2500 images , it will spend too much hours .

Thanks for your reply

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 23, 2023 Jul 23, 2023

Copy link to clipboard

Copied

If you know upfront which image should be rotated and by how much - and it looks like you know, as you can set labels to the frames - then you can rotate them in Photoshop BEFORE importing... 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 23, 2023 Jul 23, 2023

Copy link to clipboard

Copied

Thanks for your reply 

But i can't make this soltion beacause images are distributed among 500 folders not in one folder

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 23, 2023 Jul 23, 2023

Copy link to clipboard

Copied

I'm pretty sure Photoshop should be able to handle subfolders? 

 

And why so many subfolders? 

 

By any chance you work on a PC? Then you could use the free version of my ID-Tasker.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 23, 2023 Jul 23, 2023

Copy link to clipboard

Copied

LATEST

Because Each folder belongs to one student and its images only and students images not renamed by its name so that i can know the But its renaming is by numbers 

Sure ...I will use free version of id tasker and if i agreed it , I will purshace licence

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines