• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Illustrator: MultiExporter-Tool: Change script to add image dimensions

Participant ,
Dec 27, 2018 Dec 27, 2018

Copy link to clipboard

Copied

The MultiExporter tool  can generate png's of all artboards in your document.

The png's get the same name as the artboards.

The JavaScript code for the MultiExporter tool can be found here:

https://gist.github.com/larrybotha/5baf6a9aea8da574cbbe

What I want is to add automatically the dimension of the artboard/png to the exported png's.

So instead of file names like Number-1.png, Number-2.png I want file names

like Number-1_900x500.png, Number-2_800x600.png.

So is there anybody who knows if there is a simple possibility to change the script

to get automatically the width and height of the artboard/image in the file name?

TOPICS
Scripting

Views

6.2K

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
Adobe
Community Expert ,
Dec 27, 2018 Dec 27, 2018

Copy link to clipboard

Copied

Hi BaCbDc​,

sorry, but for scripters it's not a good manner to rewriting scripts from other developers.

Did you try to reach the developer Matthew Ericson?

Some hints for doing it by yourself:

In most cases you get the artboard size with:

var ab = app.activeDocument.artboards[0];

var Bds = ab.artboardRect;

alert((Bds[2] - Bds[0]).toFixed (3) + " pt × " + (Bds[1] - Bds[3]).toFixed (3) + " pt");

I did not go to deep into the code, but you have to work with the variable: base_filename

(pay attention: This variable does exists at several places in the script.)

Good luck

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
Participant ,
Dec 28, 2018 Dec 28, 2018

Copy link to clipboard

Copied

LATEST

With your hints I have done this beginning at line 356 in MultiExporter.js

           //var base_filename = this.base_path + "/" + this.prefix + artboardName + this.suffix

           

            var ab = app.activeDocument.artboards;

            var Bds = ab.artboardRect;

            //alert((Bds[2] - Bds[0]).toFixed (3) + " pt × " + (Bds[1] - Bds[3]).toFixed (3) + " pt");

            widthofartboard = (Bds[2] - Bds[0]).toFixed (3);

            heightofartboard = (Bds[1] - Bds[3]).toFixed (3);

           

            var base_filename = this.base_path + "/" + this.prefix + artboardName + this.suffix  + "_" +

            parseInt(widthofartboard) + "x" + parseInt(heightofartboard)

            //original:           

            //var base_filename = this.base_path + "/" + this.prefix + artboardName + this.suffix  +

            //docRef.artboards.width + "x" + docRef.artboards.height

Could be bad coded. But it's working. Update: Have just read what the meaning of toFixed is (number of places between 0 and 20 after the decimal point). So with toFixed(0) I think I don't need parseInt anymore.

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