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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to fill a table with images 1

Status
Not open for further replies.

german12

Programmer
Nov 12, 2001
563
DE
I have a Vfp-Table - its name = "Mypics"
500 records.
Structure:
Field.. Field-type
Nummer... character
Titel ... character
Bild ... General

Beside that I have a file with 500 pictures. File-name = "mypictures"
Now I want to fill the field "Bild" in table "mypics" with the images in the sequence of file "mypictures"

How can I do it with a loop?

Thank you in advance
Klaus


Peace worldwide - it starts here...
 
what is the advantage of using APPEND GENERAL compared to store filetostr() in a table ?

Good question. The main reason is that a General field stores the actual image, which can then be viewed, for example in a Browse, or bound to an OLE field in a report. FILETOSTR() on the other hand, just stores a character string. (Scott's code would only work if Bild was a Character or Memo field, which it isn't.)

That said, I strongly agree with the idea of not storing the image in the table, but rather keeping the image file separate and just storing its path and file name in the table. I only mentioned the General field in direct response to Klaus's original question.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 

Chris Miller said:
Seems to me, VFP can't make use of "Package" as a host of an ole image object in a general field.

"Package" doesn't support preview snapshot.

mJindrova
 
I see, thanks mJindrova.

Do I get that right?
That means Pckage is okay to have a low size storage in general fields, but the stored jpeg then isn't displayed?
So if you want to show the images you have to associate with Paint.Picture anyway? Or is there a way to see the image when it's associated with the class Package?

Chriss
 
Chris Miller ,

I don't knows host OLE application which save jpeg and presentation stream at once.
Paint.Picture suppots bmp only.
MS Graph use WMF/EMF only.



mJindrova
 
First of all, I would like to thank everyone who has replied to my question so far.
I am very surprised at the multitude of answers (all were qualified, no "yearwoods")

Meanwhile, the argument has convinced me, that the image files
should not be embedded in a VFP table.
That's why I changed the field types in the table for taking over the image descriptions, they are all of the Character type
now.

The SCOTT24x7 program (see at bottom) runs very quickly with it
and automatically assigns a 4-digit number to each image as well
the name of the picture:

Mypicsshot_ghespj.jpg


The image file with over 500 watercolors, drawings and experiments by me which were created in the last 20 years and looks like this, for example.
zeigeeinpaarbilder_myhjz2.jpg


For these pictures I also have written references to the
content made that still needs to go into the "Titel - engl.= "Title" column.
e.g. "mountains", "trees", "animal name", "beach" etc.

It should then also be possible to display groups of images with similar content or similar size on the screen using an SQL query.
I recently spent an awfully long time looking for a certain painting of mine - hence the idea of speeding up such a searchit with VFP in future.
With the picture no. and the image on the content, I can find a specific painting much faster.

I still have to think about how to get old frame numbers
can hold on to if new photos of my paintings are added to the inventory.
But that is not an issue in the moment.
Should perhaps be a separate program.

I hope I have specified the goal of my thread.

Regards
Klaus




Code:
*Program: getbild.prg

*This code was written by Scott24x7 (see text at the end of this code) and small modified/adjusted by me.
*It fills the following columns of table Mypics with a generated 4-digit number
*in field NUMMER, and the description of *.jpg images in field Bild

*the images reside together with this program in folder C:\entw\produkt\bilderhol\mypics.dbf
*All field-types in Mypic.dbf are characters.



Close Data
Use Mypics In 0  && Open the table
                 && Table structure: Nummer c(6) , Titel c(60),Bild c(60) 

*-- Get the number of files in the "mypics" folder
lcFolderPath = "C:\entw\produkt\bilderhol\mypics.dbf"  && Replace with the actual path to the folder
lnFileCount = Adir(laDirInfo,lcFolderPath + "*.jpg")  && Replace ".jpg" with the actual file extension of your pictures

CLEAR

*-- Loop through the files and add a record for each file

For i = 1 To lnFileCount
      lcPicturePath = lcFolderPath + laDirInfo[i, 1]
      lcNummer = Padl(i, 4, "0")  && Generate a 4-digit padded number for the record
      Insert Into Mypics (Nummer, Bild) Values (lcNummer, Filetostr(lcPicturePath))
Endfor
Browse
Close Databases


*!*	------------------------------------------------------------------------------------------------------------------------
*!*	this was the Orginal-code by SCOTT24x7
*!*	USE Mypics IN 0  && Open the table

*!*	*-- Get the number of files in the "mypictures" folder
*!*	lcFolderPath = "C:\path\to\mypictures\folder\"  && Replace with the actual path to the folder
*!*	laFiles = ADIR(laDirInfo, lcFolderPath + "*.jpg")  && Replace ".jpg" with the actual file extension of your pictures
*!*	lnFileCount = laFiles[0]

*!*	*-- Loop through the files and add a record for each file
*!*	FOR i = 1 TO lnFileCount
*!*	   lcPicturePath = lcFolderPath + laFiles[i, 1]
*!*	   lcNummer = PADL(i, 4, "0")  && Generate a 4-digit padded number for the record
*!*	   INSERT INTO Mypics (Nummer, Bild) VALUES (lcNummer, FILETOSTR(lcPicturePath))
*!*	ENDFOR

*!*	*-- Close the table
*!*	CLOSE DATABASES


Peace worldwide - it starts here...
 
Scott:
Scott: Klaus said:

I hope to have answered this above and I agree now with what Mike Lewis and Mike Gagnon and others said
No embedding in table is necessary.

I still have to think about how to get old frame numbers
can hold on to if new photos of my paintings are added to the inventory.
I can automatically form a 4-digit number
use, because with it I can easily label the original paintings and keep them in the archives.
Your suggestion with memo fields is also good, but with the program I save myself having to specify numbers.

I just have to figure out how to not destroy the existing numbering
from presently about 500 pictures when new pictures are added.
For example, the image that has the number 0001 must always have this number
remember, your program would then destroy the mapping if
I restart it with another bulk of photos.

Also, I'm still not sure how to add images or a group of
show images on the screen. (pre-made image objects, a grid or even page-frame?)

Thank you very much for your help.
Klaus

Peace worldwide - it starts here...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top