Copy link to clipboard
Copied
For a project I'm working on I'm writing a Javascript code that does a bunch of things including resizing a document. I need to change it into index before I resize it so the edges don't get blurry and then change it back to RGB but so far nothing is working. Here is what I've been trying:
var srcDoc = app.activeDocument;
var pixelLoc = [1,1];
var colorSamplerRef = srcDoc.colorSamplers.add(pixelLoc);
app.foregroundColor = colorSamplerRef.color;
colorSamplerRef.remove()
srcDoc.changeMode(ChangeMode.INDEXEDCOLOR)
docRes = srcDoc.resolution
if (docRes/10 >= 10){
srcDoc.resizeImage(undefined, undefined, docRes/10, undefined, undefined);
}
else{}
srcDoc.changeMode(ChangeMode.RGB)
The error right now is they want conversion options but I'm lost. Is there a way to say default?
Specify properties with a name:value pair in brackets as below.
srcDoc.changeMode(ChangeMode.INDEXEDCOLOR, {colors:256, palette:Palette.EXACT, transparency:false})
Copy link to clipboard
Copied
Put it into a try/catch block and post the exact error and line. Are you checking document.mode to see if what you are starting with?
Copy link to clipboard
Copied
The document is in RGB mode to start
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I've seen this I was just unsure how to format the relevant information and pass it through the method
Copy link to clipboard
Copied
Specify properties with a name:value pair in brackets as below.
srcDoc.changeMode(ChangeMode.INDEXEDCOLOR, {colors:256, palette:Palette.EXACT, transparency:false})
Copy link to clipboard
Copied
awesome, thanks!