DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Picture Orientation

Solved!
Go to solution

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

Tim
0 Kudos
Message 1 of 2
(2,439 Views)
Solution
Accepted by topic author smoothdurban

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.

 

Tim
0 Kudos
Message 2 of 2
(2,401 Views)