Expression Blend and Design

The team blog of the Expression Blend and Design products.

Hello DeepZoomTools.DLL : Deep Zoom Image Tile Generation Made Easy

Hello DeepZoomTools.DLL : Deep Zoom Image Tile Generation Made Easy

  • Comments 43

In our most recent release of Deep Zoom Composer, one of the major changes we made was to change how we generated the image tiles both for designing as well as exporting your Deep Zoom Content. In the past, ever since our first release at MIX, our image encoding was done using a combination of SparseImageTool.exe and ImageTool.exe command line tools. Starting with this release, we have retired those tools and have shifted to a preview version of a .NET based DLL that provides image generation capabilities.

If you look inside your Deep Zoom Composer installation folder, which is by default, [Program Files]\Microsoft Expression\Deep Zoom Composer, you will see a file called DeepZoomTools.dll:

 dztoolsPNG

This DLL contains all of the functionality needed for you to generate image tiles for compositions and collections. The classes and methods that you can use are as follows:

public enum ImageFormat { Jpg, Png, Wdp };

public class Image
    public Image(string path)
    public double MaxViewportWidth
    public double MinViewportWidth
    public string Path
    public Point ViewportOrigin
    public double ViewportWidth

public class ImageCreator
    public ImageCreator()
    public double ImageQuality
    public int TileSize
    public int TileOverlap
    public ImageFormat TileFormat
    public bool CopyMetadata
    public void Create(string source, string destination)

public class CollectionCreator
    public CollectionCreator()
    public double ImageQuality
    public int TileSize
    public int MaxLevel
    public ImageFormat TileFormat
    public bool CopyMetadata
    public void Create(ICollection<Image> images, string destination)
    public void Create(ICollection<string> images, string destination)

public class SparseImageCreator
    public double ImageQuality
    public int TileSize
    public int TileOverlap
    public ImageFormat TileFormat
    public Color BackgroundColor
    public bool CopyMetadata
    public void Create(ICollection<Image> images, string destination)

The API should be pretty straightforward. A DeepZoomTools.Image is the internal notion of a Deep Zoom image, and it contains all of the information such as the viewport widths, path to source image, origin, etc. ImageCreator is used to define an image and write the image tiles to disk. CollectionCreator and SparseImageCreator take a list of image paths and write the image tiles to disk.

When I was playing with this, the one thing that confused me was what CollectionCreator expected as its “image path”. It isn’t a string of paths to raw JPG, PNG, etc. files. It is actually a path to the Deep Zoom Image created via ImageCreator/SparseImageCreator. SparseImageCreator does take in a list of paths to the source image, so passing in a list of image files will work for generating sparse images (aka Compositions).

Do note that this DLL is a pre-release version, and the Live Labs team will decide when and how to more formally release this in the future. Even though Deep Zoom Composer uses this same DLL, there may be future releases of this DLL that are independent of Deep Zoom Composer releases.

Thanks,
Kirupa

Leave a Comment
  • Please add 8 and 4 and type the answer here:
  • Post
  • In our most recent release of Deep Zoom Composer, one of the major changes we made was to change how

  • Awesome, thanks for the introduction, it makes all the difference.

    Now we can do some very cool things with exisiting image collections :)

  • Yesterday I saw that the Expression Blend and Design team had blogged about the new DeepZoomTool.dll

  • The new DLL is much faster, and yes, this is an improvement. But I am it still fails about about image 80 when I try and load a 100 image project I created in an earlier version (100 tiles of 8K x 8K JPEG).

  • Happy Thanksgiving everyone! In this issue: Martin Mihaylov, Tim Heuer, Katrien De Graeve, Expression

  • Works great! However, I was thinking with this new setup I could parallelize the imagecreation part of the process...I used the Parallel extensions library and it works fine (90% cpu instead of 45%) as long as I don't enable copymetadata=true. When I enable this I get Cannot Write to Stream - {"Exception from HRESULT: 0x88982F71"} when calling the create method.

    Wondering if there is a way around this, I realize it has to do with STA and COM, but it sure would be nice to be able to do this.

    Thanks!

  • Another question...

    I am getting an ArgumentOutOfRangeException on imagecreator.create()

    "Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: index"

    Works fine for about 400 images and then throws that...

    Any ideas why this would be happening?

  • YSG - are you using Deep Zoom Composer or a custom app that directly talks to the DLL? If you are using Deep Zoom Composer, is the actual arrangement of images really important, or would a generic grid-like view suffice? The reason I ask is that I have a prototype of an application that just takes a folder of images, makes a collection out of it, and displays the images in a grid set programmatically.

    George - I am assuming that you are using a custom app for accessing the DLL. We have using the Parallel Extensions Library in the back of our list of things to do, but I haven't actually played with it enough to give you a better idea of why that error is being thrown.

    Is Copying Metadata something that is important to you? Generally, this is useful for copyright scenarios where each image tile would contain the licensing information. Also, Copying Metadata only works for JPEG files. PNG files are not supported yet.

    For your second question, I am really not sure what the answer would be. I will forward your question to a colleague who may know more, but because this is a holiday weekend for many of us, it may not be until early next week you get a response back.

  • George - Would it be possible for you to post that image somewhere I can access? If not, feel free to e-mail it to me at kirupa@kirupa.com.

    Thanks,

    Kirupa

  • Hey guys... so if I make a program that makes use of the DLL... can I redistribute the DLL with the program? Cause I don't see it being installed in the GAC right now.

    Or I guess I could do it the roundabout way and tell the user to install DeepZoom Composer first, and then my program will go and look for the DLL to copy into the local application folder.

  • Hi marauderz,

    This DLL is still a beta/pre-alpha version of what the Live Labs team is planning on doing in the future. While you can distribute the DLL with your app, do note that the DLL will be getting outdated very fast as we keep making updates and changes to it.

    Thanks,

    Kirupa

  • Well, all I need right now is for it to generate images and collections, so that's good enough for me! thanks for the info.

  • Hi Kirupa,

    I do appreciate giving me a great product!

    I'm very happy with ImageCreator.

    Unfortunately,

    When i try to gerenate images using ViewportOrigin property with SparseImageCreator, i got "Image out of bounds" error.

    here is a simple codes.

    Microsoft.DeepZoomTools.SparseImageCreator s = new Microsoft.DeepZoomTools.SparseImageCreator();

    s.CopyMetadata = false;

    s.TileFormat = Microsoft.DeepZoomTools.ImageFormat.Jpg;

    List<Microsoft.DeepZoomTools.Image> l = new List<Microsoft.DeepZoomTools.Image>();

    double x = 0;

    foreach (FileInfo p in fies)

    {

     Microsoft.DeepZoomTools.Image i = new Microsoft.DeepZoomTools.Image(p.FullName);

     i.ViewportOrigin = new System.Windows.Point(x, x);

     l.Add(i);

    x += 0.1;

    }

    s.Create(l, Environment.CurrentDirectory + "\\b.xml");

    Could you please let me know how can i generate several images to deepzoom images.

  • DJ - if you try multiplying the argument for y by -1, do you still get that error? I haven't played with SparseImageCreator a great deal, so I don't know for sure how to debug your problem yet.

    :)

  • I'll try to send the files this week...

    Another nice addition would be a callback/event for the collectioncreator.create method to return status...it can take a long time to run so b eing able to inform the user where we are in the process would be great...

Page 1 of 3 (43 items) 123