You are viewing limited content. For full access, please sign in.

Question

Question

multipage tiff file xp keywords extraction in workflow with script activity

asked on December 17, 2024

Hi, I'm in need to extract xp keyword metadata from a multipage tiff file. This is generated in a scanner and the keywords are manually input by the operator. I need those to be assigned to a LF field.

As I´ve investigated the only possibility to do this extraction is via a scripting activity in a workflow

I've managed to get the C# code below but I can´t make it to run. Can anybody point me in the right direction to what his wrong/missing or better yet, complete/correct the code so it can run properly? 

Imports System.Diagnostics

Imports Laserfiche.Workflow.Script

 

Public Class Script

    Public Sub Execute()

 

        ' Obtener la ruta del archivo TIFF desde un token de entrada del flujo de trabajo

        Dim filePath As String = WorkflowApi.GetTokenValue("FilePath")

        Dim exifToolPath As String = "C:\Path\To\exiftool.exe" ' Cambia esta ruta según la ubicación de ExifTool

 

        ' Validar que las rutas no estén vacías

        If String.IsNullOrEmpty(filePath) Or String.IsNullOrEmpty(exifToolPath) Then

            WorkflowApi.Logger.Log("Error: La ruta del archivo TIFF o de ExifTool no está configurada.")

            Return

        End If

 

        ' Configurar el proceso para ejecutar ExifTool

        Dim process As New Process()

        process.StartInfo.FileName = exifToolPath

        process.StartInfo.Arguments = "-XPKeywords """ & filePath & """"

        process.StartInfo.RedirectStandardOutput = True

        process.StartInfo.UseShellExecute = False

        process.StartInfo.CreateNoWindow = True

 

        Try

            ' Iniciar el proceso y leer la salida

            process.Start()

            Dim output As String = process.StandardOutput.ReadToEnd()

            process.WaitForExit()

 

            ' Validar la salida de ExifTool

            If Not String.IsNullOrEmpty(output) Then

                ' Guardar los XP Keywords en un token de salida

                WorkflowApi.SetTokenValue("XPKeywords", output.Trim())

 

                ' Registrar los XP Keywords en el log

                WorkflowApi.Logger.Log("XP Keywords extraídos: " & output.Trim())

            Else

                WorkflowApi.Logger.Log("No se encontraron XP Keywords en el archivo TIFF.")

            End If

 

        Catch ex As Exception

            ' Registrar cualquier error ocurrido durante la ejecución

            WorkflowApi.Logger.Log("Error al ejecutar ExifTool: " & ex.Message)

        Finally

            ' Liberar recursos del proceso

            process.Dispose()

        End Try

    End Sub

End Class

   

0 0

Replies

replied on December 17, 2024

This may be what you're looking for if you're trying to extract EXIF metadata.

Can we extract GeoTag information from pictures in Laserfiche repository and insert it into a Field? - Laserfiche Answers

1 0
replied on December 17, 2024

Is "C:\Path\To\exiftool.exe" the correct path for the executable on the Workflow machine? It's hard to guess what could be wrong without more information - what error do you get when the code runs?

1 0
replied on December 18, 2024 Show version history

The code I included as an example is "raw" i.e. the path you mention is not the actual, real path. But anyway if I put the right path and make it to run as a VB file, it doesn´t run.

0 0
replied on December 18, 2024

Might be silly, but just double-checking…  You mentioned C#, but that script is written in Basic not in C#.  Do you have the script activity in Workflow set to C# or Visual Basic?  

Tip: Use the “{…}code” button here in LFAnswers to make your code more readable.

1 0
replied on December 18, 2024

Err....where does this code come from? Aside from it being VB not C# as Matthew mentioned, " WorkflowApi.Logger.Log " is not a thing in Workflow and the referenced Laserfiche.Workflow.Script is not a Laserfiche file.

1 0
replied on December 18, 2024

Miruna, my mistake... it is VB not C#, anyway it does not work. 

Now, your remarks are, precisely what I´d like to correct; the code was generated with ChatGPT and obviously it is not right. May you be so kind as to what should be the correct values for the items you mention: 

- WorkflowApi.Logger.Log and

- Laserfiche.Workflow.Script

All I want is to extract XP keywords (a type of EXIF metadata from a TIFF multipage file) and put them in a a LF field. 

Any pointer to a resource where I can find information as to make this thing work would also be appreciated. 

Thanks!

0 0
replied on December 18, 2024

Are these multi-page TIFF you have on a local disk, right? They have not yet been imported into the repository.

0 0
replied on December 19, 2024

Miruna,

I´d like to have both options: for files that are in a windows folder somewhere and also for files that are being imported via Import Agent and are the entry that kicks off a LF workflow; this script activity would then be part of that workflow; the extracted xp keyword would be assigned to a LF field and the entry would be imported with the extracted keyword already in the selected field. 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.