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

Scriptui iconbutton in Illustrator CS5 - very simple?

New Here ,
Nov 10, 2011 Nov 10, 2011

Copy link to clipboard

Copied

Hi all,

I am trying to make this very basic script work in Illustrator CS5 but I keep getting the following error:

Error 509: Invalid image data

Line: 4

-> w.add("iconbutton", undefined, f); //a

The code is:

var w = new Window ("dialog");

w.orientation = "row";

var f = File ("ai.jpg")

w.add ("iconbutton", undefined, f ); // a

w.show ();

I have tried it with .ico, .png, .jpg all with the same error.  Have been looking around for examples and tuts and I can't find anything wrong with my code.

I apologize if this is a stupid question 😃

TOPICS
Scripting

Views

1.6K

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 1 Correct answer

Enthusiast , Nov 10, 2011 Nov 10, 2011

your filepath is unvalid, isn't it?

try put you icon image on desktop folder and replace it with

var w = new Window ("dialog");

w.orientation = "row";

var f = File ("~/Desktop/ai.jpg")

w.add ("iconbutton", undefined, f );

w.show ();

Votes

Translate

Translate
Adobe
New Here ,
Nov 10, 2011 Nov 10, 2011

Copy link to clipboard

Copied

Not sure if possibly CS5 has some issues with iconbutton class?

Of note, the following works fine (using image instead of iconbutton); but would be a lot easier if I could use iconbutton

// . . .

// Number of vertical slices

// ---

var V_SPRITES = 3;

// Create the UI

// ---

var w = new Window('dialog',"ScriptUI Sprites"),

    myImage = w.add('image', undefined, myPNG),

    iSize = myImage.image.size,

    spriteHeight = iSize[1] / V_SPRITES;

myImage.size = [iSize[0], spriteHeight];

// . . .

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
Enthusiast ,
Nov 10, 2011 Nov 10, 2011

Copy link to clipboard

Copied

your filepath is unvalid, isn't it?

try put you icon image on desktop folder and replace it with

var w = new Window ("dialog");

w.orientation = "row";

var f = File ("~/Desktop/ai.jpg")

w.add ("iconbutton", undefined, f );

w.show ();

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
New Here ,
Nov 10, 2011 Nov 10, 2011

Copy link to clipboard

Copied

LATEST

I would have sworn that I was getting a different error message for an incorrect path, but I just tested above and it worked flawlessly.  I then tested with a bad path and got the 509 error.  So 100% correct answer.

I was assuming the script would call a relative path to its own.

Thank you so much for catching this for me.

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