03/06/20 14:43
dylan666
Allora, funzionicchia ma con un problema.
Il codice a cui (grazie a te) siamo arrivati è questo:
Il problema è che quando clicco sul bottone il file di output chiamato "ID3.jpg" viene creato, ma resta di 0KB e il MsgBox che ho messo alla fine non appare mai.
Appena termino l'esecuzione con "Stop debugging" del Visual Studio il file diventa di un peso "normale" e risulta correttamente elaborato.
Ma allora perché prima sembra rimasto "appeso" e il MsgBox non viene mostrato?
Con il listato in C# questo non accade.
Grazie
Il codice a cui (grazie a te) siamo arrivati è questo:
Imports Google.Api.Gax.ResourceNames Imports Google.Cloud.Dlp.V2 Imports Google.Protobuf Imports System.IO Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click RedactFromImage("PROJECT-######", "C:\tmp\ID.jpg", "C:\tmp\ID3.jpg") End Sub Function RedactFromImage(ByVal projectId As String, ByVal originalImagePath As String, ByVal redactedImagePath As String) As Object Dim request = New RedactImageRequest request.ParentAsProjectName = New ProjectName(projectId) request.InspectConfig = New InspectConfig request.InspectConfig.MinLikelihood = Likelihood.Likely request.InspectConfig.Limits = New InspectConfig.Types.FindingLimits() request.InspectConfig.Limits.MaxFindingsPerItem = 5 request.InspectConfig.IncludeQuote = True request.InspectConfig.InfoTypes.Add(New InfoType With {.Name = "PERSON_NAME"}) 'request.InspectConfig.InfoTypes.Add(New InfoType With {.Name = "EMAIL_ADDRESS"}) request.ByteItem = New ByteContentItem request.ByteItem.Type = ByteContentItem.Types.BytesType.ImagePng request.ByteItem.Data = ByteString.FromStream(New FileStream(originalImagePath, FileMode.Open)) Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", "C:\tmp\PROJECT-######.json") Dim client As DlpServiceClient = DlpServiceClient.Create() Dim response = client.RedactImage(request) 'Console.WriteLine($"Extracted text: {response.ExtractedText}") ' Writes redacted image into file response.RedactedImage.WriteTo(New FileStream(redactedImagePath, FileMode.Create, FileAccess.Write)) Return 0 MsgBox("Fatto!") End Function End Class
Il problema è che quando clicco sul bottone il file di output chiamato "ID3.jpg" viene creato, ma resta di 0KB e il MsgBox che ho messo alla fine non appare mai.
Appena termino l'esecuzione con "Stop debugging" del Visual Studio il file diventa di un peso "normale" e risulta correttamente elaborato.
Ma allora perché prima sembra rimasto "appeso" e il MsgBox non viene mostrato?
Con il listato in C# questo non accade.
Grazie
aaa