Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to convert jsx to upx plugin?

New Here ,
Aug 03, 2025 Aug 03, 2025

I want to convert this code to plugin how can I do?

#target photoshop

function findLayerSetByName(name) {
    var layerSets = app.activeDocument.layerSets;
    for (var i = 0; i < layerSets.length; i++) {
        if (layerSets[i].name === name) return layerSets[i];
    }
    return null;
}

function exportGroupAsWebJPG(groupName, baseName, exportFolder) {
    var doc = app.activeDocument;

    // First hide all language groups
    var kh = findLayerSetByName("kh");
    var vn = findLayerSetByName("vn");
    var eng = findLayerSetByName("eng");
    if (kh) kh.visible = false;
    if (vn) vn.visible = false;
    if (eng) eng.visible = false;

    // Show only current group
    var targetGroup = findLayerSetByName(groupName);
    if (!targetGroup) {
        alert("Group '" + groupName + "' not found.");
        return;
    }
    targetGroup.visible = true;

    // Set export options
    var exportOptions = new ExportOptionsSaveForWeb();
    exportOptions.format = SaveDocumentType.JPEG;
    exportOptions.includeProfile = false;
    exportOptions.interlaced = false;
    exportOptions.optimized = true;
    exportOptions.quality = 100;

    // Export
    var fileName = groupName + "_" + baseName + ".jpg";
    var file = new File(exportFolder + "/" + fileName);
    doc.exportDocument(file, ExportType.SAVEFORWEB, exportOptions);
}

function exportAllLanguageGroups() {
    var doc = app.activeDocument;
    var baseName = doc.name.replace(/\.[^\.]+$/, '');
    var exportPath = Folder.selectDialog("Choose export folder");

    if (!exportPath) return;

    var languages = ["kh", "vn", "eng"];
    for (var i = 0; i < languages.length; i++) {
        exportGroupAsWebJPG(languages[i], baseName, exportPath);
    }

    alert("Exported all versions successfully!");
}

exportAllLanguageGroups();
TOPICS
Windows
77
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Aug 04, 2025 Aug 04, 2025
LATEST

Good luck with that, I'm breaking out the popcorn!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines