Jump to content
  • How to load an image from file and display via a document property in Spotfire® using IronPython scripting


    How to load an image from file and display via a document property in Spotfire® using IronPython scripting
    Article Information

    Code sample

    # Copyright © 2017. TIBCO Software Inc.  Licensed under TIBCO BSD-style license.
    
    from System.IO import MemoryStream, SeekOrigin
    from System.Drawing import Image
    from System.Drawing.Imaging import ImageFormat
    from Spotfire.Dxp.Data import BinaryLargeObject
    
    imgSrc = "C:\\Users\\USERNAME\\Pictures\\someImage.png"
    img = Image.FromFile(imgSrc)
    stream = MemoryStream()
    img.Save(stream, ImageFormat.Png)
    stream.Seek(0, SeekOrigin.Begin)
    blob = BinaryLargeObject.Create(stream)
    
    # Document Property should be of type Binary 
    Document.Properties["PngImage"] = blob
     

    References

    License:  TIBCO BSD-Style License

     

     


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...