Home Image-Pro General Discussions

Pictures MetaData

Hi,

I recorded a function to change MetaData value of my image. I need to use this to store 2 importants values for each captured image.

    Private Sub SetMetaData(ByVal CalibrationSpacial As String, ByVal MagnificationValue As String)
        Dim doc1

        With Application.Gadgets.DocumentProperties(m_SimpleScript)
            .CheckState = MediaCy.IQL.Application.McCommand.mcCheckState.Checked
            .Run()
        End With

        With Application.DocumentCommands.Active(m_SimpleScript)
            .Run(doc1)
        End With

        With Application.DocumentCommands.Properties(m_SimpleScript)
            .Title = CalibrationSpacial
            .Owner = MagnificationValue
            .Run(doc1)
        End With
    End Sub

In IPP I can see that the value has been applied, but when I save as the picture, and after that when i'm going with Windows File Explorer to check image properties...the metadata are empty.

Thanks,

Martin

Answers

  • Hi Martin,

    This is very much dependent on the file format and the software used to read the properties, so I would recommend to put your data in the Description field if you want it to be visible in Windows Explorer. Otherwise note that the calibration information will be saved automatically in TIFF files, and you can also save it separately in an .IQC file.

    Pierre
  • Hi Pierre,

    I tried with "Description" but I'm facing the same problem.
    I did some test, manually, and no metadata are saved if I use JPG format. If I use TIFF format, metadata are saved (tested using the Title and Description).

    Is it an issue with IPP ?

    Here's the steps I did :
    - Open an image
    - Show document properties
    - Add in Title "Title test 1-2-3"
    - Add in description "Description test 1-2-3"
    - Save As in JPG format
    - Save As in TIFF format
    - Reopen both files

    In the document properties of JPG file...no metadata saved...in TIFF file...everything is there.
    In Windows Explorer, it works also only for the TIFF file ; I can see the value I entered in "Description" as a part of Title and Subject tag.

    My client do not want to use TIFF format.

    Thanks,

    Martin
  • edited April 2015
    Hi Martin,

    We typically don't use JPEG because it is lossy, and currently Image-Pro Premier does not support writing metadata in JPEG files.

    As a workaround I suggest that you use the .NET API to write the metadata of your choice, here is a function that will do that.

    Pierre

    Imports System.Drawing
    
    Public Module Macros
    
        Public Sub Test1
            SetDescription(ThisApplication.ActiveDocument.FileName,"D:\Test.jpg")
        End Sub
    
        Public Sub SetDescription(inFile As String, outFile As String)
            ' http://msdn.microsoft.com/en-us/library/ms534415(VS.85).aspx
            Dim ImageDescription As Integer = &H010E
    
            Dim jpgImage As Image = Image.FromFile(inFile)
            Dim data() As Byte = system.Text.Encoding.UTF8.GetBytes("My comment")
            ' Get a Property from the image file And use it As container
            Dim pi As System.Drawing.Imaging.PropertyItem = jpgImage.PropertyItems(0)
    
            ' Set the values
            ' http://msdn.microsoft.com/en-us/library/system.drawing.imaging.propertyitem.aspx
            pi.Type = 2
            pi.Id = ImageDescription
            pi.Len = data.Length-1
            pi.Value = data
            jpgImage.SetPropertyItem(pi)
    
            jpgImage.Save(outFile)
        End Sub
Sign In or Register to comment.