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

Image trace in js script

Community Beginner ,
Dec 29, 2016 Dec 29, 2016

Hi!

I'm trying to trace a PNG image in Adobe Illustrator via js script. I've tried different approaches, but always have the same problem - I can't change Color setting automatically. Here is my simple script:

thisImage.tracing.tracingOptions.tracingMethod = TracingMethodType.TRACINGMETHODABUTTING; 

thisImage.tracing.tracingOptions.tracingMode = TracingModeType.TRACINGMODECOLOR; 

thisImage.tracing.tracingOptions.cornerFidelity = 50

thisImage.tracing.tracingOptions.pathFidelity = 55

thisImage.tracing.tracingOptions.noiseFidelity = 5

thisImage.tracing.tracingOptions.maxColors = 40

thisImage.tracing.tracingOptions.colorFidelity = 50

app.redraw();

So other parameters were changed during this script execution (Paths, Corners, Noise), but Colors is 100 again despite maxColors and colorFidelity. And I don't see any additional fields in tracing options that can be responsible for this.

%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA.PNG

Could you please give me any advise how to solve this issue?

TOPICS
Scripting
2.6K
Translate
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 29, 2016 Dec 29, 2016

first you need to Trace your image, that would return a PluginItem where you can point to a TracingObject that you can adjust properties to,

var tracedImage = thisImage.trace();

tracedImage.tracing.tracingOptions.tracingMethod = TracingMethodType.TRACINGMETHODABUTTING;

Translate
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 Beginner ,
Dec 29, 2016 Dec 29, 2016

thisImage is traced image already.

So

var thisImage = selectedImage.trace();

and it's located one line before my code. By the way, I said earlier that other parameters like pathFidelity set without any problems.

Translate
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 ,
Dec 29, 2016 Dec 29, 2016

oh, I see, sorry about that.

Translate
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 ,
Dec 29, 2016 Dec 29, 2016

it could be a bug, I have tried to use TRACINGMODE without success in the past. I solved my problem by recording an Action to Trace the object, then have my script play the action.

Translate
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 Beginner ,
Dec 30, 2016 Dec 30, 2016

CarlosCanto, It looks like a bug for me too. Thank you for a nice approach to playing action in the script. I'll definitely check it if I can't find out how it should work in the script.

Translate
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 ,
Dec 29, 2016 Dec 29, 2016

How about to call a user defined preset

//var myOpts = thisImage.tracing.tracingOptions.loadFromPreset('Line Art');

var myOpts = thisImage.tracing.tracingOptions.loadFromPreset('User defined Preset');

Translate
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 Beginner ,
Dec 30, 2016 Dec 30, 2016

pixxxel schubser, with predefined preset, I have another issue. When I load this preset in the script, it switches to a limited palette, with only 30 max colours.  And my image is traced with this parameters. But when I load this preset in GUI, it works as expected.

Translate
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 ,
Dec 30, 2016 Dec 30, 2016

I'm not agree with you.

0. Define your tracing preset ( in my example the name of the preset is: [User defined Preset] )

1. Place an image in Illu ( I placed an screenshot)

tracingPreset_01.png

2. Use any preset (e.g. Black&White)

tracingPreset_02.png

3. Run the script snippet

tracingPreset_03.png

All predefined settings are available now.

Translate
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 Beginner ,
Dec 30, 2016 Dec 30, 2016
LATEST

Yes, I made an inaccuracy. What I meant:

I have a preset:

1.PNG

So in this preset Colors parameter equals to 40.

Also, I run this code:

2.PNG

And I have a result:

3.PNG

As you can see not only cornerFidelity has changed, but Colors too. And it stands for 100.

Previously, I tried to set colorMode, and I had this issue with limited colors.

And the main trouble - I don't know how to change Colors parameter from a script. Because in any case, it stands for 100. And I can see that there are no differences, despite my options.

Translate
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