Trust ID PBCEX logo 300x102

How do I store photos in the database?

12 years 9 months ago
Rutger Koperdraad
Platinum Boarder
Platinum Boarder
Posts: 1566
More
Topic Author
How do I store photos in the database? #38
Question: I tried to configure CardExchange to store its photos in the database, but I have the following problem. When I take a photo, it on correctly shown on the card preview, but when I select another record and then select the first record again, the photo has disappeared. Aparently,the photo is not stored in the database.

Answer: You probably forgot to define a storage item for the photographs. For point-to-image photos, it is enough to map the photo field, but for storing the entire photo in the database, you need to do one step more. Anything you want to store in the database requires a storage item. Photos are no exception to this rule.

For storing photos in a database, you need at least Premium. Furthermore, you need to use Microsoft Access or a relational database. You cannot store photos in Excel or comma-separated files. The steps needed for storing a photo are described below.

1. Define a storage item
Open the data-definition wizard and go to the last wizard page, where the storage items are defined. Add a storage item called Photo and select the correct table, primary key and column for storing the photo. If the photo is stored in the table that is also used to read data from, that is, the table you selected on the second wizard page, make sure that you select the same primary key. If you store the photo in a different table, the primary key field you select for the photo table should contain a valid reference to the corresponding record of the table or view you read from.

2. Mark the storage item as image store
Select the option Use selected column to store images in the last page of the data-definition wizard. By selecting this option you inidicate that this storage item should be processed when you take a picture, and not after successfully printing a card.

3. Map the storage item as photo
The next step is to indicate that you want to use this storage item for photos. Close the data-definiton wizard and go to the card-item properties (version 2 and 3) or the mappings page of the card-definiton wizard (version 4). Select Photo in the Storage items tab of the navigator on the left hand side. Then choose the option Photo in the drop-down menu on the top of the window (Type of data to be displayed in the selected card item). Select the field in the database that contains the photo and select the option The database contains the image data.

As you can see, when the photos are stored in the database, you have to do the photo mapping twice. First for the visible object on the card and then for the photo storage item.

Rutger Koperdraad
Senior Software Engineer

"A reasonable man adapts himself to the world. The unreasonable man persists in trying to adapt the world to himself. All progress, therefore, depends on the unreasonable man." (Bernard Shaw)
12 years 3 months ago
Craig Bechelli
Administrator
Administrator
Posts: 624
More
How do I store photos in the database? #451
Hi Rutger,

I undersand the photo's are stored in the database as BLOB files, but what is the format of the photo ?
Am I correct in thinking that it is always a JPEG ?
Is there any way to specify another file format when saving into a database ?

Craig Bechelli
CardExchange Solutions Support Team

"If you define the problem correctly, you almost have the solution." (Steve Jobs)
12 years 3 months ago
Sergio Agostinho
Administrator
Administrator
Posts: 508
More
How do I store photos in the database? #455
Hi Craig,

The images are stored in databases in a BLOB format (A binary large object, also known as a blob, is a collection of binary data stored as a single entity in a database management system. Blobs are typically images, audio or other multimedia objects, though sometimes binary executable code is stored as a blob. “From Wikipedia”)

The BLOB works like a container where the image or another object like a pdf for ex can be stored. It has a sort of header that includes the image format(for example, BMP files always have BM in their header, GIF files have GIF, JPEG have JFIF, PNG have PNG, etc). The Microsoft access database engine uses those headers to know what image is stored, but to make a tool to import/export them another approaches can be taken, like store the file type on another column than the actual file data or concatenate the file format as string like BMP-<blobdata> in the blob field.

The size of the storage image will be the size of it, it’s recommended to cut or resize it to smaller dimensions to avoid long time delays when loading them. CardExchange doesn’t have any feature to define the image storage size, only the ratio is configurable. The image can be only changed using image tools.

With best regards,
Sergio Agostinho

With best regards
Sergio Agostinho
12 years 3 months ago
egumo
Fresh Boarder
Fresh Boarder
Posts: 9
More
How do I store photos in the database? #458
Can you configure card exchange to get an image from file and store it in the BLOB? If we are unable to define the size and type from the camera uning image exchange, can we set card exchange to pick a JPEG picture from the network and transfer this to the BLOB?
12 years 3 months ago
Sergio Agostinho
Administrator
Administrator
Posts: 508
More
How do I store photos in the database? #463
There is a way to do it more or less automatically.
Map you photo filed to the database column where you want to store it (as a BLOB)
[attachment=1:2a9upkyq]<!-- ia1 -->Screen1.jpg<!-- ia1 -->[/attachment:2a9upkyq]
Go to "Photo options", select the "Options tab" and select import image for both option.
[attachment=0:2a9upkyq]<!-- ia0 -->Screen2.jpg<!-- ia0 -->[/attachment:2a9upkyq]
Print all cards to some dummy print like "Microsoft XPS Document Writer"
Now for each card you will be asked to select the image that you want to use on it, get it from you pictures folder, and after the print process it will be stored in the database.

With best regards
Sergio Agostinho

With best regards
Sergio Agostinho
Attachments:
12 years 3 months ago
Rutger Koperdraad
Platinum Boarder
Platinum Boarder
Posts: 1566
More
Topic Author
How do I store photos in the database? #465
Hi,

If your photos as stored as image files and you want to import them into BLOB fields in the database, the following option may be interesting to you. It is not possible to do a massive import of photo files into BLOB fields, but you can configure CardExchange to import a photo file into a BLOB field at the moment the card is being printed. To achieve that, you need to configure the following:
  • Define a storage item for the BLOB field and select the option "Supply new value for selected column". This option assures that the storage item is processed after printing and not when taking a photo.
  • Map both the photo object on the card and the storage item as photo usgin the point-to-image option.

Now, when a photo is taken it is stored as image file. When the card for that person is printed, the image is stored as BLOB in the database. Please, also note that BLOBs written by CardExchange alwayshave the JPEG format.

Rutger Koperdraad
Senior Software Engineer

"A reasonable man adapts himself to the world. The unreasonable man persists in trying to adapt the world to himself. All progress, therefore, depends on the unreasonable man." (Bernard Shaw)
12 years 2 months ago
egumo
Fresh Boarder
Fresh Boarder
Posts: 9
More
How do I store photos in the database? #528
Rutger,

We have setup the system as recommended and have the following issues. When we take the photo, it is stored as a 11.7KB JPEG image. At print, the photo is tranfered to the database correctly. When we extract the photo from the database, we have found the image is over 500KB. Why is this?

I would expect the 11.7KB photo to be transfered to the database in its original size. Is Card Exchange converting the photo to a BMP before tranferring it to the database? As you have told me in the past, all BLOBs are always written in JPEG, but i dont understand why the size of the BLOB grows to be 500KB
12 years 2 months ago
Rutger Koperdraad
Platinum Boarder
Platinum Boarder
Posts: 1566
More
Topic Author
How do I store photos in the database? #529
Hi Eric,

Unfotunately, I have not been able to reproduce this. Can you provide a data folder or show more details about the setup? Which version are you running?

Rutger Koperdraad
Senior Software Engineer

"A reasonable man adapts himself to the world. The unreasonable man persists in trying to adapt the world to himself. All progress, therefore, depends on the unreasonable man." (Bernard Shaw)
12 years 1 month ago
egumo
Fresh Boarder
Fresh Boarder
Posts: 9
More
How do I store photos in the database? #552
I have emailed the setup to the support email address. if you need any more info, please let me know

Eric
8 years 11 months ago
gaston
Senior Boarder
Senior Boarder
Posts: 73
More
How do I store photos in the database? #2541
Hi Team,
Even though I'm using point to point for the photo, can I store the path when I take a picture in a column in my sql table?

We've found some older records that store the photos in randomly generated folders (before we switched to CE), we're not necessarily looking for the old photos, but other departments that use our table for reference are asking for the photo path. What would be the easiest way to do this?