Image Orientation

J

Jess

How can I determine programmatically the orientation of an image
-Portrait/landscape- on my hard drive?

Thanks
 
J

Jack Leach

Here's a function you can use to loop through the properties of a file... it
doesn't give *everything* but I think you can get the length and width of a
jpg file. I'm not sure a picture actually has an "orientation" persay, but
you can do a ratio comparision to the length and width to determine which it
may be better suited for perhaps...





'==============================================================================
' FileGetProperties
'
' Adapted (copied) from Michael Pierron
' http://www.pcreview.co.uk/forums/thread-1862574.php
' Purpose: Returns an array of all file properties
' Arguments: sFile: Full Path to File
' Returns: Array (Variant) of all properties
'-----------------------
Public Function FileGetProperties(sFile As String) As Variant
On Error GoTo Err_Proc
Dim Ret(34) As String
'==================
Dim i As Integer
Dim T As String
'==================

With CreateObject("Shell.Application").Namespace(Left( _
sFile, lPosition(sFile, "\") - 1))

For i = 0 To 34
T = .GetDetailsOf(.parsename(Dir(sFile)), i)
If Len(T) Then
Ret(i) = .GetDetailsOf(.Items, i) & ": " & T
Debug.Print Ret(i)
End If

Next i

End With

'==================
Exit_Proc:
FileGetProperties = Ret
Exit Function
Err_Proc:
MsgBox "Error!" & vbCrLf & _
Str(Err.Number) & ": " & Err.Description, _
vbCritical, "Library Error!"
Resume Exit_Proc
Resume
End Function

Private Function lPosition%(Chain$, Char$)
'Dependant of FileGetProperties
Dim iPos%
Do
iPos = InStr(lPosition + 1, Chain, Char, 1)
If iPos Then lPosition = iPos Else Exit Do
Loop
End Function


--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top