Saving images into folders based on their barcode
This example shows how to sort image files and save them as TIFF files in different folders based on the barcode type detected within the image.
'We assume that GdPicture has been correctly installed and unlocked.Dim oGdPictureImaging As New GdPictureImaging()Dim filePath As [String] = "Pictures\barcodes"Dim distPath As [String] = "Pictures\barcodeTypes\"Dim allImages As [String]() = Directory.GetFiles(filePath)Dim bcfound As Integer = 0Dim m_Image As Integer = 0Dim status As GdPictureStatus = GdPictureStatus.OKFor Each imagePath As String In allImages bcfound = 0 m_Image = oGdPictureImaging.CreateGdPictureImageFromFile(imagePath) If oGdPictureImaging.GetStat() <> GdPictureStatus.OK Then MessageBox.Show("Error: " + oGdPictureImaging.GetStat().ToString(), "Barcode Example", MessageBoxButtons.OK, MessageBoxIcon.Error) Exit For End If status = oGdPictureImaging.Barcode1DReaderDoScan(m_Image, Barcode1DReaderScanMode.BestSpeed) If status <> GdPictureStatus.OK Then MessageBox.Show("Error: " + status.ToString(), "Barcode Example", MessageBoxButtons.OK, MessageBoxIcon.Error) oGdPictureImaging.ReleaseGdPictureImage(m_Image) Exit For End If bcfound = oGdPictureImaging.Barcode1DReaderGetBarcodeCount() If bcfound > 0 Then For i As Integer = 1 To bcfound Dim barcodeType As [String] = oGdPictureImaging.Barcode1DReaderGetBarcodeType(i).ToString() Dim folderName As [String] = [String].Concat(barcodeType, "\") Dim imageName As [String] = [String].Concat(i.ToString(), ".tif") Dim completePath As [String] = [String].Concat(Path.Combine(distPath, folderName), imageName) status = oGdPictureImaging.SaveAsTIFF(m_Image, completePath, TiffCompression.TiffCompressionAUTO) If status <> GdPictureStatus.OK Then MessageBox.Show("Error: " + status.ToString(), "Barcode Example", MessageBoxButtons.OK, MessageBoxIcon.Error) Exit For End If Next End If oGdPictureImaging.ReleaseGdPictureImage(m_Image) If status <> GdPictureStatus.OK Then Exit For End IfNextoGdPictureImaging.Dispose()
This code sample is an example that illustrates how to use our SDK. Please adapt it to your specific use case.