David's Astronomy Pages
Image Database Details



  Home
Image
Database
  Home
Home
Page
 

Bullet Database
Bullet Web Publishing

Database

A listing of my key images held on my website is stored in an Excel spreadsheet.

Each image is recorded on a separate row. At present some 70 columns are available for recording various properties and information pertaining to each imag, however on average an image will have information on only around 30 fields.

The main fields are Image File Name, Image Title, Image Type (CCD, Astrophoto, Drawing), Image Subject, Image Description.  CCD Images for example will then also record CCD Camera,  Optical Setup, Image Scale (arc sec/pixel), processing etc.  

The Spreadsheet comprises Image Data Sheet, a General Data Sheet and Macros.  Actual images are held with an images folder on my local web.  

Image

Back to Top


Web Publishing

A Visual Basic script is used to publish index pages listing all images in the database by subject category (eg.  Moon Index) and a web page container for each image (see example page for M1 image).    These static pages are then uploaded to the internet.  

A control column in the spreadsheet (a Y or blank field), is used to determine whether a particular image web page is regenerated when the script is run. 

The VBA macro is some 1000 lines long. The first part of the macro picks up general variables (such as web location, image folder, email address etc) from the General Data sheet.  The second part goes through the list of images on Image List Sheet and writes the Image Index Page in html. The third part goes through the Image List Sheet again and writes an html page for each image flagged for publishing.

The advantages of maintaining a database and using a script to generate web pages is that changes to one or more web pages can be easily made, new pages can be added in the confidence that they with have the same format and major revisions to the style and format of the pages can be easily made without needing to edit each page individually.

The most important components of the script, relating to the crucial third part, are shown below. 

Start :
Sub BuildWebPages()

' stop screen updating during macro
Application.ScreenUpdating = False

Selection of Cells with Image Information :
Sheets("ImageList").Select
Range("A1", Selection.SpecialCells(xlLastCell)).Select

iRows = Selection.Rows.Count
iColumns = Selection.Columns.Count

Definition of columns :
' Define List Of Columns (just first 3 columns are shown here)
ColPublish = 1
ColFileName = 2
ColFileType = 3

Looping round for each image  : 
For iR = 3 To iRows  ' NB rows 1 and 2 are headers

Assembling Image Information from  Spreadsheet Cells :
ImageFileName = Trim(Selection.Item(iR, ColFileName).Value)
ImagePublish = Trim(Selection.Item(iR, ColPublish).Value)
ImageFileType = Trim(Selection.Item(iR, ColFileType).Value)
ImageName = Trim(Selection.Item(iR, ColName).Value)
ImageSubject = Trim(Selection.Item(iR, ColSubject).Value)
ImageDate = Trim(Selection.Item(iR, ColDate).Value)

Opening of a file for writing html page :
' Open Index Page
HtmFileName = ImageFileName & ".htm"
iWebPage = FreeFile()
WebPage = WebFolder & HtmFileName
Open WebPage For Output As iWebPage

The writing of html code to the file : 
' Write Web Page Header
Print #iWebPage, "<html>"
Print #iWebPage, "<head>"
Print #iWebPage, "<title>Main Inventory (Richweb AstroImage Database)</title>"
Print #iWebPage, "</head>"

The placement of the image name at top of the web page : 
Print #iWebPage, "<font size=""5"">" & ImageName & "</font>"

The placement of the image on the web page : 
' Put Picture
ImageFileURL = ImageFolder & ImageFileName & "." & ImageFileType

Print #iWebPage, "<div align=""center"">"
Print #iWebPage, "<table border=""4"" cellpadding=""0"" cellspacing=""0"">"
Print #iWebPage, "<tr>"
Print #iWebPage, "<td><img border=""0"" src=""" & ImageFileURL & """></td>"
Print #iWebPage, "</tr>"
Print #iWebPage, "</table>"
Print #iWebPage, "</div>"

The placement of the information table below the image  : 
Print #iWebPage, "<div align=""center"">"
Print #iWebPage, "<table border=""0"" width=""95%"" cellpadding=""0"" cellspacing=""0"">"
Print #iWebPage, "<tr><td width=""55%"">&nbsp;</td><td width=""5%"">&nbsp;</td><td width=""40%"">&nbsp;</td></tr>"

The placement of text information about the image : 
' Put Description and Note 1
Print #iWebPage, "<tr><td valign=""top""><font face=""verdana, arial"" size=2>"
Print #iWebPage, "<b>Description:</b><br>"
If ImageDescription1 <> "" Then
  Print #iWebPage, ImageDescription1 & "<br>"
End If

If ImageNote1 <> "" Then
  Print #iWebPage, "<br>" & ImageNote1 & "<br>"
End If

Print #iWebPage, "<p></font></td>"
Print #iWebPage, "<td></td></tr>" 

' Other information sections would normally follow below


End Table of Text  :
Print #iWebPage, "</table>"
Print #iWebPage, "</center>"
Print #iWebPage, "</div>"

Write Web Footer and Close File :
' write Web Page Footer
Print #iWebPage, "</body>"
Print #iWebPage, "</html>"


'close web page
Close iWebPage

End Loop  :
Next iR

Finish : 
' resume screen updating during macro
Application.ScreenUpdating = True

End Sub

Back to Top


This Web Page: Image Database Details
Last Updated : 2015-05-16
Site Owner : David Richards
Home Page : David's Astronomy Web Site