Hi!
I have this script that saves a new JPEG in the same folder of the PSD.
And this just works fine.
Then, my boss, asked me to resize the saved jpeg (example: from 1000x1000 to 300x300), without resizing the original document.. and I don't know hot to do that.
My script is executed at the "save" action in photoshop CS4.. so every time the user save his document the JPEG is automatically created.
this is the function (that is pretty famous):
Code: Select allfunction saveJPEG( filename, quality, document ){
var saveFile = new File( filename );
var saveOpt = new JPEGSaveOptions();
saveOpt.embedColorProfile = false;
saveOpt.formatOptions = FormatOptions.STANDARDBASELINE;
saveOpt.matte = MatteType.NONE;
saveOpt.quality = quality;
document.saveAs(saveFile, saveOpt, true );
}
I think I need to create some sort of duplicate of the activeDocument, resize and save that duplicate and then discard the duplicate and return to the original one.. but I'm not sure how to do that.. or even if this is the correct solution..
Save a resized JPG without resizing document (and other bug)
Save a resized JPG without resizing document (and other bug)
I don't think you need to make a dupe. Because you are using the as copy option you could just resize, saveAs copy, then step back one state in the document history to restore the original size. Or if you were going to close the document anyway just resize, saveAs copy, and close without saving.
Save a resized JPG without resizing document (and other bug)
Thanks for your answer..
Can you please tell me how to do the "step back" thing?
I haven't found any reference to the history or undo elements in the javascript reference..
Can you please tell me how to do the "step back" thing?
I haven't found any reference to the history or undo elements in the javascript reference..
Save a resized JPG without resizing document (and other bug)
Sorry for the delay HistoryStates are in the javascript reference but I think it is faster to use Action Manager.
Code: Select allfunction stepBack() {// same as ctrl-alt-z
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID('HstS'), charIDToTypeID('Ordn'), charIDToTypeID('Prvs') );
desc.putReference( charIDToTypeID('null'), ref );
executeAction( charIDToTypeID('slct'), desc, DialogModes.NO );
};
Code: Select allfunction stepBack() {// same as ctrl-alt-z
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID('HstS'), charIDToTypeID('Ordn'), charIDToTypeID('Prvs') );
desc.putReference( charIDToTypeID('null'), ref );
executeAction( charIDToTypeID('slct'), desc, DialogModes.NO );
};