Copy link to clipboard
Copied
I want to be a save png file with a script, in script same file name same folder
Thanks in advance
Copy link to clipboard
Copied
There are many examples in the forum. Do you know how to modify/hack an existing script?
Do you want to use Save As or Export > Save for Web (Legacy)?
What settings?
If the current file was say a JPEG or PSD etc, do you want the current file to remain open by saving a copy, or should the current file now be the PNG?
Do you wish to silently overwrite any existing PNG file with the same name, skip or prompt?
Copy link to clipboard
Copied
I want to use save as and current file is jpg and i want to save png file and close jpeg and jpg remain same in folder and png file will be there as same name and save in same folder which jpg file contains and i dont know how to use javascript
Thanks
Copy link to clipboard
Copied
So you don't need file name and a location to be adequate to script properties. Now you say of other prerequisites. Save below script as 'JPG to PNG.jsx' to 'Presets / Scripts' folder of your Ps. Launch app and when your .jpg is open, choose 'JPG to PNG' from 'File / Scripts' menu:
with(activeDocument) saveAs(fullName, new PNGSaveOptions), close()
Copy link to clipboard
Copied
activeDocument.saveAs(File($.fileName), new PNGSaveOptions)
Copy link to clipboard
Copied
This script uses Save As a Copy:
/*
Save As PNG to Parent Folder
https://community.adobe.com/t5/photoshop-ecosystem-discussions/photoshop-scripting/td-p/12934278
11th May 2022, v1.0 - Stephen Marsh
*/
#target photoshop
if (app.documents.length !== 0) {
// Remove the filename extension
var docName = activeDocument.name.replace(/\.[^\.]+$/, '');
try {
// Use the previously saved directory path
var docPath = activeDocument.path;
} catch (e) {
// If unsaved, prompt for the save path
var docPath = Folder.selectDialog('Unsaved file, select the save directory:');
}
// File Path & Naming
var savePNG = new File(docPath + '/' + docName + '.png');
// Conditional overwrite check
if (savePNG.exists) {
// true = 'No' as default active button
if (!confirm('File exists, overwrite: Yes or No?', true))
// throw alert('Script cancelled!');
throw null;
}
var saveOptions = new PNGSaveOptions();
saveOptions.compression = 0; // 0-9
saveOptions.interlaced = false;
activeDocument.saveAs(savePNG, saveOptions, true, Extension.LOWERCASE);
activeDocument.close(SaveOptions.DONOTSAVECHANGES);
// alert('PNG saved to: ' + '\r' + docPath.fsName);
// docPath.execute();
} else {
alert('You must have a document open!');
}
Instructions for saving/installing/running:
https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html#Photoshop
Copy link to clipboard
Copied
This version uses Export - Save for Web:
/*
Export Save for Web PNG to Parent Folder
https://community.adobe.com/t5/photoshop-ecosystem-discussions/photoshop-scripting/td-p/12934278
11th May 2022, v1.0 - Stephen Marsh
*/
#target photoshop
if (app.documents.length !== 0) {
// Remove the filename extension
var docName = activeDocument.name.replace(/\.[^\.]+$/, '');
try {
// Use the previously saved directory path
var docPath = activeDocument.path;
} catch (e) {
// If unsaved, prompt for the save path
var docPath = Folder.selectDialog('Unsaved file, select the save directory:');
}
// File Path & Naming
var saveForWebPNG = new File(docPath + '/' + docName + '.png');
// Conditional overwrite check
if (saveForWebPNG.exists) {
// true = 'No' as default active button
if (!confirm('File exists, overwrite: Yes or No?', true))
// throw alert('Script cancelled!');
throw null;
}
var pngOptions = new ExportOptionsSaveForWeb();
pngOptions.PNG8 = false;
pngOptions.transparency = true;
pngOptions.interlaced = false;
pngOptions.quality = 100;
pngOptions.includeProfile = true;
pngOptions.format = SaveDocumentType.PNG;
activeDocument.exportDocument(saveForWebPNG, ExportType.SAVEFORWEB, pngOptions);
activeDocument.close(SaveOptions.DONOTSAVECHANGES);
// alert('PNG saved to: ' + '\r' + docPath.fsName);
// docPath.execute();
} else {
alert('You must have a document open!');
}
Copy link to clipboard
Copied
thanku very much its work
Copy link to clipboard
Copied
What about mine? Most likely too short to notice loll
Copy link to clipboard
Copied
Thanks for help i really appreciate to you, you make time for me
Copy link to clipboard
Copied
Thank You. If you find for us a little time mark some replies as correct š
Find more inspiration, events, and resources on the new Adobe Community
Explore Now