Copy link to clipboard
Copied
Hi All,
Is it possible to save the clipboard image in the desktop using script? And save the clip board image into swatches then apply as color to selected layer via scripting.
Copy link to clipboard
Copied
I'm not exactly clear what you mean by all that. If it's AI data, all that would be required is to paste it to a new document. Otherwise you don't have access over pixel data and savcing it to your computer directly would be done much more efficiently using your system's screenshot & clipping tool. Conversely, adding stuff to a swatch requires to sample a color using the eyedroper or creating some sort of selection to e.g. generate a pattern swatch or brush.
Mylenium
Copy link to clipboard
Copied
Thanks for the update.
It's not AI image, need to save the image copy from the web(screenshot), that image will save into swatches or pattern as you mentioned that color will apply for AI images, this all need to be done via scripting. Is it possible?
Copy link to clipboard
Copied
Illustrator probably isn't the right tool for this job.. Illustrator is designed for manipulating vector artwork, not processing raster images. There's no built-in way to just create a bunch of swatches from an image...
a potential workaround is to use Live Trace with a custom setting to convert the image into vector, then expand the image into a clean vector object, then select the artwork and do "add selected colors" from the swatches panel. theoretically all of that could be done with a script.
but i just re-read your last comment... and i think i misunderstood what you're looking for. you don't want a bunch of swatches that match the colors in the photos... you want a script that automatically converts the copied image into a tileable pattern fill swatch? that's simply not going to be possible in AI.
Copy link to clipboard
Copied
this code is not working to download any image from the adobe illustrator.
function base64(imgPath){
const base64string = imgPath;
const pageImage = new Image();
pageImage.src='data:image/png;base64,' + base64string;
pageImage.onload = function() {
const canvas = document.createElement('canvas');
canvas.width = pageImage.naturalWidth;
canvas.height= pageImage.naturalHeight;
const ctx = canvas.getContext('2d');
ctx.imageSmoothingEnabled = false;
ctx.drawImage(pageImage, 0, 0);
saveScreenshot(canvas);
}
}
function saveScreenshot(canvas) {
let fileName = "image"
const link = document.createElement('a');
link.download = fileName + '.png';
canvas.toBlob(function(blob) {
link.href = URL.createObjectURL(blob);
link.click();
});
};
Copy link to clipboard
Copied
Hi Mylenium,
Can you please give your suggestion on this asap.
Thanks,
Rishabh