Richards Center at Yale University
RC Home | Search | Table of Contents | General Information

Last Modified: Wednesday, 01-Mar-2006 16:44:12 EST

Listing of this directory

PDF labels for DVDs

Basic printer and label specs

Generating labels for a project

Steps for producing a single label from scratch

Labels are produced using ImageMagick(IM). IM's coordinates are in pixels, with (0,0) in the UL corner. The steps are:

  1. Produce a 733pix-sq .jpg background image.
  2. Create a 733pix-sq .jpg white mask with the printable DVD area set to black.
  3. Add the two .jpg images to mask unprintable parts of the background.
  4. Add the fixed part of the annotations.
  5. Add the project- and DVD-specific annotations
  6. Apply the mask again
  7. Convert to PDF

Scripts are in /srv/local/backup/scripts; Images and annotation templates are in /srv/local/backup/labels.

         setenv scr /srv/local/backup/scripts
	 setenv lbl /srv/local/backup/labels
       

Creating background images

We start with diffpattern2.jpg, a 320x321 pixel image of a diffraction pattern. Expand it to 733pix-sq:
        cd $lbl
        cp diffpattern2.jpg diffpattern2-733px.jpg
	mogrify -scale 733x733 diffpattern2-733px.jpg
      
Create the DVD mask file using the script dvdmask:
        $scr/dvdmask $lbl/dvdmask.jpg
      
Combine the mask with the background image, creating a working image in the CWD. (This step is not really necessary; after annotations are added (next step), the mask will be applied again. But this is useful to help determine where to place the annotations.)
        composite -compose Plus $lbl/diffpattern2-733px.jpg \
	          $lbl/dvdmask.jpg maskedimage.jpg
      

Adding annotations

Text annotations are now overlayed on the masked image. The annotations come from an annotation file (.ann) which we create. First, apply the standard label fields for CSB crystallographic data archives:
        $scr/annotate $lbl/xray-fixed-01.ann maskedimage.jpg fixed-ann.jpg
      
Next, a user-supplied annotation file is applied to supply additional annotations, based on $lbl/xray-user-01.ann.
        cp $lbl/xray-user-01.ann myprojectbase.ann
	vi myprojectbase.ann
	$scr/annotate myprojectbase.ann fixed-ann.jpg myprojectlabel.jpg
      

Final steps

Now, we re-apply the mask, and convert to PDF.
        composite -compose Plus myprojectlabel.jpg \
	          $lbl/dvdmask.jpg final.jpg
        convert -density 150 -units PixelsPerInch final.jpg final.pdf
      
final.pdf can now be ftp'd to elijah using binary mode.

Annotation file

The annotation file has one line for each text phrase to be added to the label. Lines beginning with "#" will be trseated as comments and ignored. Coordinates are in pixels, with (0,0) in the UL corner, and 150 pixels/inch. Note that the font specification is currently ignored. From xray-fixed-01.ann:
      #fields are separated by ^
      #coords^size ^color^font      ^Annotation text
      #       (PTs)
      300,100^20   ^blue^ @times.ttf^Yale University
      240,120^20   ^blue^ @times.ttf^Center for Structural Biology
      230,140^18   ^blue^ @Times.ttf^x-ray crystallography data archive
    

Scripts for producing labels

Extracts from scripts are included to demonstrate the IM commands used.

/srv/local/backup/scripts/dvdmask:

    	#!/bin/sh
    	# usage: dvdmask targetfile.jpg
    	#   create a .jpg file with a white background, and a black disc denoting
    	#   the printable area of a DVD (or CD). For the Rimage, the label should be
    	#   733x733 pixels (122mm-sq). The printable area has diameter 696 pixels.
    	#   There is an unprintable hub in the center with a 214-pixel diameter.
    	maskfile=$1
    	# create the file, with the 696-pixel diameter black disc inside it
    	convert -size 733x733 xc:white -fill black \
    		-draw 'circle 366,366 18,366' $maskfile
    	# overlay the 214-pixel diameter white disc in the center
    	mogrify -fill white -draw 'circle 366,366 259,366' $maskfile
      

From /srv/local/backup/scripts/annotate:

    	#!/bin/perl
    	#   usage:
    	#     annotate annotation_file template.jpg annotated.jpg
    	my $afile = shift(@ARGV);
    	my $tjpg = shift(@ARGV);
    	my $ajpg = shift(@ARGV);
    	# copy $tjpg to $ajpg -- operations will be applied to $ajpg 
    	`cp $tjpg $ajpg`;
    	# For annotation, use commands of the form:
    	#     mogrify -pointsize 14 -fill blue -font Times \
    	#       -draw 'text 50,360 "middle of disc"' $ajpg
      

Last Modified: Wednesday, 01-Mar-2006 16:44:12 EST


RC Home | Search | Table of Contents | General Information
Richards Center (www.rc.yale.edu) at Yale University (www.yale.edu)
Contact: webmaster_at_ben^rc^yale^edu