"Attachment Size"

unclefink

Registered User.
Local time
Today, 10:12
Joined
May 7, 2012
Messages
184
I have a database which contains a field with a .jpg attachment. I am in the process of decreasing the size of each attachment to reduce redundancy and increase consistency.

I have roughly about 600 photographs I am currently working with and due to the nature of the database, additional pictures will continue to be added. What I would like to do is create a query and have that query only show me attachments which are larger than 800X600 pixels. I can run this query as part of my maintenance and reduce those photographs to a more desired size.

What I don't know how to do is add a criteria to my query to only retrieve pictures larger than this specific size. Any recommendations, is this possible?

Respectfully,
 
you should be able to get that from the FileData eg Len(filedata)

On your query (using the QBE), the attachment fields 'sub properties' should show in the tables field list. So set a field as Len(FieldName.FileSize) and set the criteria as ">xxxx". This should give you a list of attachments over the size of xxxx. Include the FileName sub property to identify the actual file.

EDIT:
There is also a very interesting article here on deleting a single attachment from an attachment field containing multiple attachments.
 
Last edited:
Please forgive me for asking and the continued questions. What is QBE and how do I apply this. Can you show me an example?

Respectfully,
 
Sorry, QBE is just the screen you see when designing/editing queries.
 
Can you give me an example for this process, its not working as planned.

Thanks for the help.

Respectfully,
 
see the attached :)

Incidentally i noticed i had put the wrong sub property in my earlier post, it should be FileData
 

Attachments

Isskint,

Thank you very much for your assistance thus far, This is really a great start to what I was looking for. Objectivly I am looking for any pictures more than 600X900 pixels, in looking at the kb size of pictures such as this there is a variation in "kb" size as color quality and so on will change and vary the overall size from picture to picture. Is there a way to give the "pixel" size data in the query.

Alternatively, given a max size of "600X900 Pixels" is there a "kb" size you would reccomend for my criteria. The tough part is as mentioned, the file size can vary based on color, size, quality and so on. What i've noticed as i change the photographs to 600X900 the overall db size is consistently decreasing and making management easier for what I am trying to do for this specific db.
 
hmmm, interesting, have a look Here
 
Last edited:
Have a look at this post. It will enable you to clean up your oversize attachment field files.
 
Thank you so much for the solution, Isskint! and thank you, unclefink for posting the question! I need to weed out large pdf files in my database, and this is exactly what I needed to do it! :)
 
This checks the size of a file not the resolution of the image. Certain file types have larger and smaller file sizes which kind of makes this way pointless to what the requested function is.
 
Try this code out :)
Code:
' REFERENCE: Microsoft Scripting Runtime

Private Sub Command0_Click()
    Dim fdlg As FileDialog
    Set fdlg = Application.FileDialog(msoFileDialogFilePicker)
    
    With fdlg
        .AllowMultiSelect = False
        .Filters.Clear
        .Filters.Add "PNG", "*.png"
        .Filters.Add "JPG", "*.jpg"
        .Filters.Add "JPEG", "*.jpeg"
        .Filters.Add "GIF", "*.gif"
        
        If .Show Then
            MsgBox GetImageSize(.SelectedItems(1))
        End If
    End With
End Sub


Private Function GetImageSize(ByVal address As String) As String

    Dim SH As Object
    Dim fImFile As Object
    Dim FOL As Object
    Dim fs As FileSystemObject
    Dim size As String
    
    Set SH = CreateObject("Shell.Application")
    Set fs = New FileSystemObject
    Set FOL = SH.Namespace(fs.GetParentFolderName(address))
    
    For Each fImFile In FOL.Items
        If fImFile.Name = fs.GetFileName(address) Then
            GetImageSize = FOL.GetDetailsOf(fImFile, 31)
            GetImageSize = Mid(GetImageSize, 2)
            GetImageSize = Left(GetImageSize, Len(GetImageSize) - 1)
            Exit For
        End If
    Next
    
End Function
 
Last edited:
Isskint & BlueIshDan - 7ish years later, I came across this and it is exactly what I need for a project I'm working on. Thank you
 

Users who are viewing this thread

Back
Top Bottom