convertProfile() and referring to Working Color Spaces

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

poopsmcgee

convertProfile() and referring to Working Color Spaces

Post by poopsmcgee »

Hi everyone,

I'm trying to utilize convertProfile in a script. So far it's been great, I haven't had any issues (including dealing with the Adobe (1998) RGB profile).

But for some reason I've found "Gray Gamma 1.8" to be a bit trickier than the others. Like the adobe 1998 profile, it seems calling this profile by the full name of the .icc file isn't working. But I've even busted out the script listener which outputted this:
Code: Select all// =======================================================
var idconvertToProfile = stringIDToTypeID( "convertToProfile" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idDcmn = charIDToTypeID( "Dcmn" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref2.putEnumerated( idDcmn, idOrdn, idTrgt );
    desc4.putReference( idnull, ref2 );
    var idT = charIDToTypeID( "T   " );
    desc4.putString( idT, """Gray Gamma 1.8""" );
    var idInte = charIDToTypeID( "Inte" );
    var idInte = charIDToTypeID( "Inte" );
    var idClrm = charIDToTypeID( "Clrm" );
    desc4.putEnumerated( idInte, idInte, idClrm );
    var idMpBl = charIDToTypeID( "MpBl" );
    desc4.putBoolean( idMpBl, true );
    var idDthr = charIDToTypeID( "Dthr" );
    desc4.putBoolean( idDthr, false );
    var idsdwM = charIDToTypeID( "sdwM" );
    desc4.putInteger( idsdwM, -1 );
executeAction( idconvertToProfile, desc4, DialogModes.NO );


But I've adjusted me script to this and I still have no luck!

Code: Select alldocRef.convertProfile("""Gray Gamma 1.8""", Intent.RELATIVECOLORIMETRIC)

I know this has to be something a bit foolishly obvious... but what am I missing exactly? When I run my script it doesn't change any profiles.

I've tried extracting the profiles post photoshop, and using any other string I can find related to "Gray Gamma 1.8" but none of them seem to work. Perhaps someone else has been here before?
poopsmcgee

convertProfile() and referring to Working Color Spaces

Post by poopsmcgee »

Maybe I'm just being retarded. I figured at worst I can set Gray Gamma to be the working gray for photoshop.

But according to the CS6 JS reference I should be calling something like:

docRef.convertProfile('Working Gray', Intent.RELATIVECOLORIMETRIC, true, false);
or
docRef.convertProfile('Working RGB', Intent.RELATIVECOLORIMETRIC, true, false)

depending on my profile preference. This has been failing for me - anyone know the correct way to reference the Working Space?
xbytor

convertProfile() and referring to Working Color Spaces

Post by xbytor »

Here's a bit of code that determines the current Working Gray profile. You may find it helpful.
Code: Select allfunction getWorkingGrayProfile() {
  function cTID(s) { return app.charIDToTypeID(s); };
  function sTID(s) { return app.stringIDToTypeID(s); };

  var ref = new ActionReference();
  ref.putProperty(cTID("Prpr"), sTID("colorSettings"));
  ref.putEnumerated(cTID("capp"), cTID("Ordn"), cTID("Trgt") );
  var desc = executeActionGet(ref);

  var settings = desc.getObjectValue(sTID("colorSettings"));
  var profile = settings.getString(sTID("workingGray"));

  return profile;
};
poopsmcgee

convertProfile() and referring to Working Color Spaces

Post by poopsmcgee »

Indeed I think I will. Thanks!
poopsmcgee

convertProfile() and referring to Working Color Spaces

Post by poopsmcgee »

So this is fairly embarrassing, but after some review I realized my problem had nothing to do with calling the gray scale profile, but the button variable name being re-written by a different button in a different section of the code. I was adding a new profile to an already existing script, so I hadn't left myself much namespace.

I only mention it in case anyone ever stumbles into this thread with a similar problem. Utilizing xbytor's code definitely works, but so does "Working Gray" or using the name "Gray Gamma 1.8" - which is exactly what xbytors code returns (in my setup). Why I never realized any of this while staring at my code is of course unfortunate, but comes with the territory.

Cheers, y'all