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

Embedding Color Profile into Script ?

Advocate ,
Oct 02, 2011 Oct 02, 2011

Copy link to clipboard

Copied

I want to embedded a color profile into a script and run the script would change the color profile.

TOPICS
Actions and scripting

Views

6.2K

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 ,
Oct 02, 2011 Oct 02, 2011

Copy link to clipboard

Copied

From the Photoshop  javascript  manual

convertProfile (destinationProfile, intent [, blackPointCompensation] [, dither])

string

Intent

boolean

boolean

Changes the color profile.

The destinationProfile parameter must

be either a string that names the color

mode or Working RGB, Working CMYK,

Working Gray, Lab Color (meaning one

of the working color spaces or Lab color).

Intent

ABSOLUTECOLORIMETRIC

PERCEPTUAL

RELATIVECOLORIMETRIC

SATURATION

The rendering intent to use when

converting from one color space to

another with

Document.convertProfile() or

JJMack

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
Advocate ,
Oct 02, 2011 Oct 02, 2011

Copy link to clipboard

Copied

I don't follow completely.  If you can embedded profiles how come you can't embedded brushes / tool presets ?

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
Community Expert ,
Oct 02, 2011 Oct 02, 2011

Copy link to clipboard

Copied

Just to make sure, are you trying to convert an image to a pofile that is installed on the computer or do you want to include a profile in a Script so that it would also work on stations that do not have that profile installed before running the Script?

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 ,
Oct 03, 2011 Oct 03, 2011

Copy link to clipboard

Copied

StrongBeaver wrote:

I don't follow completely.  If you can embedded profiles how come you can't embedded brushes / tool presets ?

Pleas explaine what you mean when you write "embedded profiles" what I wrote was how to convert a document to a profile. All I know about embedded color profile and scripting has to do with saving files with color profile and adding new document with a color profile.  I'm sure you can select a tool preset what do you mean by "embedded brushes". Are you trying to create a brush or brush preset?

JJMack

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
Advocate ,
Oct 03, 2011 Oct 03, 2011

Copy link to clipboard

Copied

Just to make sure, are you trying to convert an image to a pofile that is installed on the computer or do you want to include a profile in a Script so that it would also work on stations that do not have that profile installed before running the Script?

I want to include a profile in a script so it will also work on stations that do not have the profile installed.

Pleas explaine what you mean when you write "embedded profiles" what I wrote was how to convert a document to a profile. All I know about embedded color profile and scripting has to do with saving files with color profile and adding new document with a color profile.  I'm sure you can select a tool preset what do you mean by "embedded brushes". Are you trying to create a brush or brush preset?

I want to have a script that has brushes ABR and Tool Presets embedded into a script, without having to call them from a external folder if this is possible, or if it's possible to save brushes and tool presets directly to a script and view the brushes and tool presets as you can in photoshop in a external menu ? I hope I was clear.

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
Community Expert ,
Oct 03, 2011 Oct 03, 2011

Copy link to clipboard

Copied

I can’t remember who of the usual suspects helped me back then, but it involved some of xbytor’s code, so with some heavy help I have been able to include a Pattern in a Script by creating a string from the hex-data derived from the binary (and don’t even ask what that means), but that created a .pat-file which could then be laoded via Script.

So quite possibly you could do the same with abr- or icc-files, but naturally the Scripts would be larger than those original files and not exactly sleek.

It would probably be easier to just check if the icc-profile is installed and prompt a warning if it is missing.

Edit: It was Paul Riggott, xbytor and Michael L Hale that helped me back then.

http://forums.adobe.com/message/3171749#3171749

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
Advocate ,
Oct 03, 2011 Oct 03, 2011

Copy link to clipboard

Copied

It would be nice if they came forward again to help with this problem

What about if the ICC profile is attached with the configurator custom layout in a folder, I still prefer to have it as a script. The same for ABR files, anyone else can contribute ?

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
Community Expert ,
Oct 03, 2011 Oct 03, 2011

Copy link to clipboard

Copied

One thing to consider here is that including a lot of data in the Script (that may not be necessary if the preset, profile etc. has been created once) might be a drag on the Scripts performance.

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
Guru ,
Oct 03, 2011 Oct 03, 2011

Copy link to clipboard

Copied

Embedding binary data in a script is not too hard. It just needs a little prep work.

// first read the files you want to embed in your script( not part of the final script )

File.prototype.readByte = function() {// file functions adapted from Xbytor

  return this.read(1).charCodeAt(0);

};   

var file = new File("~/desktop/test.atn");

    var arr = new Array

    file.open("r");

    file.encoding = 'BINARY';

    file.seek(0, 0);

    for(i=0;i<file.length;i++){

    arr.push(file.readByte());

    }

    $.writeln(arr);// write to console

    file.close();

// now in your final script include this function

File.prototype.writeByte = function(b) {

  file.write(String.fromCharCode(b));

};

// and create an array from the data in the console

var atnArr = [0,0,0,16,0,0,0,5,0,116,0,101,0,115,0,116,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,9,0,65,0,99,0,116,0,105,0,111,0,110,0,32,0,50,0,0,1,0,0,0,1,0,1,0,2,84,69,88,84,0,0,0,14,109,101,114,103,101,76,97,121,101,114,115,78,101,119,0,0,0,12,77,101,114,103,101,32,76,97,121,101,114,115,255,255,255,255,0,0,0,1,0,0,0,0,0,0,110,117,108,108,0,0,0,0];

// then in your script write the file to disk

var file = new File(Folder.temp+"/test.atn");

    file.open("w");

    file.encoding = 'BINARY';

    file.seek(0, 0);

    for(i=0;i<tag.length;i++){

    file.writeByte(tag);

    }

    file.close();

   

// then load the file if it is an action, pattren, brush, preset, etc

app.load(file);

Note for profiles, if you want to be cross platform, you will have to work out where to write the files so the OS and Photoshop can use it. You do not use app.load for profiles.

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
Advocate ,
Oct 03, 2011 Oct 03, 2011

Copy link to clipboard

Copied

I will be assigning the script to two buttons one which will switch Adobe RGB(1998) which probably won't require the CSF custom profile to be embedded in a script. And a custom CSF profile, that I created. 

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
Guru ,
Oct 03, 2011 Oct 03, 2011

Copy link to clipboard

Copied

No, the script I posted was an example of how to embed binary data in a script. You can use it to embed your custom profile. But for it to be available to Photoshop you will have to write the file where the OS stores profiles. All you need to do is write the embeded profile to that folder. You don't load it like you can with actions, brushes, etc.

But perhaps I don't fully understand what you want to do. I'm not sure what you mean by 'calling it from a script'. Do you mean assigning or converting the activeDocument's profile?

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
Advocate ,
Oct 03, 2011 Oct 03, 2011

Copy link to clipboard

Copied

I have a custom panel button that when triggered loads the Adobe RGB (1998) profile and I have another custom CSF profile that I created. From my knowledge there probably won't be a need to assign the Adobe RGB profile into a script, rather tell the script to switch to that profile since all versions of Adobe have this profile.  The custom CSF profile I want embedded into the script, when I click the button it assigns that profile, clicking the other button assigns the Adobe RGB profile.

Do you know how I could save Custom Brushes and Tool Presets to a Script and load them from the script with a preview in a panel window ? If that is possible ?

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
Advocate ,
Oct 21, 2011 Oct 21, 2011

Copy link to clipboard

Copied

The script contains no problems, but it's not doing what it should be doing, I'm back at square one. ?

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
Guru ,
Oct 21, 2011 Oct 21, 2011

Copy link to clipboard

Copied

Can you post your script. The only code in this thread is a couple of snippets that show how to embed a binary file in a script. It's hard to say why way a script is not doing doing what it should without seeing the script in question.

What is not being done that you think it should be doing?

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
Advocate ,
Oct 21, 2011 Oct 21, 2011

Copy link to clipboard

Copied

File.prototype.writeByte = function(b) {

    file.write(String.fromCharCode(b));

    };

var profileArrayTextureBase = ["0,0,1,248,65,68,66,69,2,16,0,0,109,110,116,114,82,71,66,32,88,89,90 ,32,7,218,0,8,0,19,0,21,0,47,0,14,97,99,115,112,65,80,80,76,0,0,0,0,1 1 0,111,110,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,246,214,0,1,0,0,0,0 , 211,44,65,68,66,69,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0 ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9,99,112,114,116,0,0,0,240 , 0,0,0,50,100,101,115,99,0,0,1,36,0,0,0,114,119,116,112,116,0,0,1,152, 0 ,0,0,20,114,88,89,90,0,0,1,172,0,0,0,20,103,88,89,90,0,0,1,192,0,0,0, 2 0,98,88,89,90,0,0,1,212,0,0,0,20,114,84,82,67,0,0,1,232,0,0,0,14,103, 8 4,82,67,0,0,1,232,0,0,0,14,98,84,82,67,0,0,1,232,0,0,0,14,116,101,120 , 116,0,0,0,0,67,111,112,121,114,105,103,104,116,32,50,48,49,48,32,65,1 0 0,111,98,101,32,83,121,115,116,101,109,115,32,73,110,99,111,114,112,1 1 1,114,97,116,101,100,0,0,0,100,101,115,99,0,0,0,0,0,0,0,24,51,68,32,8 4 ,101,120,116,117,114,101,32,67,111,108,111,117,114,32,83,112,97,99,10 1 ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0 ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0 ,0,0,0,0,0,0,0,0,0,0,0,88,89,90,32,0,0,0,0,0,0,243,82,0,1,0,0,0,1,22, 2 04,88,89,90,32,0,0,0,0,0,0,156,24,0,0,79,165,0,0,4,252,88,89,90,32,0, 0 ,0,0,0,0,52,141,0,0,160,44,0,0,15,149,88,89,90,32,0,0,0,0,0,0,38,49,0 , 0,16,47,0,0,190,155,99,117,114,118,0,0,0,0,0,0,0,1,1,0,0,0"]

var file = new File("/C/WINDOWS/system32/spool/drivers/color/texturebase.icc");

    file.open("w");

    file.encoding = 'BINARY';

    file.seek(0, 0);

    for(i=0;i<profileArrayTextureBase.length;i++){

    file.writeByte(profileArrayTextureBase);

    }

    file.close();

I want the script to assign the color profile to the composition, the effect is similar to saturating a color. It's writting the color space to Gamma 1.0 (Linear)

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
Guru ,
Oct 21, 2011 Oct 21, 2011

Copy link to clipboard

Copied

The scripting DOM does not have a method to assign a profile. It only has one to convert. To assign you will need to use scriptlistener or an action.

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
Advocate ,
Oct 21, 2011 Oct 21, 2011

Copy link to clipboard

Copied

What was the script I posted purpose ? To Convert, if so I should have seen a visual different on my composition.

Back to the drawing board and run script listener to call up the profile, arrrghhh.

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
Guru ,
Oct 22, 2011 Oct 22, 2011

Copy link to clipboard

Copied

The purpose of the script is to embed a binary file in a script so that it can be distributed with the script and used on systems that do not have the embedded file. That is what you requested. All the script you posted does is write a file from the embedded data.

Looking at the guide, I was wrong when I said you need scriptlistener. You should be able to assign a profile by setting the document's colorProfileType and colorProfileName properties.

Also converting an image to a different profile does not always change the visual appearance of the image.

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
Advocate ,
Oct 22, 2011 Oct 22, 2011

Copy link to clipboard

Copied

I ran a simple script that assigned the color profile to the composition, and it worked.  That is exactly what I want only embedded into a script.  When I click the custom menu button the color profile is not read from photoshop but from the script.

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
Guru ,
Oct 22, 2011 Oct 22, 2011

Copy link to clipboard

Copied

I'm not sure what you are tying to do. Photoshop can not use the profile directly from the script. The profile would need to be saved in a folder where Photoshop know profiles are stored on the system before it can be used by Photoshop.

So save the profile from the embedded data if it doesn't already exists on the user's system then assign the profile.

app.activeDocument.colorProfileName = 'yourCustomProfileName';// note assigns a new profile to the document

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
Advisor ,
Oct 22, 2011 Oct 22, 2011

Copy link to clipboard

Copied

What's interesting is that if SB needed to Convert instead of Assign, you could create the custom profile in PS and get tasty SL Code:

//

// Generated from /private/var/folders/T5/T5GFAtoEFAGxisHIXg0rMU+++TI/-Tmp-/TemporaryItems/tmp00000001 on Sat Oct 22 2011 14:26:18 GMT-0500

//

function ftn1() {

  function cTID(s) { return app.charIDToTypeID(s); };

  function sTID(s) { return app.stringIDToTypeID(s); };

    var desc6 = new ActionDescriptor();

        var ref5 = new ActionReference();

        ref5.putEnumerated( cTID('Dcmn'), cTID('Ordn'), cTID('Trgt') );

    desc6.putReference( cTID('null'), ref5 );

    desc6.putData( cTID('T   '), String.fromCharCode( 0, 0, 1, 236, 65, 68, 66, 69, 2, 16, 0, 0, 109, 110, 116, 114, 82, 71, 66, 32, 88, 89, 90, 32, 7, 219, 0, 10, 0, 22, 0, 19,

0, 25, 0, 58, 97, 99, 115, 112, 65, 80, 80, 76, 0, 0, 0, 0, 110, 111, 110, 101, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

0, 0, 0, 1, 0, 0, 246, 214, 0, 1, 0, 0, 0, 0, 211, 44, 65, 68, 66, 69, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

0, 0, 0, 9, 99, 112, 114, 116, 0, 0, 0, 240, 0, 0, 0, 50, 100, 101, 115, 99, 0, 0, 1, 36, 0, 0, 0, 101, 119, 116, 112, 116,

0, 0, 1, 140, 0, 0, 0, 20, 114, 88, 89, 90, 0, 0, 1, 160, 0, 0, 0, 20, 103, 88, 89, 90, 0, 0, 1, 180, 0, 0, 0, 20,

98, 88, 89, 90, 0, 0, 1, 200, 0, 0, 0, 20, 114, 84, 82, 67, 0, 0, 1, 220, 0, 0, 0, 14, 103, 84, 82, 67, 0, 0, 1, 220,

0, 0, 0, 14, 98, 84, 82, 67, 0, 0, 1, 220, 0, 0, 0, 14, 116, 101, 120, 116, 0, 0, 0, 0, 67, 111, 112, 121, 114, 105, 103, 104,

116, 32, 50, 48, 49, 49, 32, 65, 100, 111, 98, 101, 32, 83, 121, 115, 116, 101, 109, 115, 32, 73, 110, 99, 111, 114, 112, 111, 114, 97, 116, 101,

100, 0, 0, 0, 100, 101, 115, 99, 0, 0, 0, 0, 0, 0, 0, 11, 67, 117, 115, 116, 111, 109, 32, 82, 71, 66, 0, 0, 0, 0, 0, 0,

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 88, 89, 90, 32, 0, 0, 0, 0, 0, 0, 235, 194, 0, 1, 0, 0, 0, 1, 65, 50,

88, 89, 90, 32, 0, 0, 0, 0, 0, 0, 97, 15, 0, 0, 36, 77, 255, 255, 255, 232, 88, 89, 90, 32, 0, 0, 0, 0, 0, 0, 103, 37,

0, 0, 220, 208, 0, 0, 5, 29, 88, 89, 90, 32, 0, 0, 0, 0, 0, 0, 46, 162, 255, 255, 254, 227, 0, 0, 206, 39, 99, 117, 114, 118,

0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0 ) );

    desc6.putEnumerated( cTID('Inte'), cTID('Inte'), cTID('Clrm') );

    desc6.putBoolean( cTID('MpBl'), true );

    desc6.putBoolean( cTID('Dthr'), false );

    desc6.putInteger( cTID('sdwM'), 2 );

    executeAction( sTID('convertToProfile'), desc6, DialogModes.NO );

};

This may lead to a way of Assigning a custom profile, but I doubt it.

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
Advocate ,
Oct 22, 2011 Oct 22, 2011

Copy link to clipboard

Copied

I have the custom profile created.  Script Listener could pull the code nessessary ?

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
Advisor ,
Oct 22, 2011 Oct 22, 2011

Copy link to clipboard

Copied

StrongBeaver wrote:

I have the custom profile created.  Script Listener could pull the code nessessary ?

There may be a way to assign a custom profile using SL code, but I don't know what it would be.

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
Advocate ,
Oct 22, 2011 Oct 22, 2011

Copy link to clipboard

Copied

What about converting a profile to a script then calling the script, which would assign the profile via a button in a script ?

I'm going to follow up with a full explination and with saving brushes incase I've been vague everyone will understand and hopefully we can work towards completing the goal. 

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