Linking thumbnails into a database

Ask for help and post your question on how to use XnView Classic.

Moderators: helmut, XnTriq, xnview

Post Reply
T(r)opdude

Linking thumbnails into a database

Post by T(r)opdude »

Great program!

Is there a way that thumbnails can be linked, imported and/or displayed into a database (e.g. Excel, FoxPro, Paradox, or any other heavy duty database-program)?

In my case, such a database contains the relevant info of the image (title, geographic location, notes, subject, etc.) as text fields, and when browsing or searching the database it would be extremely useful to see a small thumbnail of the image next to its description. Many databases these days can handle images in a separate field.
User avatar
Clo
XnThusiast
Posts: 4441
Joined: Sun Oct 17, 2004 4:57 am
Location: Bordeaux, France
Contact:

Workaround ?

Post by Clo »

:) Hello !

- AFAIK, such a feature is missing till today…

- I know only one APP. which builds a data-base from the thumbnails it displays : it's Total Commander which can use XnView as a partner program to do this…
- All thumnail-options of XnView are imported there too.
- This file is located under XP as the variable :
%$LOCAL_APPDATA%\GHISLER

- Under Win 9x, this file <tcthumbs.db> is located the most times in the directory of Total Commander.
- I know this is not a very good reply, but if this *.db format is standard, maybe could you play with it and use for some "heavy" APPs you quote…
- You must display the thumbnails in TC once to get the *.db file, no more.

:mrgreen: Kind regards,
Claude
Clo
Old user ON SELECTIVE STRIKE till further notice
t(r)opdude

Post by t(r)opdude »

for excel, i found this sub-optimal poor-man solution:

You can insert your scanned receipt image into a comment on that cell.
Select the cell.
Right mouse, Insert Comment
Doubleclick the border of the comment to open the Format Comment dialogue box.
Select colors and lines tab.
Open the drop down box against Color and select Fill Effects...from the bottom.
Select the Picture tab.
Select the picture of your receipt.
Click OK until dialogue box disappears.


Any suggestion how to automatize this, so, for example, in a simple two-column format (column 1: image number, column 2: thumbnail image) the 1111.jpg thumbnail will match the row with image number 1111 - and so on for slides (=rows) 1-50,000?
t(r)opdude

script for excel with thumbnails

Post by t(r)opdude »

http://blogs.officezealot.com/charles/a ... /3019.aspx

Code: Select all

Sub AddPictureToComment() 
Dim rng As Range 
Dim shp As Comment 
Dim fs As Object 

Set rng = ActiveCell 
Set fs = CreateObject("Scripting.FileSystemObject") 

If rng.Text <> "" Then 
If fs.fileexists(rng.Text) Then ' check if the filename as specified in the text exists 
If Not rng.Comment Is Nothing Then ' check if there is a comment already in the cell 
rng.Comment.Delete 
End If 
Set shp = rng.AddComment("") 
shp.Shape.Fill.UserPicture rng.Text 
Else 
Debug.Print "File: """ & rng.Text & """ does not exist" 
MsgBox "File: """ & rng.Text & """ does not exist" 
End If 
End If 

Set fs = Nothing 
End Sub
Anybody knows how to run this on multiple cells at the same time?
User avatar
helmut
Posts: 8704
Joined: Sun Oct 12, 2003 6:47 pm
Location: Frankfurt, Germany

Re: script for excel with thumbnails

Post by helmut »

t(r)opdude wrote: Anybody knows how to run this on multiple cells at the same time?
The code below is based on your above sample. It will check the range you specify as parameter of function AddPictureToComment() for image files and place the image in the comment.

Code: Select all

Option Explicit

Sub AddPictures()
    AddPictureToComment range("A1:C10")
End Sub

Sub AddPictureToComment(pRangeWithFilenames As range)
    Dim fs As Object
    Dim rng As range
    Dim shp As Comment
    Dim lRow As range
    
    Set fs = CreateObject("Scripting.FileSystemObject")
    
    For Each lRow In pRangeWithFilenames.Rows
        For Each rng In lRow.Columns
            If rng.Text <> "" Then
                If fs.fileexists(rng.Text) Then ' check if the filename as specified in the text exists
                    If Not rng.Comment Is Nothing Then ' check if there is a comment already in the cell
                        rng.Comment.Delete
                    End If
                    Set shp = rng.AddComment("")
                    shp.Shape.Fill.UserPicture rng.Text
                Else
                    Debug.Print "File: """ & rng.Text & """ does not exist"
                    MsgBox "File: """ & rng.Text & """ does not exist"
                End If
            End If
        
        Next
    Next
    Set fs = Nothing
End Sub
- Before using your solution heavily, you should make a test with many images and watch the size of the database (Excel sheet).

- Rather than MS Excel you might consider using MS Access or another database to properly link the images in.

- As you probably know, there's various database programs available. Perhaps there's even (Open) source code if you intend to customize it for your own needs.
Post Reply