Jump to content
  • The thumbnail is encoded as a Base64 128x96 png inside a LibraryItem. By using the LibraryManager you can fetch the Base64 image. The following is a sample C# code which illustrates how to access the thumbnails of dxps from Spotfire Server library.

    Introduction

    The thumbnail is encoded as a Base64 128x96 png inside a LibraryItem. By using the LibraryManager you can fetch the Base64 image. The following is a sample C# code which illustrates how to access the thumbnails of dxps from Spotfire Server library:

    Code Sample

    // Copyright © 2017. TIBCO Software Inc. Licensed under TIBCO BSD-style license.
    
    private void SaveThumbnailImageFromLibrary(AnalysisApplication app)
    {
        LibraryItemCollection items;
        LibraryManager lm = app.GetService();
    
    	items = lm.Search("type:dxp", LibraryItemRetrievalOption.IncludeProperties);
    
        bool isValidProperty = false;
        foreach (LibraryItem item in items)
        {
            if (item == null) continue;
            LibraryItemPropertyCollection lic = item.Properties;
            LibraryItemProperty prop;
            isValidProperty = lic.TryGetProperty("Spotfire.Preview.Thumb", out prop);
            if (!isValidProperty)
            {
                continue;
            }
    
            IEnumerator base64 = prop[0].GetEnumerator();//This will give you an image (base64 encoded 128x96 png) as a char enumeration.
    
            //To save the image:
            /*Image img;
            byte[] fileBytes = Convert.FromBase64String(prop[0].ToString());
            using (MemoryStream ms = new MemoryStream())
            {
                ms.Write(fileBytes, 0, fileBytes.Length);
                img = Image.FromStream(ms);
            }
            img.Save(@"C:ThumbNail.png", ImageFormat.Png); 
            */
        }
    }
     

    References

    License:  TIBCO BSD-Style License

     

     


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...