What's new
Photoshop Gurus Forum

Welcome to Photoshop Gurus forum. Register a free account today to become a member! It's completely free. Once signed in, you'll enjoy an ad-free experience and be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Reply to thread

How about a script?


copy this script to your scripts folder (extension should be *.jsx)


If "saving as a PNG" is the only function you want to include in your action, you can also assign a shortcut to your script.


You can also integrate the script into your action.


[CODE=javascript]#target photoshop


(function () {

    if (app.documents.length === 0) {

        alert("No document open.");

        return;

    }


    var doc = app.activeDocument;


    // Derive file name and target path

    var nameNoExt = doc.name.replace(/\.[^\.]+$/, ""); // remove extension

    var extension = doc.name.split('.').pop().toLowerCase();

    if (extension === "png") {

        alert("This document is already a PNG. Saving would overwrite the original. Operation cancelled.");

        return;

    }


    var targetFolder = doc.fullName.parent;

    var targetFile = new File(targetFolder + "/" + nameNoExt + ".png");


    // Overwrite if it already exists

    if (targetFile.exists) {

        try {

            targetFile.remove();

        } catch (e) {

            alert("Failed to remove existing file:\n" + e);

            return;

        }

    }


    // PNG save options – moderate optimization (compression 6 of 0–9)

    var pngOpts = new PNGSaveOptions();

    pngOpts.compression = 6;          // 0 (none) … 9 (max) – 6 ≈ moderate

    pngOpts.interlaced  = false;      // no interlacing

    // Make sure profile is NOT embedded

    if (pngOpts.hasOwnProperty('embedColorProfile')) {

        pngOpts.embedColorProfile = false;

    }


    // Save with lower‑case extension

    doc.saveAs(targetFile, pngOpts, true /*asCopy*/, Extension.LOWERCASE);


    // Done

})();[/CODE]


What is our favorite program/app? (Hint - it begins and ends with the letter P)
Back
Top