簡體   English   中英

從圖書館批量導出圖像?

[英]Batch export images from Library?

我有一個flash .fla,它正在編譯為.swc,引用圖像,但現在我需要從外部加載所有這些圖像,而我沒有原始資產。

我知道我可以一個一個地導出它們,但我在文件中有幾百個,並希望找到一種更簡單的方法。

任何幫助都是極好的。

您可以使用此腳本。 它只導出庫中的位圖

//created by Heitara
var folderURI = fl.browseForFolderURL('Select folder where all images should be exported as *.PNG');

var doc = fl.getDocumentDOM();
var newDoc = fl.createDocument();
//fl.outputPanel.trace("Init");

if(doc && newDoc)
{
    fl.outputPanel.trace("Start");
    var library = doc.library;
    var allLibItems = library.items;
    var item;
    var c = 0;
    var selectedItemOnStage;
    var selectionArray;
    var itemName;

    for (var i = 0; i<allLibItems.length; ++i) 
    {
        item = allLibItems[i];//only images will be processed
        if(item.itemType == "bitmap") //|| item.itemType == "graphic")
        {
            // attach image
            newDoc.addItem({x:0.0, y:0.0}, item);

            //postition all items on (0,0) 
            var image = newDoc.getTimeline().layers[0].frames[0].elements[0];
            if(image)
            {

                var hpx = image.hPixels;
                var vpx = image.vPixels;

                newDoc.width = hpx;
                newDoc.height = vpx;
                // we need to reposition the image, otherwise it will be centered
                image.x = 0;

                image.y = 0;
            }

            itemName = item.name.split('.')[0];
            //export as png
            newDoc.exportPNG(folderURI + "/"+itemName +".png",true,true);
            //select all
            newDoc.selectAll();
            //remove selection
            newDoc.deleteSelection();
            //deselect everything
            newDoc.selectNone();
            //output.trace("[END]");

        }

    }
}

//close the new document withut saving it
fl.closeDocument(newDoc, false);

只需將其保存為.jsfl文件並從閃存中打開即可。 您還應該打開要從中導出所有圖像的.fla文件。

最好,埃米爾

ps其他解決方案是將.fla重命名為.zip(.rar)文件並提取所有資產。 這僅適用於使用最新版本的Flash CS5或CS5 +創建的.fla文件。

鏈接已經死了,我找到了這個腳本:

https://github.com/rafaelrinaldi/fla2img

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM