Copy link to clipboard
Copied
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.
Could you please give me any advise how to solve this issue?
Copy link to clipboard
Copied
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;
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
oh, I see, sorry about that.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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');
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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)
2. Use any preset (e.g. Black&White)
3. Run the script snippet
All predefined settings are available now.
Copy link to clipboard
Copied
Yes, I made an inaccuracy. What I meant:
I have a preset:
So in this preset Colors parameter equals to 40.
Also, I run this code:
And I have a result:
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.