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

How to script a document mode change?

Explorer ,
Jul 31, 2024 Jul 31, 2024

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? 

TOPICS
Actions and scripting , Windows

Views

232

Translate

Translate

Report

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

correct answers 1 Correct answer

LEGEND , Jul 31, 2024 Jul 31, 2024

Specify properties with a name:value pair in brackets as below.

 

srcDoc.changeMode(ChangeMode.INDEXEDCOLOR, {colors:256, palette:Palette.EXACT, transparency:false})

Votes

Translate

Translate
Adobe
LEGEND ,
Jul 31, 2024 Jul 31, 2024

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?

Votes

Translate

Translate

Report

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
Explorer ,
Jul 31, 2024 Jul 31, 2024

Copy link to clipboard

Copied

Zee333_0-1722445561583.png

The document is in RGB mode to start

Votes

Translate

Translate

Report

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
LEGEND ,
Jul 31, 2024 Jul 31, 2024

Copy link to clipboard

Copied

Screenshot 2024-07-31 141751.png

Votes

Translate

Translate

Report

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
Explorer ,
Jul 31, 2024 Jul 31, 2024

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

Votes

Translate

Translate

Report

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
LEGEND ,
Jul 31, 2024 Jul 31, 2024

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})

Votes

Translate

Translate

Report

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
Explorer ,
Jul 31, 2024 Jul 31, 2024

Copy link to clipboard

Copied

LATEST

awesome, thanks!

Votes

Translate

Translate

Report

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