I have a vb interface for users to modify some aspects of image, like threshold and rotation. I have to use different files for output with convert, since overwritting the same seems not to work (I've also tried mogrify with no better results); gives no error but file is not updated. After the user is happy and finishes, I want to delete all temporary files, but keep getting the error file in use by VB, I have checked that no picture element in VB is using it, and have set the image object to nothing, yet all files previuosly used by convert are left open. Here is my code.
When scrolling to change threshold:
Sub cambiaContraste(ByVal pContraste As Integer)
Try
msgs = CStr(img.Convert(file_name_temporal, "-black-threshold", pContraste.ToString & "%", file_temp & pContraste.ToString & ".jpg"))
PictureBox2.Image = System.Drawing.Bitmap.FromFile( file_temp & pContraste.ToString & ".jpg")
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End Sub
When saving image and wanting to delete temporary files:
img = Nothing
For Each archivo In System.IO.Directory.GetFiles(dirtemporal)
archivo_inf = New System.IO.FileInfo(archivo)
Try
System.IO.File.Delete(archivo)
Catch ex As Exception
MsgBox(archivo.ToString)
End Try
Next
I get a file in use error in every temporary file created during the scrolling. I haven't seen any information in web or in the forums about this problem, maybe I'm using the object inadequately. I have the following:
Imports ImageMagickObject
Public img As New ImageMagickObject.MagickImage
Thanks in advance for your support.