Templates - TitaniumBunker/Selfietorium GitHub Wiki

A template for the Selfietorium project is simply a inkscape SVG file. This SVG will contain links images, which will be loaded by the python based SVG library http://cairographics.org/pyrsvg/.

Here is some sample code for SVG / PNG production.

import cairo
import rsvg

img = cairo.ImageSurface(cairo.FORMAT_ARGB32, 640,480)

ctx = cairo.Context(img)

## handle = rsvg.Handle(<svg filename>)
# or, for in memory SVG data:
handle= rsvg.Handle(None, str(<svg data>))

handle.render_cairo(ctx)

img.write_to_png("svg.png")

In addition the SVG XML format also contains Descriptions for each photo, meaning that the prompt to the user can be stored within the template.... A Halloween template could ask the subject to pull their scariest face - whereas a party template may ask he subject to smile.

##Layout and structure It is a good idea to create your template based on layers. The sample template provided with the project works quite well as a base to see how to construct your own templates.

###Layers The template is based on a series of layers - some of these are optional, but it does make templates easier to work with. Think of these layers as a stack, each layer build on the ones bellow it. All images present in the photos layer will be replaced with photos from the picam ####Background This provides the background image that the other images will be composited onto.

####Photos This layer contains individual image boxes. In the template these can be any image you wish, as selfietorium will take a photo for each image it finds.

####Overlay This layer contains image information laid over the background and photos. This layer can be used to add a decorative from around your photos, or watermarks that identify the event for this photo template, allowing a template to be re-used for multiple events.

###Cropping and clipping images The picam can take photos of 2592x1944 - which will be considerably larger than your template. These images need to be cropped to the correct aspect ratio.

Basic process for cropping :

Create a rectangle for the image you wish to crop to. import your sample bitmap (of the same size as taken by the picam) resize this photo to the same height or width as the box you wish to use - preserving the aspect ratio align the crop box and the image - typically this will loose information on the left/right of the image Select both the image and the crop box and set clip now apply all changes to this cropped aspect ratio correct image box.

⚠️ **GitHub.com Fallback** ⚠️