Public Sub ProcessImage(infile As String)
Dim txtfile As String
Dim saveimage As String
Dim Image As WIA.ImageFile
Dim ip As WIA.ImageProcess
txtfile = infile
'MsgBox "Processing: " & txtfile
Let Me.ImageOrig.Picture = infile
Let Me.Image1.Picture = ""
Let Me.TB_Orientation.Value = 1
Set Image = New WIA.ImageFile
Call Image.LoadFile(infile)
If Image.Properties.Exists("274") Then
Set ip = New WIA.ImageProcess
With ip
' On Error GoTo B:
On Error GoTo Err_Handler1
Let Me.TB_Orientation.Value = Image.Properties("274").Value
Select Case Image.Properties("274").Value
Case 2: Call mkFlt(ip, "FlipHorz")
Case 3: Call mkFlt(ip, "Rotate", 180)
Case 4: Call mkFlt(ip, "FlipVert")
Case 5: Call mkFlt(ip, "FlipHorzandRotate", 270)
Case 6: Call mkFlt(ip, "Rotate", 90)
Case 7: Call mkFlt(ip, "FlipHorzandRotate", 90)
Case 8: Call mkFlt(ip, "Rotate", 270)
End Select
Set Image = .Apply(Image)
End With
End If
B: On Error GoTo Err_Handler2
'Me.Image1.PictureData = Image.FileData.BinaryData
'Me.Image1.Picture = Image.FileData.BinaryData
saveimage = CurrentProject.Path & "\" & "temp.jpg"
On Error Resume Next
Kill saveimage
Image.SaveFile saveimage
Me.Image1.Picture = saveimage
X: Exit Sub
E: Debug.Print Err.Description
MsgBox "Error: " & Err & " Dsc: " & Err.Description
Exit Sub
Err_Handler1:
'MsgBox "Error: " & Err & " Dsc: " & Err.Description, , "Handler1"
Resume B:
Err_Handler2:
MsgBox "Error: " & Err & " Dsc: " & Err.Description, , "Handler2"
End Sub