26 Replies Latest reply on Oct 24, 2011 7:03 PM by StrongBeaver

    Embedding Color Profile into Script ?

    StrongBeaver Level 3

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

        • 1. Re: Embedding Color Profile into Script ?
          JJMack Most Valuable Participant

          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

          • 2. Re: Embedding Color Profile into Script ?
            StrongBeaver Level 3

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

            • 3. Re: Embedding Color Profile into Script ?
              c.pfaffenbichler Level 9

              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?

              • 4. Re: Embedding Color Profile into Script ?
                JJMack Most Valuable Participant

                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?

                • 5. Re: Embedding Color Profile into Script ?
                  StrongBeaver Level 3

                  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.

                  • 6. Re: Embedding Color Profile into Script ?
                    c.pfaffenbichler Level 9

                    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

                    • 7. Re: Embedding Color Profile into Script ?
                      StrongBeaver Level 3

                      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 ?

                      • 8. Re: Embedding Color Profile into Script ?
                        c.pfaffenbichler Level 9

                        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.

                        • 9. Re: Embedding Color Profile into Script ?
                          Michael L Hale Level 5

                          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[i]);
                              }
                              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.

                          • 10. Re: Embedding Color Profile into Script ?
                            StrongBeaver Level 3

                            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. 

                            • 11. Re: Embedding Color Profile into Script ?
                              Michael L Hale Level 5

                              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?

                              • 12. Re: Embedding Color Profile into Script ?
                                StrongBeaver Level 3

                                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 ?

                                • 13. Re: Embedding Color Profile into Script ?
                                  StrongBeaver Level 3

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

                                  • 14. Re: Embedding Color Profile into Script ?
                                    Michael L Hale Level 5

                                    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?

                                    • 15. Re: Embedding Color Profile into Script ?
                                      StrongBeaver Level 3

                                      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[i]);

                                          }

                                          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)

                                      • 16. Re: Embedding Color Profile into Script ?
                                        Michael L Hale Level 5

                                        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.

                                        • 17. Re: Embedding Color Profile into Script ?
                                          StrongBeaver Level 3

                                          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.

                                          • 18. Re: Embedding Color Profile into Script ?
                                            Michael L Hale Level 5

                                            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.

                                            • 19. Re: Embedding Color Profile into Script ?
                                              StrongBeaver Level 3

                                              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.

                                              • 20. Re: Embedding Color Profile into Script ?
                                                Michael L Hale Level 5

                                                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

                                                • 21. Re: Embedding Color Profile into Script ?
                                                  xbytor2 Level 4

                                                  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.

                                                  • 22. Re: Embedding Color Profile into Script ?
                                                    StrongBeaver Level 3

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

                                                    • 23. Re: Embedding Color Profile into Script ?
                                                      xbytor2 Level 4

                                                      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.

                                                      • 24. Re: Embedding Color Profile into Script ?
                                                        StrongBeaver Level 3

                                                        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. 

                                                        • 25. Re: Embedding Color Profile into Script ?
                                                          StrongBeaver Level 3

                                                          Assigning a Color Profile from a Script

                                                           

                                                          The goal is save a custom ICC profile as a script.  Load this profile which is a script , no dependence on manually assigning the profile to the composition, speeding up workflow. Executing the script assigns the color profile to the composition, it does not convert the color profile that remains the same, for now.

                                                           

                                                          Loading and Saving Brushes & Brush ToolSets

                                                           

                                                          When I want to save a Brush or Tool Preset to the script (menu) I am given the option on wheather I want to save the Brush / Tool Set Preset to the location that photoshop would normally save the Brush / Tool Set Preset or to the menu. If the menu is choosen the Brush / Tool Set Preset would appear and a icon representing the Brush or the Tool Set Preset in which the preset was saved with.  Selecting the brush icon you could delete the brush if needed, all the brushes and tool set presets are saved in the script, they are not loaded externally from within a folder they are all saved in the script.  Re-locating or moving the menu to another computer keeps things organized without having to search for the brushes from photoshop and then copy and paste, this makes moving the custom photoshop workflow to another computer painless and your desired brushes and tool presets follow you no worry of loss if PC failure / photoshop re-install etc.

                                                           

                                                          I want to make this all a reality, if there are things that may have to be changed or routed differently please explain so it can be compleated, as I look forward to it.

                                                          • 26. Re: Embedding Color Profile into Script ?
                                                            StrongBeaver Level 3

                                                            Can I get help getting both of these completed within a week as I need to complete my menu.