Photo Grotto Photo server.

Introduction

Photogrotto is an http photoserver. The photos are saved in a database such as postgresql which can handle large fields of binary data representing the photo. The photo requested though the http protocol, resized, converted to an acceptible image format, number of colors changed as needed.

Photogrotto has the following features.

Photogrotto is a multi-threaded application with the ability to accept and process multiple simultanious requests for photos.

Photogrotto was designed using Qt 4.2.x and ImageMagick 6.3.x. The reason for using ImageMagick instead of the Qt image manipulation classes was to allow this application to run without an X server.

A long term goal is for it is to be able to serve semi-static html content available for a given image. This will most likely be used from within an iframe.

Download the Source

The source is available at ftp://ftp.linuxlots.com/pub/photogrotto

Invoking the server

The is started with the follwing command line:

photogrotto -f [xmlfile]

The parameter xmlfile should point to the xml file defining the servers operation.

Making requests of the server.

The precise defintion of the requests are controlled by the XML definition for the server. There are a few things that are common in all cases. In general the format of a URL to request an image is:

   http://<servername>[:<port>]/<image_name>.<ext>[?<options>]

The servername would be something like images.clockstop.com. The port is a number, if not specified, the browser will most likely use 80. The ext defines the format of the image to return. The server will convert the image to any supported format. The following extensions can be used for the requests:

Other formats may be available as well depending on the configuration and compilation of the ImageMagick libraries.

The follwing options will be honored:

If no option is given, the image will be returned as it is in the database. The image may be scaled depending on the cachDimension defintion in XML file for the server.

Photogrotto Server XML File Definition.

The operation of photogrotto is controlled by an XML configuratin file. Thie file specifies what address the server should listen on, the names of the webservers it will respond to requests for. The databases and the queries to use to access the images for each server.

Here is an example configuration file

<configuration>
   <!-- 
      Specify the log file to send logging info to
   -->
   <logfile name="/var/log/photogrotto.log" />

   <!--
      Specifiy the IPAddress of the interface and Port number to listen on
      for requests. Currently only one listen definition can be given.
   -->
   <listen port="8081" address="24.154.32.42" />

   <!--
      Start the definition of a server. Specfiy the host name which will be
      passed in for the request.
   -->
   <server name="www.k9country.com:8081">

      <!--
         Specify the database name and type of database. Any valid database
         type there is a plugin for can be specified here
      -->
      <database name="k9kinship" type="QPSQL">

         <!--
            Specifiy the connection information for the database.
         -->
         <connection host="db1.server.com" port="5432" user="myname" table="dog_pictures" />

         <!--
            Define the sql statement required to fetch the desired image.
            Currently "raw" is the only valid format. 

            The tag :resource will be expanded to the requested file name
            of the image. As an example, if the complete url is

            http://www.k9country.com:8081/113-203.jpg?width=200

            :resource will be expanded to 112-203.jpg
         -->
         <sql format="raw">
            <![CDATA[ 
               select dog_pictures.pic
                  from dog_pictures
                  where dog_pictures.dog || '-' || dog_pictures.ident || '.jpg' = :resource or
                     dog_pictures.dog || '-' || dog_pictures.ident || '.png' = :resource or
                     dog_pictures.dog || '-' || dog_pictures.ident || '.xpm' = :resource or
                     dog_pictures.dog || '-' || dog_pictures.ident || '.bmp' = :resource or
                     dog_pictures.dog || '-' || dog_pictures.ident || '.xbm' = :resource
            ]]>
         </sql>
      </database>

      <!--
         Define the maximum size of the largest size of the image to be
         servered. Requests for any size larger will result in an image
         with it's largest size set to max_dimension.

         Cache_dimension is the size of the largest side of an image will
         be scaled to when saved in the image cache.
      -->
      <image cache_dimension="1024" max_dimension="1024" />
   </server>

   <!--
      Define more servers as needed
   -->
   <server name="images.clockstop.com:8081">
      <database name="clockstop" type="QPSQL">
         <connection host="db2.server.com" port="5432" user="myotheruser" table="products" />
         <sql format="raw">
            <![CDATA[ 
               select pic from products where model || '.jpg' = :resource or 
                                             model || '.png' = :resource or
                                             model || '.xpm' = :resource or
                                             model || '.bmp' = :resource
            ]]>
         </sql>
      </database>
      <image cache_dimension="1024" max_dimension="1024" />
   </server>

   <server name="images.diecastdepot.net:8081">
      <database name="diecast" type="QPSQL">
         <connection host="db1.server.com" port="5432" user="username" table="products" />
         <sql format="raw">
            <![CDATA[
               select pic from products where model || '.jpg' = :resource or
                                             model || '.png' = :resource or
                                             model || '.xpm' = :resource or
                                             model || '.bmp' = :resource
            ]]>
         </sql>
      </database>
      <image cache_dimension="1024" max_dimension="1024" />
   </server>
</configuration>

Generated on Fri May 4 11:21:12 2007 for PhotoGrotto by  doxygen 1.5.0