0

I'm using a plugin to export my pngs (https://www.fnordware.com/superpng/) Anyone knows how I can replicate the Export Layers to files functionality that comes with photoshop but export as SuperPNG?

There is export options documentation but only includes the default photoshop formats...

Thanks in advance!

  • I think there might not be a lot of demand for that when there are so many standalone applications for image compression. I often use ImageOptim. It's a little manual (1 more step in the workflow) but for a lot of things, it doesn't really matter. I don't know where you're using the images, but it may also be possible for you to automatically compress on build or whatever. – Joonas Jan 30 at 8:20
0

Here's the script I use to save quantified pngs (it uses SuperPNG plugin you mentioned). There're some options in there that I didn't test (with // ??) but by default it saves a png with max quality and transparency. It also checks if you have SuperPNG installed.

exportSuperPng(
{
    path: "/C/Users/Sergey Kritskiy/Desktop/temp", // required
    name: "test-png", // default: document name
    quality: 100, // default: 100 (Highest) 82 is High
    transparency: true, // default: true
})

function exportSuperPng(data)
{
    if (data == void(0)) return false;
    if (data.path == void(0)) return false;
    if (data.quality == void(0)) data.quality = 100;
    if (data.name == void(0)) data.name = activeDocument.name;
    if (data.transparency == void(0)) data.transparency = true;
    if (!getSuperPngInfo()) return false;

    var desc = new ActionDescriptor();
    var descSPng = new ActionDescriptor();
    descSPng.putInteger(charIDToTypeID('pngC'), 9); // ??
    descSPng.putInteger(charIDToTypeID('pngF'), 248); // ??
    descSPng.putInteger(charIDToTypeID('pngS'), 0); // ??
    descSPng.putBoolean(charIDToTypeID('pngQ'), true); // ??
    descSPng.putInteger(charIDToTypeID('pngq'), data.quality); // quality
    descSPng.putEnumerated(charIDToTypeID('pngA'), charIDToTypeID('alfT'), data.transparency ? charIDToTypeID('alfT') : charIDToTypeID('alfN'));
    descSPng.putBoolean(charIDToTypeID('pngX'), false);
    descSPng.putBoolean(charIDToTypeID('pngI'), false); // ??
    descSPng.putBoolean(charIDToTypeID('pngM'), false); // ??
    desc.putObject(charIDToTypeID('As  '), stringIDToTypeID('fnord SuperPNG'), descSPng);
    desc.putPath(charIDToTypeID('In  '), new File(data.path + "/" + data.name + ".png"));
    desc.putInteger(charIDToTypeID('DocI'), 475);
    desc.putEnumerated(stringIDToTypeID('saveStage'), stringIDToTypeID('saveStageType'), stringIDToTypeID('saveSucceeded'));
    executeAction(charIDToTypeID('save'), desc, DialogModes.NO);

    function getSuperPngInfo()
    {
        var sysInfo = app.systemInformation.split("\n");
        for (var i = sysInfo.length - 1; i >= 0; i--)
        {
            if (sysInfo[i].indexOf('SuperPNG') != -1)
            {
                return true
            }
        }
        return false
    }
};
  • Thanks this really helped me! – Andreia Jan 30 at 18:52
0

Leaving it here with extra options if anyone needs

exportSuperPng(
{
    path: Folder.desktop, // required
    name: "test-png", // default: document name
    quality: 100, // default: 100 (Highest) 82 is High
    transparency: true, // default: true
    saveMetadata: false,
    cleantransparent:true,
    pInterlacted:false
})

function exportSuperPng(data, path, name)
{
    data.path = path;
    data.name = name;

    if (data == void(0)) return false;
    if (data.path == void(0)) return false;
    if (data.quality == void(0)) data.quality = 100;
    if (data.name == void(0)) data.name = activeDocument.name;
    if (data.transparency == void(0)) data.transparency = true;
    if (data.saveMetadata == void(0)) data.saveMetadata = false;
    if (data.cleantransparent == void(0)) data.cleantransparent = true;
    if (data.pInterlacted == void(0)) data.pInterlacted = false;
    if (!getSuperPngInfo()) return false;

    var desc = new ActionDescriptor();
    var descSPng = new ActionDescriptor();
    descSPng.putInteger(charIDToTypeID('pngC'), 9); // ??
    descSPng.putInteger(charIDToTypeID('pngF'), 248); // ??
    descSPng.putInteger(charIDToTypeID('pngS'), 0); // ??
    descSPng.putBoolean(charIDToTypeID('pngQ'), true); // ??
    descSPng.putInteger(charIDToTypeID('pngq'), data.quality); // quality
    descSPng.putEnumerated(charIDToTypeID('pngA'), charIDToTypeID('alfT'), data.transparency ? charIDToTypeID('alfT') : charIDToTypeID('alfN'));
    descSPng.putBoolean(charIDToTypeID('pngX'), data.cleantransparent);
    descSPng.putBoolean(charIDToTypeID('pngI'), data.pInterlacted);
    descSPng.putBoolean(charIDToTypeID('pngM'), data.saveMetadata);
    desc.putObject(charIDToTypeID('As  '), stringIDToTypeID('fnord SuperPNG'), descSPng);
    desc.putPath(charIDToTypeID('In  '), new File(data.path + "/" + data.name + ".png"));
    desc.putInteger(charIDToTypeID('DocI'), 475);
    desc.putEnumerated(stringIDToTypeID('saveStage'), stringIDToTypeID('saveStageType'), stringIDToTypeID('saveSucceeded'));
    executeAction(charIDToTypeID('save'), desc, DialogModes.NO);

    function getSuperPngInfo()
    {
        var sysInfo = app.systemInformation.split("\n");
        for (var i = sysInfo.length - 1; i >= 0; i--)
        {
            if (sysInfo[i].indexOf('SuperPNG') != -1)
            {
                return true
            }
        }
        return false
    }
};

exportSuperPng();

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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