blog community

Welcome to blog community Sign in | Join | Help
in Search

Wouter van Vugt

This blog is no longer maintained and has moved

Unpacking the Microsoft EMZ File Format

When you crack open one of the new Word files which use the new packaging format (e.g. docx etc), you'll find that many images are stored as EMZ files, which is basically a zipped up EMF file. It is very easy to extract the image from this EMZ format with tools such as the SharpZipLib. The following code takes in the path to an EMZ file, and writes out the unpacked version:

static void Main(string[] args)

{

    string emzFile = "image.emz";

    GZipInputStream inputStream = new GZipInputStream(

        new FileStream(emzFile, FileMode.Open, FileAccess.Read));

    FileStream outputStream = new FileStream("test.emf", FileMode.Create);

    byte[] buffer = new byte[1024];

    int read = inputStream.Read(buffer, 0, 1024);          

    while (read > 0)

    {

        outputStream.Write(buffer, 0, read);

        read = inputStream.Read(buffer, 0, 1024);

    }

    outputStream.Close();

    inputStream.Close();

}

Published Tuesday, May 30, 2006 2:42 PM by wouterv

Comments

No Comments
Anonymous comments are disabled

This Blog

Syndication

News


Add to Technorati Favorites
Powered by Community Server, by Telligent Systems