Suppress Color Profile warnings

Discussion of Photoshop Scripting, Photoshop Actions and Photoshop Automation in General

Moderators: Tom, Kukurykus

undavide

Suppress Color Profile warnings

Post by undavide »

Hello,
in a script I've the need to open a variable number of files.
Is there a way to suppress color profile warning (missing profile / profile different from working ICC) overriding the preferences in the color settings?
I've seen there's a suppressProfile boolean property, but that's for Application.batch() and I don't have actions to run (unless I put in there a dummy action with nothing on it, but it doesn't look like a viable solution).
Thank you!

Davide Barranca
http://www.davidebarranca.com
undavide

Suppress Color Profile warnings

Post by undavide »

I've put together this one, still have to test it.
(UPDATE: restoreProfileWarnings() is broken)

Code: Select all/*
 * Usage:
 * userProfileWarnings = storeProfileWarnings() // as ActionDescriptor
 * suppressProfileWarnings()
 * Open files..
 * restoreProfileWarnings(userProfileWarnings)
*/

var restoreProfileWarnings, storeProfileWarnings, suppressProfileWarnings;

storeProfileWarnings = function() {
  var d, r, s2t;
  s2t = function(s) {
    return app.stringIDToTypeID(s);
  };
  d = new ActionDescriptor();
  r = new ActionReference();
  r.putProperty(s2t('property'), s2t('colorSettings'));
  r.putEnumerated(s2t('application'), s2t('ordinal'), s2t('targetEnum'));
  return d = executeActionGet(r);
};

restoreProfileWarnings = function(colorSettingsDescriptor) {
  var d, r, s2t;
  s2t = function(s) {
    return app.stringIDToTypeID(s);
  };
  d = new ActionDescriptor();
  r = new ActionReference();
  d.putObject(s2t('to'), s2t('colorSettings'), colorSettingsDescriptor);
  return executeAction(s2t('set'), d, DialogModes.NO);
};

suppressProfileWarnings = function() {
  var d, d2, r, s2t;
  s2t = function(s) {
    return app.stringIDToTypeID(s);
  };
  d = new ActionDescriptor();
  r = new ActionReference();
  r.putProperty(s2t('property'), s2t('colorSettings'));
  r.putEnumerated(s2t('application'), s2t('ordinal'), s2t('targetEnum'));
  d.putReference(s2t('target'), r);
  d2 = new ActionDescriptor();
  d2.putBoolean(s2t('askMismatchOpening'), false);
  d2.putBoolean(s2t('askMissing'), false);
  d.putObject(s2t('to'), s2t('colorSettings'), d2);
  return executeAction(s2t('set'), d, DialogModes.NO);
};

Davide Barranca
http://www.davidebarranca.com
undavide

Suppress Color Profile warnings

Post by undavide »

Got a working version, but only setting the two descriptor keys I'm interested into from the stored desc.
I haven't been able to restore the entire 'colorSettings' descriptor that I stored previously, for some reason - still a bit unsatisfied because of that!

Code: Select allvar restoreProfileWarnings, storeProfileWarnings, suppressProfileWarnings;

storeProfileWarnings = function() {
  var d, r, s2t;
  s2t = function(s) {
    return app.stringIDToTypeID(s);
  };
  d = new ActionDescriptor();
  r = new ActionReference();
  r.putProperty(s2t('property'), s2t('colorSettings'));
  r.putEnumerated(s2t('application'), s2t('ordinal'), s2t('targetEnum'));
  return d = executeActionGet(r);
};

restoreProfileWarnings = function(colorSettingsDescriptor) {
  var askMismatchOpening, askMissing, d, d2, r, s2t;
  s2t = function(s) {
    return app.stringIDToTypeID(s);
  };
  d = new ActionDescriptor();
  r = new ActionReference();
  r.putProperty(s2t('property'), s2t('colorSettings'));
  r.putEnumerated(s2t('application'), s2t('ordinal'), s2t('targetEnum'));
  d.putReference(s2t('target'), r);
  d2 = new ActionDescriptor();
  askMismatchOpening = colorSettingsDescriptor.getObjectValue(colorSettingsDescriptor.getKey(0)).getBoolean(s2t('askMismatchOpening'));
  d2.putBoolean(s2t('askMismatchOpening'), askMismatchOpening);
  askMissing = colorSettingsDescriptor.getObjectValue(colorSettingsDescriptor.getKey(0)).getBoolean(s2t('askMissing'));
  d2.putBoolean(s2t('askMissing'), askMissing);
  d.putObject(s2t('to'), s2t('colorSettings'), d2);
  return executeAction(s2t('set'), d, DialogModes.NO);
};

suppressProfileWarnings = function() {
  var d, d2, r, s2t;
  s2t = function(s) {
    return app.stringIDToTypeID(s);
  };
  d = new ActionDescriptor();
  r = new ActionReference();
  r.putProperty(s2t('property'), s2t('colorSettings'));
  r.putEnumerated(s2t('application'), s2t('ordinal'), s2t('targetEnum'));
  d.putReference(s2t('target'), r);
  d2 = new ActionDescriptor();
  d2.putBoolean(s2t('askMismatchOpening'), false);
  d2.putBoolean(s2t('askMissing'), false);
  d.putObject(s2t('to'), s2t('colorSettings'), d2);
  return executeAction(s2t('set'), d, DialogModes.NO);
};

Anyway it does the job.

Davide