Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Oversize Tiff Files Identification 2

Status
Not open for further replies.

ricardo1023

Programmer
Mar 23, 2008
54
US
I do have hundreeds of thousands of image files that need to be printed. We have more than one printer and we need to identify which files correspond to very large blueprints (paper size is 24 x 30) In Windows explorer there is a column called "Dimensions" that may help with the identification (by dividing the numbers by 3 or something like that). Any idea how to accomplish this programatically?

Thank you
 



Hi,

What MS Office application are you using?

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
> In Windows explorer there is a column called "Dimensions" that may help
Something I put together a couple of years ago might help:
Code:
[blue]Public Function GetPictureDimensions(strPicturePath As Variant, strFilename As Variant) As String
    GetPictureDimensions = CreateObject("Shell.Application").NameSpace(strPicturePath).Items.Item(strFilename).ExtendedProperty("Dimensions")
End Function[/blue]
 

strongm,

Is this a VBA thing, that CreateObject("Shell.Application") does create a ShellDispatch4 object, but then the Namespace object CreateObject("Shell.Application").Namespace(strPicturePath) returns a Value of Nothing for the path I supplied, which is the string I copied from my Windows Explorer Address: C:\Documents and Settings\ii36250\My Documents\My Pictures

Using my Watch Window.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 


the CreateObject("Shell.Application") object has only Application and Parent as objects in the Watch Window.

Namespace indicates <Expression not defined in context>

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Which OS, Skip? This should work on XP and later. I've tested it on XP SP1, SP2 and SP3, Vista (original and SP1), and Windows 7 - so right now I can't say why it isn't working for you
 


XP 2002 SP2

Do I need a library ref?

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
For me, strPicturePath should the fullname of a directory and strFilename the name of an image file in this directory.
Is that the case Skip ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 


Yes, Full Path Name from the Address bar of Windows Explorer.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Ok - can we try the following? Is that Pictures folder your My Pictures folder, or are yoiu accessing somebody else's?

If it is your own, try passing &H27 as the strPicturePath parameter and see what happens (Namespace can deal with full pathnames and with the Shell's special folders, which are numerical; in this case &H27 should be the logged in users My Pictures folder)
 


Wonderful! That works for My Pictures.

But what about any other path?

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
It works for any path.
Code:
MsgBox GetPictureDimensions("c:\zzz\", "combo.bmp")
returns the correct values for me.

Handy that. Thanks strongm.

Gerry
 



OK. My problem is with calling the function from the sheet.

All is well.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 


Thanx!

==> [purple]*[/purple]

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
ricardo1023, just to get back to your original request, here is something that may start you out.
Code:
Sub BiggerThanThat()
Dim file
Dim path
Dim FirstNum() As String
Dim BigList As String

path = "c:\zzz\"
file = Dir(path & "*.jpg")
Do While file <> ""
   FirstNum() = Split(GetPictureDimensions(path, file))
   If FirstNum(0) > 200 Then
      BigList = BigList & file & " " & FirstNum(0) & vbCrLf
      [COLOR=red]' or do whatever with the file...[/color red]
   End If
   file = Dir()
Loop
MsgBox BigList
End Sub
This produces a list of all .jpg files in a given folder with a width greater than 200. Note that the function GetPictureDimensions results in a string: "width x height"


So using Split, FirstNum(0) = width. You could just as easily factor in the height.

Gerry
 
Thank you everyone. Any idea on how to get the horizontal and the verticar resolution (for example 300 DPI)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top