0

I have the following script that saves a copy of my current document as a JPG to the desktop, however I cannot get it to embed the colour profile. Does anyone know how to do that?

var JPGquality = 12;
var docPath = '/Users/cristianmoisei/Desktop/';
var docName = app.activeDocument.name.replace(/\.[^\.]+$/, '');;

var saveFile = new File(docPath + '/' + docName + '.jpg');

var fileExists = saveFile.exists;
var tries = 1;
while (fileExists) {
  saveFile = new File(docPath + '/' + docName + ('-' + tries) + '.jpg');
  tries++;
  fileExists = saveFile.exists;
  jpgSaveOptions.embedColorProfile = true;
}

SaveJPEG(saveFile, JPGquality);

function SaveJPEG(saveFile, jpegQuality) {
  jpgSaveOptions = new JPEGSaveOptions();
  jpgSaveOptions.embedColorProfile = true;
  jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
  jpgSaveOptions.matte = MatteType.NONE;
  jpgSaveOptions.quality = jpegQuality; //1-12
  activeDocument.saveAs(saveFile, jpgSaveOptions, true, Extension.LOWERCASE);
}
0

Now it works, I just delete the first jpgSaveOptions.embedColorProfile = true;

var JPGquality = 12;
var docPath = '/Users/cristianmoisei/Desktop/';
var docName = app.activeDocument.name.replace(/\.[^\.]+$/, '');;

var saveFile = new File(docPath + '/' + docName + '.jpg');

var fileExists = saveFile.exists;
var tries = 1;
while (fileExists) {
  saveFile = new File(docPath + '/' + docName + ('-' + tries) + '.jpg');
tries++;
fileExists = saveFile.exists;
}

SaveJPEG(saveFile, JPGquality);

function SaveJPEG(saveFile, jpegQuality) {
  jpgSaveOptions = new JPEGSaveOptions();
  jpgSaveOptions.embedColorProfile = true;
  jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
  jpgSaveOptions.matte = MatteType.NONE;
  jpgSaveOptions.quality = jpegQuality; //1-12
  activeDocument.saveAs(saveFile, jpgSaveOptions, true, Extension.LOWERCASE);
}

Here is my process:

  • Having a jpg with Adobe RGB (1998) profile
  • Change it to Don't Color Manage This Document
  • Save the file
  • Play the script
  • When opening the duplicate file, the profile is Don't Color Manage This Document

enter image description here

This is another script to try (source feedback.photoshop.com/photoshop_family):

//Duplicate doc
var doc = app.activeDocument
var fname = doc.name.split(".")
var fname = fname[0]
//var newDoc = doc.duplicate(fname) // This caused active document to be in an 
unsaved state and have no document path
//save part
if (app.documents.length > 0) {
  var thedoc = app.activeDocument;
  var docName = thedoc.name;
  if (docName.indexOf(".") != -1) {
    var basename = docName.match(/(.*)\.[^\.]+$/)[1];
  } else {
    var basename = docName;
  }
  //getting the location, if unsaved save to desktop;
  try {
    var docPath = doc.path;
  } catch (e) {
    var docPath = "~/Desktop";
  }
var docFolder = Folder( doc.path  );
var newFolder = Folder( docFolder.parent + '/' + "02 - web");
    // create folder if missing
    if (!newFolder.exists) {
        $.writeln("Creating new folder: " + newFolder.fsName)
        try {
            if( newFolder.create() === false )
            {
                alert( "error:copyDir:error creating directory         "+newFolder.fsName);
            }
        } catch (e) {
            alert( "error:copyDir:error creating directory "+newFolder.fsName+":"+ e.message);
        }
    }

  var jpegOptions = new JPEGSaveOptions();
  jpegOptions.quality = 12;
  jpegOptions.embedColorProfile = true;
  jpegOptions.matte = MatteType.NONE;
  var filename = newFolder + '/' + basename + '.jpg';
    $.writeln(filename);
  thedoc.saveAs((new File(filename)), jpegOptions, true);
}; 
  • Oh, apologies, I pasted a version where I was trying to get it work. The script does work, but it doesn't embed the colour profile. My JPGs get saved without a colour profile. Any idea how to fix that? – CristianMoisei Jul 8 '18 at 21:03
  • The script of my answer works, I already try it and embed the color profile – user120647 Jul 8 '18 at 21:11
  • Hm, maybe I'm doing something wrong. I ran it as you suggested (as I had it before) and it doesn't embed the colour profile. (look at the red of the button): dropbox.com/s/a8enie1qe6ou8rj/… If I do a Save As and tick the box for including the colour profile, it then works. dropbox.com/s/phop3frfxc18dxf/… I've uploaded the two images here: dropbox.com/sh/jmopg807k025p71/AAB6kTm7qVh7YrST9WVYbjKWa?dl=0 – CristianMoisei Jul 8 '18 at 21:26
  • I add an animation with the procces – user120647 Jul 8 '18 at 21:50
  • So if I open the file in Photoshop after following the steps you suggested, it has the same colour profile (it could be that it assigns a colour profile when it opens a file). But if I open the file in any other program (Preview, Email) it won't be accurate. And the problem is that it is accurate everywhere if I do File > Save As > Embed colour profile ticked. Here's a video of what I mean: dropbox.com/s/wg81qylhz58w5pw/example.mov?dl=0 So is there any way to replicate that tickbox in the script? Maybe I just don't understand colour management well enough and I'm missing something. – CristianMoisei Jul 9 '18 at 9:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.