You may find that the database being shipped with OpenOffice (ver.2) delights you as much as it has me. This page, and the others linked to it, can help you use it.
Forget any experiences you may have had with Adabas, which came with Star Office, the commercial version of Open Office 1. The Open Office Version 2 database, "Base", aka "ooBase", is unrelated. And remember that Open Office, including Base, is free! But don't let that fool you. It's not new. Big organizations, civil and governmental, are adopting it as their standard office suite... and saving million$.
There's more about ooBase in the main index to this material.
This page is "browser friendly". Make your browser window as wide as you want it. The text will flow nicely for you. It is easier to read in a narrow window.
Page contents © TK Boyd, Sheepdog Software ®, 06/07.
You will learn how to make a small database with fields which hold images. In the tutorial they are photos, but they could also be diagrams, drawing, etc. This isn't a very demanding tutorial. But it does show you the "tricks" of something that has many uses.
Specifically, we will create a database with pictures of some North American birds. (The photos are provided for you.) Each record will consist simply of an index number, the bird's name, and the bird's photo.
Besides discussing the specific tricks to putting an image field into a database, this tutorial also gives you some help with details of creating and editing form designs.
I do go off on one little diversion, talking of extra fields you might have, but not a lot of time is spent on that.
Before we delve into the tutorial, I would like to thank the contributors to the ooBase forum at OOoForum. That is a great place to "hang out" if you want to expand your ooBase skills. Please "lurk" for a bit (read posts without writing them) if you are new to fora. There are "rules" of etiquette to be learned. Also make use of the search service. Whatever you want to know has probably already been discussed... probably several times. Get your answer now, instead of having to wait!
Create a new database. Put it in it's own folder, call it BirdsWImages. (Most of the names I've suggested could be different, if you felt strongly about it.)(Name from "BirdsW(ith)Images".)
Set up a table. (Create in Design View would probably be fine.)
Fields:
Index (Integer:INTEGER, Autovalue=yes,
primary key)
BirdsPicture (Image:LONGVARBINARY)
Name (Text:VARCHAR)
Be sure to set Index as primary key.
Save the table as BirdsWImagesT1. (The names don't have to be unique, but I like to fight ambiguity.)
A biologist doing this might say that using the "Latin" name would make sense. It would make a natural unique key, something that you always want to consider. However, in this case we're going to have more than one record per species, so the "Latin" name would only be part of the answer, anyway. (We can't, for instance, have just one picture for the mallard duck.., the male and female look different, as do the juveniles.)
The techniques explained in this tutorial allow you to store photos of whatever you want. For the sake of the tutorial, I have made a collection of photos of some birds available. (You may make whatever use you wish of those photos, except a use that restricts anyone else from doing the same. I assert ownership of their copyright. Don't get too excited... they're not good photos!)(You can access a vast library of royalty-free images online at a sister project of Wikipedia, by the way.)
They are in a "self-extracting archive" prepared with WinZip. Before you download the archive, make a folder for it. You'll use the same folder for the images that will come from the archive. The folder can be dispensed with before you finish this tutorial, so don't agonize over "the right place" for it. Once you have the folder, all you have to do is download the archive, and then double-click on it. It will start up, and ask you where (what folder) you want to store the images. It puts 10 small .bmp files in that folder. Each one is named for the bird shown in the file. Each is about 200k. (That's probably bigger than it needs to be.) (I don't know the complete list of image formats that ooBase can handle. I believe it is quite extensive.) (I tried putting an animated gif into the database. It was possible to have it in the database, but only the first frame of the animation was displayed, i.e. you could see the gif... but "paused". If anyone knows how to get it to work more fully, please get in touch?)
Once you have run the self-extracting archive once, you won't need it anymore, other than for backup. Once the database is complete, you won't need the .bmp files, either. (Copies of the images will exist within the database. There is another approach for managing image data. It is beyond the scope of this tutorial, but, in a nutshell, the database is set up to store the path to the image file rather than the image itself.)
The photos in the set you were given are all about the same size. I'll say more on the subject of the images' sizes later.
Get a form started by using the Wizard....
At "Step 1", I hit the first "little mystery": Only the Index and Name fields appeared to be available for inclusion in the form, despite an explicit note on the wizard window saying "Binary fields are always listed and selectable from the left list. If possible, they are interpreted as images." That seems to be wrong, but fear not! We're using the wizard simply to create a first draft of the form we need. You want the "Name" field, but don't need the "Index" field on our form. Click Next. (The strange conflict between what actually happens and explicit information in the wizard's text was noted in a post at OOoForum.org, too.)
Step 2: There's no need for any subforms. Click Next, which will take us straight to step 5.
Step 5: Arrange the controls "Columnar- labels on top." Click Next.
Step 6: Leave "The form is to display all data" ticked. Do not tick "The form is to be used for entering..." Click Next.
Step 7: Play with these settings if you wish... but it isn't necessary. Click Next.
Step 8: Name the form "BirdsWImagesF1", and select "Modify the form", and click "Finish".
Don't be alarmed if a few things are odd... like the labels above the edit boxes. You may need to widen the controls to see all of the text of the label.
(Most readers will be able to just go on to the next steps. If, however, you have closed the form before you start (or re-visit) the following steps, be advised that you must not re-open the form simply by clicking on its name in the ooBase project management window. You need to right-click and select "Edit". This is not a quirk of the database with images; it is an always present safeguard.)
Use View | Toolbars to be sure that the Form Controls and Form Design toolbars are showing. (You can tell which toolbar is which if you drag them away from the edge of the window so that they become floating toolbars. You drag them by the little column of dots at the left hand end.)
Be sure you are in design mode. (If you click on the already present Name-field control while you are in design mode, you will get 8 drag handles. There's a "Design Mode On/ Off" button on the Form Design toolbar to switch in and out of design mode.
If, in the wizard, you, like me, were only able to add the Index and Name fields to the form, you will add the BirdsPicture field to the form "by hand", in form design mode. You might think it would be easy, but there are a few little twists. What follows is probably at the heart of most people's problems with doing databases with images... the rest of the job is pretty straightforward. I found this part of "my" tutorial in a post by the helpful Drew Jensen in the excellentOOoForum. I have lightly modified version of what he said....
BEGIN QUOTE...
On the form design toolbar is a button for 'Form Navigator', this will be the fifth button from the left.
This opens a window with a tree view showing all your form's dataform controls.
In the case of a form newly created with the wizard, the dataform you want is named MainForm. Using your mouse select this dataform.
Back on the Form Design toolbar is a button for Add Field; it is the button just to the right of the Form Navigator button. Click on it.
This opens a window listing all of the fields in the datasource used by the dataform control. You should find "BirdsPicture" in the list.
Use your mouse to drag the image field from the Add Field window onto the form.
What you've just done should add two controls to your form, a label field and an image control.
....END QUOTE
The two controls are, at the moment, "grouped". If, still in design mode, you click on what you added you should get drag handles, and then you can move it around to just the right spot. The new label field and the new image control will move together, because they are grouped. This is good if you want to position them. It is not so helpful if you want to change something specific to one of them, for instance (as you may have to) the size of the label field.
Before you can access the specifics of either, you need to "ungroup" them. Happily this is easy.
Right-click on the group. You should see "group" on the menu, and an "ungroup" option once you click on that. Just before you ungroup the label field and the image control, click on "Control...". You'll see a few properties, e.g. enabled (yes/ no) and background color. Now ungroup the members of the group. Click outside the group's boundaries, to de-select the members of the group. (Previously, you had the group selected. It is possible to select multiple controls, in which case what you see is similar to what you see if you group them and select the group.) Now right-click on the image control, and select "Control..." again. Now you see rather more properties, and data and events tags have also appeared.
So: to work with a "broad brush", you can group things, and operate on the group as an entity. For detailed work, you need to ungroup things, and work on each control individually.
A quick word about selecting multiple objects and how to group them, and then we'll get back to the database with images.
I couldn't find a way to select multiple objects by shift-click or control-click... but there is a simple way. All you have to do is drag a box out around the objects you wish to select. The "select" tool has to be the one currently selected, but it probably is, anyway. It is the mouse pointer arrow at the left end of both the form design and the form controls toolbar.
There is one little trick to selecting multiple objects: The box you drag out must completely enclose all of every object you want in the multi-selection.
As you have probably guessed: To group (or re-group) objects: Select all the objects you want in the group. Right-click inside the selection. Click "Group..." and then "Group" again from the sub-menu. Easy when you know how!
Add a navigation bar to the form, too. It is to be found via the "more controls" button of the Form Controls toolbar.
Re-size the form and its elements to suitable sizes.
Leave the design mode. The form's now ready. Next we're going to put some data in the table's records.... words in the "Name" field (the bird names) and pictures in the "BirdPicture" field. Again, it is easy when you know how.
Now... to enter our first record. Obviously, you're not going to "type" the photo into the record... but how DO you enter a picture?
If you right-click on the image field on the form, and keep the button down (unlike a normal "right click"), you'll get "insert graphic from..." Move the mouse pointer onto the "insert graphic from..." text and then release it. A "load file" dialog should come up. Pick an graphic. It should appear in the field on your form! Fill in the bird's name. That's it!
Use the navigation bar to go to the next record. Add another image.
Beware: At this stage it would probably be a good idea to completely shut ooBase down. Close the form. Close the table if it is still open. Close ooBase.
You don't have to do this every time you enter two records! But as this is a new database, and as you are (presumably) new to adding images to a database, this double-check that all is well seems warranted. There are lots of things in computers that work once... but then mysteriously are "broken" the next time you try them from a standing start. Happily, usually if things work on the second trial, they will work on the third, fourth, fifth, etc.
Restart ooBase. Reopen the form. If all has gone well, you'll see your data!
We have a working database, with images!
After putting two .bmps into my database, one of 287k, the other of 248k, the database file (BirdsWImages.odb) was 759k.
I then went back to the database and entered three more records, involving 670k more in image data. I left the last record I entered, to "ensure" that it had been written to the database.
Here's the "odd" thing: I looked at BirdsWImages.odb again... and it was still only 759k. Here's a nasty little secret: ooBase caches things to memory. It doesn't automatically flush things to disk as soon as you might think it would. It didn't write the new data to the disk when I closed the table. It only wrote to the disk when I closed ooBase. (The file then "grew" to 1,783k.) Now... this is great for performance... but! What happens if you have a crash at the wrong moment? There is a macro you can add to your database which will allow you to force a flush- to- disk, but that's a story for another time. If you BUY a piece of my software, I will get the tutorial written up before I cash your check!
There are many ways to store images on a computer, and many choices associated with each way. As you work with images, you will learn more about...
I'll go into these in a moment, but first a word about why we care.
The different choices allow us to achieve a compromise appropriate to our needs. We have to get a balance between having a "good" image, and having an image that doesn't take acres of disk space, hours to manipulate, hours to fetch over the internet, can't be used on many people's systems, etc, etc. (That last "wished for" item might be the opposite of what we want in some circumstances. Presumably the CIA has images which it would prefer to be readable only on their computers? It can be done... with the storage format.)
One other thing, before discussing the image properties just listed: Tools. Any decent photo manipulation software will have a way to export images to a variety of storage formats, at resolutions, etc, of the user's choosing. (I like Serif's PhotoPlus, not least because Serif will give you a free copy of PhotoPlus, with no unreasonable restrictions, of a very useable, if not completely up to date, version. And if you like that, the cost of their latest/ greatest version is reasonable. (That page is sometimes unresponsive. Try it at ten minute intervals if it is not responding.) See also my page about free tools for Windows.)
If you want to get a little way into manipulating images, without "doing" very much to your computer, or taking on another learning chore, the excellent Irfan Viewer will do a lot with image re-saving, size changing, etc. While I said you might want to avoid a learning chore, and you can use Irfan for many things without any study, if you do take time in it's help files, you will find it amazingly capable. For instance: My camera puts ExIF data into my jpegs. With Irfan I can change the names "IMG0234", "IMG0235", IMG0236", etc, to "2007-06-12 12:00:00", "2007-06-12 12:01:06", "2007-06-12 12:01:58", assuming the photos were taken on June 12th, around noon... all automatically. I don't have to type in all that "stuff"... Irfan will pull it from the image's internal data.
So! Back to the mini tutorial on images...
Storage formats: You've probably heard of "bmp", "jpeg", etc? These are storage formats. They each have pros and cons... or else one would have replaced all the others, and life would be easier. If less full of choices. Don't worry... as long as you let your government officials let Microsoft do what it likes, it won't be long before the spurs to Microsoft's creativity are driven out of business, and then Microsoft can stop bothering with giving us choices. Miao.
Resolution: This is the "pixels per inch" property of an image, also called "dots per inch", or dpi. It is only meaningless if you have defined the size of the image you are looking at. The same image, printed once at 8" x 12" and a second time at 4" x 6" will "have" different resolutions... the big one's resolution... pixels per inch... will be lower. Note that if you were to re-do the image so that it, at a given physical size, went from 100 dpi to 200 dpi, you wouldn't double the amount of disc space needed to store it... you would quadruple the storage space need.
Image size: This can mean several things. It may refer to the physical size of the image on the page or screen, i.e. something like 8" x 10", or it may refer to how much space is needed on a disk to store the image, or it may refer to the dimensions of the image in pixels. "Image size" in that sense and resolution interact the way speed, time and distance-travelled interact.
Color depth: Some images have only black, shades of grey, and white in them. They have a very low color depth, although even here you are speaking of color depth when you start talking about how many shades of grey are present. A fancier image may have some colors, but not a large number of different colors. If your image has more different colors, and shades/ tints of colors, then it has a greater "color depth".
By now, you are probably wondering "Why is he talking about image properties?"
The reason is that you need to master them to make the right choices, and to prepare your images properly for inclusion in your database. Err one way, and the quality of the images will be inadequate. Err the other, and the images will take up so much space in the database, and hence on your disk, that the database runs slowly.
If you reopen the form we made for viewing the birds database, ungroup the image control if necessary, and look at its properties, you'll see one called "Scale". Before IO say what that will do, one thing that it won't: It won't cause the size of the image object on your form to change, regardless of how you set it.
If this is set to "Yes", then any image that you view with the form will be stretched shrunk as necessary to make it exactly fill the image object on the form. As long as all of your images have the same aspect ratio as each other and as the image object, all will be well. (Aspect ratio: The answer you get if you divide the height of the image by its width.) Even if all of your images have the same aspect ratio, you may still regret having "Scale" set to "Yes" because it will hide problems. If your images are bigger than they need be to fill the box on the form, you are wasting disc space. If they are smaller, you are not getting a "better" picture just because you've blown it up. In extreme cases, you'll see pixellation... the little squares, one per enlarged pixel.
If your images do not all have the same aspect ratio as the image object on the form, then if "Scale" is set to "Yes", the images will be displayed with distortion. A panorama will fit in a square... as long as you don't mind it being "squished" in its horizontal dimension.
So! What are the disadvantages of setting "Scale" to "No"?
You may prefer distortion to not being able to see all of an image, which is what will happen if the image is too big for the image object. If all of your pictures have similar aspect ratios, even if they are not all exactly the same, you may never notice the distortion. Setting "Scale" to "Yes" also produces a "tidy" result with less effort.
Well. There you have it. We've....
Best wishes to you in your database work. Please spread the word about ooBase. A visit to my freeware page (see below) would be appreciated, too!
I dislike 'fancy' websites with more concern for a flashy appearance than for good content. For a pretty picture, I can go to an art gallery. Of course, an attractive site WITH content deserves praise... as long as that pretty face doesn't cost download time. In any case....
I am trying to present this material in a format which makes it easy for you to USE it. There are two aspects to that: The way it is split up, and the way it is posted. See the main index to this material for more information about the way it is split up, and the way it is posted.
PLEASE >>> Click here to visit editor's Sheepdog Software (tm) freeware, shareware pages <<< PLEASE
If you liked this ooBase tutorial, see the main index for information other help from the same author.
Editor's email address. Suggestions welcomed! - - - Want a site hosted, or email? I like 1&1's services.
Page tested for compliance with INDUSTRY (not MS-only) standards, using the free, publicly accessible validator at validator.w3.org
. . . . . P a g e . . . E n d s . . . . .