The fireworks PNG format, any insight? Any libs?

前端 未结 2 765
日久生厌
日久生厌 2021-02-10 05:17

The ultimate goal is to export the pages in a fireworks png file to individual images. So I have a couple questions:

  1. Do you know of anything -- library, applicatio
相关标签:
2条回答
  • 2021-02-10 05:25

    Some digging I did on my own for the private chunk types in Adobe Fireworks files is as follows (assume Python slicing notation):

    prVW ("thumbnail preview?")

    Data format:
    - bytes[0:4]   - Chunk length
    - bytes[4:8]   - Chunk type
    - bytes[8:10]  - zlib file magic 0x789c
    - bytes[10:-8] - zlib data
    - bytes[-8:-4] - zlib checksum
    - bytes[-4:]   - Chunk checksum
    
    After decompressing, the first 4-bytes are the value "0xcafebeef",
    likely another file magic byte value for whatever format the data is
    in.
    


    mkBF

    Data format:
    - bytes[0:4]   - Chunk length
    - bytes[4:8]   - Chunk type
    - bytes[8:12]  - 0xfadecafe (file magic?)
    - bytes[12:16] - big-endian length value?
    - bytes[16:80] - 64-byte NULL-padded data field
    - bytes[80:84] - Chunk checksum
    


    mkBS

    Data format:
    - bytes[0:4]   - Chunk length
    - bytes[4:8]   - Chunk type
    - bytes[8:10]  - zlib file magic 0x789c
    - bytes[10:-8] - zlib data
    - bytes[-8:-4] - zlib checksum
    - bytes[-4:]   - Chunk checksum
    


    mkBT

    Data format:
    - bytes[0:4]   - Chunk length
    - bytes[4:8]   - Chunk type
    - bytes[8:12]  - 0xfacecafe (file magic?)
    - bytes[12:16] - Unknown big-endian value.  Increments for
                     each mkBT chunk present, and appears to only
                     consume the lower 24-bits.
    - bytes[16:84] - 68-byte NULL-padded data field
    - bytes[84:86] - zlib file magic 0x789c
    - bytes[86:-8] - zlib data
    - bytes[-8:-4] - zlib checksum
    - bytes[-4:]   - Chunk checksum
    
    This chunk may contain a split/spanned zlib stream, as the decompressed
    data is cut at 64kb per mkBT chunk and does not appear to carry a zlib
    checksum value.  Decompressing each zlib stream and then concatenating them
    all together does not appear to be wrong.
    


    mkTS

    Data format:
    - bytes[0:4]   - Chunk length
    - bytes[4:8]   - Chunk type
    - bytes[8:10]  - zlib file magic 0x789c
    - bytes[10:-8] - zlib data
    - bytes[-8:-4] - zlib checksum
    - bytes[-4:]   - Chunk checksum
    
    0 讨论(0)
  • 2021-02-10 05:45

    Interesting question.

    Don't how much it helps, if you're trying to write an utility that gets a Fireworks PNG(APNG) and saves the pages, but here goes:

    You could use the Export menu in Fireworks: File > Export > Pages to Files.

    Also you could use the Save as option and choose Photoshop PSD. This option preserves the pages as folders/groups int the Photoshop Layers Panel, but it does rasterize vector shapes. Still, it could be handy if you want to parse a PSD instead of a APNG(to access images,pages).

    I've put together a small script (mostly using the docs) which saves a PSD of your currently open Fireworks PNG to a folder you choose:

    var doc = fw.getDocumentDOM();
    var loc = fw.browseForFolderURL("select a folder to save pages");
    
    var prevWarn = fw.getPref("PsdExport_Warn100"); // bool 
    fw.setPref("PsdExport_Warn100", false);    // don't warn. 
    
    var kObjToLayer = 1; 
    var kFlatten = 2; 
    var prevLayers = fw.getPref("PsdExport_Layers"); 
    fw.setPref("PsdExport_Layers", kObjToLayer);    // flatten layers or not. 
    
    var kEffectEditable = 1; 
    var kEffectRender = 2; 
    var prevEffects = fw.getPref("PsdExport_Effects"); 
    fw.setPref("PsdExport_Effects", kEffectEditable); 
    
    var kTextEditable = 1; 
    var kTextRender = 2; 
    var prevText = fw.getPref("PsdExport_Text"); 
    fw.setPref("PsdExport_Text", kTextRender); 
    
    if(loc) fw.exportPSD(doc, loc+"/yourPages.psd"); 
    
    // Put the prefs back. 
    fw.setPref("PsdExport_Warn100", prevWarn); 
    fw.setPref("PsdExport_Layers", prevLayers); 
    fw.setPref("PsdExport_Effects", prevEffects); 
    fw.setPref("PsdExport_Text", prevText);
    

    If you save this as a .jsf file, and have a document open in Fireworks, you should be able to just double click the .jsf file.

    Also, noticed there's an Export PSD extension available, which has more options than my little script here.

    If you need the vector shapes, you can use File Export > FXG and Images and choose All Pages bellow the format. FXG is an xml format, and the specs are available.

    HTH

    0 讨论(0)
提交回复
热议问题