开发者

The fireworks PNG format, any insight? Any libs?

The ultimate goal is to export the pages in a fireworks png file to ind开发者_如何学编程ividual images. So I have a couple questions:

  1. Do you know of anything -- library, application -- that does this already?
  2. Do you have any information on the format? They store their information in specialized chunks, I assume. I'm just hoping the format of those chunks' payload is not so difficult to figure out.

I have not dug into any fireworks files yet. I am finding no information on the format, so that is next step, but I figured someone may know a bit and save me some time :).

What I hope (and probably isnt the case) is that each page is stored as PNG in separate IDAT chunks. Unlikely, though, due to the vector capabilities. Maybe they store svg format in the chunks?

Any help or discussion is appreciated. I plan to dig into this in the next couple days.

Ben

EDIT: Here are a couple things: the linked superuser post below indicates the files are APNG. fireworks files are not APNG. APNG contains animation chunks: acTL, fcTL, fdAT. Fireworks has, in addition to the IDAT chunks, prVW, mkBF, mkTS, mkBS, mkBT chunks but none of the APNG chunks.

There is a pretty solid post here on fireworks PNGs: http://newsgroup.xnview.com/viewtopic.php?f=35&t=20592#p86243

So I suppose I need to know what these chunks do, and how to parse them.


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


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜