Photoshop CC 2015.5: Script Metadata assigment error

  • 1
  • Problem
  • Updated 6 months ago
  • Not a Problem
  • (Edited)
The  following statement in my script below works in Photoshop version Prior to CC 2015.5 but not in  CC 2015.5 Scripting. 

app.activeDocument.info.instructions = before + after;


The full simple toggle script is here

/* ======================================================================================// 2015  John J. McAssey (JJMack)  http://www.mouseprints.net/
//  
// This script is supplied as is. It is provided as freeware. 
// The author accepts no liability for any problems arising from its use.
//
// This script is designed to Toggle centering guides 
//
// ===================================================================================== */
/*

$$$/JavaScripts/AddRemoveCenterGuides/About=JJMack's AddRemoveCenterGuides.^r^rCopyright 2009 Mouseprints.^r^rRun twice script utility for action.^r^rFirst Run Set Guides on camvas bounds and center.^rSecond Run clears the set guides.
JJMackJJMack's Action Run Twice Utility

*/
if (app.documents.length > 0) app.activeDocument.suspendHistory('ToggleCenterGuides','main()' );
else alert("You must have at least one open document to run this script!"); 
/////////////////////////////////////////////////////////////////////////////////////////// 
function main() {
if (app.activeDocument.info.instructions.indexOf("") == -1 ){ // no footprint fisrt useage 
var orig_ruler_units = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS; // Set the ruler units to PIXELS
try { 
activeDocument.guides.add(Direction.VERTICAL, 0);
activeDocument.guides.add(Direction.VERTICAL, activeDocument.width/4);
activeDocument.guides.add(Direction.VERTICAL, activeDocument.width/2);
activeDocument.guides.add(Direction.VERTICAL, activeDocument.width*3/4);
activeDocument.guides.add(Direction.VERTICAL, activeDocument.width);
activeDocument.guides.add(Direction.HORIZONTAL, 0);
activeDocument.guides.add(Direction.HORIZONTAL, activeDocument.height/4);
activeDocument.guides.add(Direction.HORIZONTAL, activeDocument.height/2);
activeDocument.guides.add(Direction.HORIZONTAL, activeDocument.height*3/4);
activeDocument.guides.add(Direction.HORIZONTAL, activeDocument.height);
  }
// display error message if something goes wrong
catch(e) { alert(e + ': on line ' + e.line, 'Script Error', true); }
app.preferences.rulerUnits = orig_ruler_units; // Reset units to original settings
// put footprint in metadata info instructions
app.activeDocument.info.instructions = app.activeDocument.info.instructions + "" + " Show" + ""; 

else { 
clearGuides();
// Remove footprint from metadata info instructions
before = app.activeDocument.info.instructions.substr(0,app.activeDocument.info.instructions.indexOf(""));
afterOffset = app.activeDocument.info.instructions.indexOf("") + "".length;
after = app.activeDocument.info.instructions.substr(afterOffset, app.activeDocument.info.instructions.length - afterOffset);
//alert ("before = " + before + " after = " + after);
app.activeDocument.info.instructions = before + after;


//////////////////////////////////////////// Action Manager Code to Clear all Guides ///////////////////////////////////
function clearGuides() { 
   var id556 = charIDToTypeID( "Dlt " ); 
       var desc102 = new ActionDescriptor(); 
       var id557 = charIDToTypeID( "null" ); 
           var ref70 = new ActionReference(); 
           var id558 = charIDToTypeID( "Gd  " ); 
           var id559 = charIDToTypeID( "Ordn" ); 
           var id560 = charIDToTypeID( "Al  " ); 
           ref70.putEnumerated( id558, id559, id560 ); 
       desc102.putReference( id557, ref70 ); 
   executeAction( id556, desc102, DialogModes.NO ); 
};
Photo of John McAssey

John McAssey

  • 191 Posts
  • 7 Reply Likes
  • frustrated

Posted 2 years ago

  • 1
Photo of Jeffrey Tranberry

Jeffrey Tranberry, Sr. Product Manager, Digital Imaging

  • 14046 Posts
  • 1735 Reply Likes
Official Response
Hi John, after some investigation, this new behavior is as-designed:

From the engineer: This was an intentional change to better preserve metadata during collisions from other applications:

"The new logic can lead to some cases where the user deleted information in another application and it reappears in Photoshop because it was not deleted in all instances (we have at least one source for the info, but no idea of the intention behind the change). But that is much safer than deleting added information which was intended (deleting a byline, description, or copyright is BAD)."