Skip to main content
Known Participant
June 14, 2024
Open for Voting

Will Photoshop one day allow artboards to be exported as animated Gifs?

Hello
Over time, I've noticed that many users have asked why Photoshop can't export different artboards to animated Gifs.
This is a feature that saves time when creating animated Gif banners of different sizes.
- The "export artboards to files" option does not allow this.
- And the "Export to" option does allow the Gif, but it's static.
So I have to hide all the artboards and display one by one the size I want to export, using the Save for Web function. Please allow web saving for all artboards at once!

1 reply

Known Participant
June 14, 2024

You know what, after a few minutes, I got Chat GPT writing a working script for me : save it to .jsx, then go to scripts, open it and it works alone. So why don't you add such a feature in Photoshop ?

#target photoshop

// Fonction pour masquer tous les artboards
function hideAllArtboards(artboards) {
    for (var i = 0; i < artboards.length; i++) {
        artboards[i].visible = false;
    }
}

// Fonction pour exporter un artboard en GIF animé
function exportArtboardAsGif(doc, artboard, exportPath) {
    var artboardName = artboard.name;

    // Masquer tous les artboards sauf celui-ci
    hideAllArtboards(doc.layerSets);
    artboard.visible = true;

    // Duplique le document pour l'exportation
    var tempDoc = doc.duplicate();

    // Sélectionne et recadre l'artboard actuel
    var artboardBounds = artboard.bounds;
    tempDoc.crop([artboardBounds[0], artboardBounds[1], artboardBounds[2], artboardBounds[3]]);

    // Crée une animation de trame à partir des calques
    // Active les calques un par un pour créer une animation
    var layers = tempDoc.artLayers;
    for (var i = 0; i < layers.length; i++) {
        for (var j = 0; j < layers.length; j++) {
            layers[j].visible = (i === j);
        }
        tempDoc.layers[i].duplicate();
    }

    // Enregistre en GIF
    var saveFile = new File(exportPath + "/" + artboardName + ".gif");
    var exportOptions = new ExportOptionsSaveForWeb();
    exportOptions.format = SaveDocumentType.COMPUSERVEGIF;
    exportOptions.colors = 256;  // Spécifie que le GIF doit être en 256 couleurs

    // Options de dithering
    exportOptions.dither = Dither.NOISE;
    // Autres options possibles pour le dithering :
    // Dither.NONE - Pas de dithering
	// Dither.PATTERN - Pas de dithering
    // Dither.DIFFUSION - Dithering par diffusion
    // Dither.NOISE - Dithering par bruit

    // Options de réduction des couleurs
    exportOptions.colorReduction = ColorReductionType.ADAPTIVE;  
    // Autres options possibles pour la réduction des couleurs :
    // ColorReductionType.SELECTIVE - Sélective
	// ColorReductionType.PERCEPTUAL - Sélective
    // ColorReductionType.ADAPTIVE - Adaptive
    // ColorReductionType.RESTRICTIVE - Web

    exportOptions.interlaced = false;
    exportOptions.transparency = true;
    exportOptions.includeProfile = false;
    exportOptions.loop = true;
    tempDoc.exportDocument(saveFile, ExportType.SAVEFORWEB, exportOptions);

    // Ferme le document temporaire sans enregistrer
    tempDoc.close(SaveOptions.DONOTSAVECHANGES);

    // Masquer l'artboard actuel après l'exportation
    artboard.visible = false;
}

// Fonction principale
function main() {
    var doc = app.activeDocument;

    if (!doc) {
        alert("Aucun document ouvert.");
        return;
    }

    var artboards = doc.layerSets; // Accès aux artboards via layerSets

    if (!artboards || artboards.length == 0) {
        alert("Aucun artboard dans le document.");
        return;
    }

    var exportFolder = Folder.selectDialog("Choisissez le dossier d'exportation des GIFs");

    if (exportFolder) {
        for (var i = 0; i < artboards.length; i++) {
            exportArtboardAsGif(doc, artboards[i], exportFolder.fsName);
        }
        alert("Exportation terminée!");
    } else {
        alert("Exportation annulée.");
    }
}

main();

 

 

 

 

Translate