09-05-2018 10:00 AM
Hello All
I have developed some report templates that assume that all images will be in Landscape mode however it appears that sometimes my techs forget this and take photos in portrait mode.
I have stumbled across the "LoadPicture" function and I have found a way to create an image object however I cannot seem to find additional documentation (on the web) on of the methods or properties associated with the object.
Basically I would like to check if an image file on disk is either in portrait or landscape mode and rotate the image if need be.
Any help would be appreciated
Solved! Go to Solution.
09-10-2018 12:00 PM
I found a viable work around see below
Set miDoc = LoadPicture(file) 'Where file is full image file path and name
If miDoc.height > miDoc.width Then 'Logic being if the height > width the photo is in portrait mode
Call WIA_RotateImage(file, file, 270)
End If
Function WIA_RotateImage(sInitialImage, sOutputImage, lRotAng)
Dim oWIA 'WIA.ImageFile
Dim oIP 'ImageProcess
'Should check if the output file already exists and if so,
'prompt the user to overwrite it or not
Set oWIA = CreateObject("WIA.ImageFile")
Set oIP = CreateObject("WIA.ImageProcess")
oIP.Filters.Add oIP.FilterInfos("RotateFlip").FilterID
oIP.Filters(1).Properties("RotationAngle") = lRotAng
oWIA.LoadFile sInitialImage
Set oWIA = oIP.Apply(oWIA)
DeleteAFile(sOutputImage)
oWIA.SaveFile sOutputImage
End Function
Sub DeleteAFile(filespec)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFile(filespec)
End Sub
Not the most elegant solution but it does work.