简体   繁体   English

从图书馆批量导出图像?

[英]Batch export images from Library?

i have a flash .fla that was compiling as a .swc with references to images, but now I need to load all these images externally and I dont have the original assets. 我有一个flash .fla,它正在编译为.swc,引用图像,但现在我需要从外部加载所有这些图像,而我没有原始资产。

I know I can export them one by one, but I have a few hundred in the file, and want to find an easier way. 我知道我可以一个一个地导出它们,但我在文件中有几百个,并希望找到一种更简单的方法。

Any help would be awesome. 任何帮助都是极好的。

You can use this script. 您可以使用此脚本。 It exports only bitmaps from your library. 它只导出库中的位图

//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);

Just save it as .jsfl file and open it from flash. 只需将其保存为.jsfl文件并从闪存中打开即可。 You should also open the .fla file from which you want to export all images. 您还应该打开要从中导出所有图像的.fla文件。

Best, Emil 最好,埃米尔

ps Other solutions is to just rename the .fla to .zip(.rar) file and to extract all assets. ps其他解决方案是将.fla重命名为.zip(.rar)文件并提取所有资产。 This is applicable only to .fla files created with latest version of Flash CS5 or CS5+. 这仅适用于使用最新版本的Flash CS5或CS5 +创建的.fla文件。

The link being dead, I found this script: 链接已经死了,我找到了这个脚本:

https://github.com/rafaelrinaldi/fla2img https://github.com/rafaelrinaldi/fla2img

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM