I am looking for a script that will give me a list of all the colors in an Adobe Illustrator document by there color numbers (rgb or cmyk). I have no code and have no idea how to do this, or if you even can. Can anyone please give me any information?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
From SVG
This solution uses a browser to parse/extract all colors present. You should follow this steps:
The idea is iterating over all elements and using getComputedStyle(), then extract only values like
rgb(n, n, n)
using a regex like/(.*)(rgb\([0-9, ]*\))(.*)/g
performing another loop, like this:Full functional example here: https://jsfiddle.net/gwd35Lyv/ and https://jsfiddle.net/oenmL4t6/ an empty document in which you could include the svg created.
This is assuming we are using a browser, not embebed JavaScript into illustrator file.
You could also open the svg file with a browser, like this https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/AJ_Digital_Camera.svg press F12 and in the console, paste the js code in it.
From Image
Previous solution doesn't compute the colors present in images, because we have to read pixel by pixel, to do that based in this How to get a pixel's x,y coordinate color from an image?. we could do this:
Here an example: http://jsfiddle.net/vkq0ew9n/ The restriction is that the image should be within the same origin (local doesn't work, just http: https: etc, not file:).
This will loop through all the shapes in the active document and gets posts an alert with their RGB fill colours:
Note: You document must be in RGB colour mode for this to work
The long
If
line anwers your other question