Image Thumbnails in Access Forms This sample illustrates how to generate a thumbnail when storing an image with DBPix in an Access photo/picture/graphic database application. Examples are provided for both embedded and external-file storage (ie images stored in the database tables, or as external image files).
Thumbnail and Detail images are stored at fixed resolutions/sizes (see also the related forms in the sample that make use of the pictures). The images are also suitable for publishing via a web-browser interface, as illustrated in the various web samples.
Note that this sample is now updated for DBPix 2.0, and is incorporated into the Main DBPix sample - the latest version is available below:
DBPix Image Control version 2.0.
Microsoft Access 2000 or later.
Unzip the archive into a new/empty folder.
Open the form 'Embedded_Main' or 'External_Main', to work with embedded images or external files respectively.
Use the form navigation buttons to view the existing records in the database. Right-click on the main image to see the available tools or to display image info (such as the EXIF digital camera photo info).
Scroll to a new record and add an image, either by right-clicking the main image control and using the context-menu to load, paste or TWAIN-acquire an image, or by dropping a file. The main and thumbnail images are created automatically, and stored in the table or as external files as appropriate. After saving the record the image can also be viewed in the corresponding 'Multi' form.
Two DBPix controls are used on the form, one for the thumbnail and one for the detail image. Both are configured to resample (resize) new images to fixed dimensions, and store them using appropriate JPEG settings. The thumbnail control is also configured to strip any image metadata (such as EXIF digital camera photo info) to keep the thumbnail size as small as possible.
Whenever the user modifies the image in the Main DBPix control, the control's 'ImageModified' event fires. The event handler copies the image from the main control into the thumbnail control, which resamples and encodes/compresses the image according to its configuration. Additionally the image dimensions are saved in the table - these are useful for adding a web-browser front-end.
In the Embedded version of the sample the DBPix controls are bound to table fields, so changes are saved to the table automatically. In the External version, the 'ImageModified' event-handler also saves the updated images to files (using the record Id as the filename, and in the 'Images' subdirectory relative to the location of the .mdb file). To display images when the user opens or scrolls the form, the form's 'OnCurrent' event is handled, and loads the main and thumbnail images into the two controls
Files & Code
|File / module|| ||Description|| || |
|Embedded_Main|| ||Form module for the 'Embedded' example|| ||View Code|
|External_Main|| ||Form module for the 'External' example|| ||View Code|
|GetImageFolder|| ||Returns the path for external image files|| ||View Code|