You are on page 1of 4

COVER STORY Web Design with GIMP

Web page layouts with the GIMP

PAINTING
YOUR SITE
Georgios M. W., www.sxc.hu

Good homepage design is a question of the layout. Sometimes the best option is to use a graphics program

to design the page, then translate the result into HTML code. The versatile image manipulation program

GIMP can help. BY PETER KREUSSEL

S
ome purists believe they must Suse users will need to add the Python Dialogs | Layers or [CTRL+L] will
compose HTML code line by line extension and the Py-Slice plug-in manu- open the Layers dialog. Clicking New
in a text editor to achieve clean ally [2]. After doing so, launch GIMP Layer creates a new layer. In the dialog,
results, but other developers are occa- and create a new image (File | New). enable Transparency below Layer Fill
sionally willing to consider alternatives. Then select the 800x600 entry in the Type, and confirm by pressing OK, to
One little known alternative is the option Templates drop down. This is the resolu- create a new layer. Everything you add
of creating a graphics file in GIMP and tion we will be using for the homepage. to the image now will be placed in this
then converting the file directly to Then enter a name for the file; you will layer.
HTML. GIMP version 2 (www.gimp.org) be storing the file under this name later. Press [Ctrl+A] to select the whole
or newer includes the Py-Slice plug-in, Make sure you use GIMP’s native .xcf image. The dotted line surrounding the
which converts the image into a collec- format to have access to all of GIMP’s image shows the boundary of the selec-
tion of tiles, and then creates an HTML features. tion. Then select Rounded Rectangle in
table that organizes the tiles into an the Select menu; set the value for Radius
image that looks like the original. The The Sample Project
THE AUTHOR

results can easily be used for homepages GIMP uses so-called layers. You can Peter Kreussel studied German,
with attractive graphics, like the example compare the GIMP layer system to a English and philosophy. Today, he is
shown in Figure 1. stack of photographic slides. The layers an editor of both online and print
Most current distributions give you may be viewed together for the complete media. Peter has had a computer
GIMP version 2.2; we will be using this image, or you can edit each layer sepa- ever since the days of the C64.
version for the remainder of this article. rately.

34 ISSUE 59 OCTOBER 2005 W W W. L I N U X - M A G A Z I N E . C O M


advertisement

to five percent. This gives set the values for red, green,
you a selection with rounded and blue to 255. Then click
edges, as shown in Figure 1. the selected area with the fill
Now fill the whole selec- tool to color the selection
tion with a red color. To do white. You can then press
so, click on the foreground [CTRL+A] to disable the
color selection in the toolbox selection.
and set the values for red,
green, and blue to 190, 0, and Eye-Catching
0, respectively, to use a dark Effects
red tone. Select the fill tool in The 3D effect comes courtesy
the toolbox and enable Fill of the Drop Shadow in the
whole selection below Script-Fu | Shadow menu. In
Affected Area. Then click on the layers dialog, select the
the selection to apply the fill layer you just created, and
color. then apply a drop shadow.
For your next step, you GIMP will automatically add
need some guides. To draw a enough space for the shadow
guide, click on Image | Guide to the graphic image. How-
| New Guide, select the hori- ever, the white background
zontal Direction, and choose will not grow to match. After
a position of 100. Repeat the selecting the background
steps to create another hori- layer in the layers dialog,
zontal guide, using a value of click on Layer | Layer to
525 this time, and then add image size to resolve this.
two vertical guides at posi- The 3D label is still miss-
tions 125 and 725. The guide ing. Start by adding normal
intersections mark the cor- text with the text tool. Our
ners of the white rectangle at example uses the Sans Bold
the center of the page. Italic font and a slightly
Make sure you have lighter red than of the back-
enabled the option Snap to ground color, with values of
Guides in the View menu. 250, 225, and 225 for red,
Then select the scaling tool green, and blue, respectively.
from the toolbox and click on Clicking with the text tool in
Transform selection below the white area opens a dialog
Affects in the main GIMP window where you can enter
window. Now, when you Created.
click on the drawing, the Select Sans or any other
Scaling information dialog non-italic font as the font for
appears. Drag the small boxes the shorter piece of text and
at the corners of the dotted reduce the size. Clicking with
selection rectangle to the the text tool below the piece
guide intersections so that of text you have already
the selection matches the added will create a new text
empty white area. The guides block. Both texts will appear
will automatically attract the as separated layers in the lay-
mouse to improve positioning ers dialog. Select one of the
accuracy. Then click Scale to blocks and, in the toolbox,
complete the procedure. click the Create path from text
To fill the selection with button, which appears when
white color, add another layer you select a text. Then repeat
via the layers dialog. Select this step for the second block
the top entry and click on of text.
New Layer, again making the A path has a similar func-
background transparent. tion to a guide; however, it is
Then set white as the fore- in fact an embedded vector
ground color in the toolbox graphic with an arbitrary
palette; that is, you need to shape. A path will not appear
COVER STORY Web Design with GIMP

Figure 2: Using a blur and a drop shadow,


and moving two text objects, to create a 3D
effect.

dialog (two for the texts and the copies,


plus the Drop Shadow layer) in the
empty space on the right of the eye sym-
bol. This setting links the selected layers
so that you can move them together to
their final position by dragging the
mouse.
All we need now is the white box with
the label. To create the white box, draw
a rectangular selection around the text,
create a new layer, and fill the selection
with white. Use the same approach to
draw the white bar. To achieve the
Figure 1: A website with 3D effect – just a few clicks away thanks to GIMP. shadow effect shown in our example,
add a drop shadow to both the white
in a print-out, and you can’t export it to (select the layers, and then apply the boxes.
an image format such as JPEG or PNG. filter). We are just one step away from In our example, the menu bar on the
However, you can convert the form completing the 3D effect. Select the left will be used for navigating the web-
described by the path to a selection. lighter of the two text layers and add a site. To do this, first create the top box
After creating a path from the text, drop shadow to the image (Script Fu | by drawing another rectangular selec-
select Paths in the Dialogs menu. There Shadow | Drop Shadow). This gives you tion, creating a new layer with the selec-
will be two path objects in the path list the second line in the logo box in our tion and filling with white color. Then
for this example. The button bar at the example. duplicate the new layer and move the
bottom allows you to convert the path Now align the texts to be left justified duplicate downward. Repeat this step
into a selection. Apply this function to and below one other, and then move until you have a box for each menu
the first path. them to the required position. To do so, item. Then apply the effects for the 3D
The selection is the basis for a so- click on all six text layers in the layer look, motion blur and drop shadow, to
called layer mask. Select the Created
entry in the layer palette – the name
will reflect the text you typed – and
duplicate the entry. When you click on
the text with the text tool, you can
change the color in the main window.
The color selection dialog shows the last
two colors you used; select the dark red
used for the background.
Now open a dialog box via Layer |
Mask | Add Layer Mask, enable Selec-
tion, and click OK to confirm. Click on
Move to in the main window and move
the dark red text using the arrow keys;
press the down arrow twice and the
right arrow once to achieve the results
shown in Figure 2. Remember that it is
important for the Affects: field to be set
to the layer containing the object you
want to move.
Now let’s apply the filter. To do so,
select Filter | Blur | Gaussian Blur (hori-
zontal and vertical: 5 px) and apply the Figure 3: The GIMP Py-Slice plug-in creates an HTML table from an image. Guides are used as
filter to the light and dark red texts column and row separators.

36 ISSUE 59 OCTOBER 2005 W W W. L I N U X - M A G A Z I N E . C O M


Web Design with GIMP COVER STORY

through 6-0 (Figure 4),


add the HTML code for
the link immediately after
<td>, that is: <a
href="path/filename">.
Close the link tag at the
end of the line by adding
</a> before the </td>
tag.
You also need a HTML
Figure 4: The relationship between the original image in GIMP and the HTML code created by Py-Slice. rump segment to com-
plete the HTML docu-
all layers. Finally, use the text tool to ated an HTML encoded table. The table ment. Even though most browsers will
label the buttons. cells contain the image sections as render the Py-Slice HTML code correctly
defined by the guides in GIMP. Figure 4 without the rump segment, remember
From GIMP to HTML shows the link between the HTML code that the HTML standard requires you to
We will use a table to convert the bitmap and the image; each column comprises include the following lines in the header
image to HTML. The individual menu three rows of cells. for this kind of file:
buttons will be the cells in the table; In our example we wanted the central
they can be assigned to links that will white area to be a uniform block. We <HTML>
change the content in the main central only need the cell structure, as applied <HEAD>
area. GIMP uses guides to divide the by GIMP, for the menu items. To achieve <TITLE>[My Page Title]</TITLE>
image. Set the guides as shown in Figure this, we need to change the central cell <META HTTP-EQUIV=U
3 by clicking on one of the rulers, hold- in line 2, that is, cell 1-1, in the ninth "Content-Type" ??
ing down the mouse button, and drag- line of HTML code to <td rowspan="7" CONTENT="text/html; charset=??
ging the mouse down or to the left. valign="top">. Also, delete the <img iso-8859-1">
Additionally, you can only export one alt=" " src="images/pyslice-1-1.png" </HEAD>
layer. As layering information is lost width="582" height="48"> section. <BODY BGCOLOR=#FFFFFF>
when you combine the image, you will This leaves the area free for your own <div align="center">
want to save a backup copy of the image content. Anything you add at this posi-
under a new name before you continue. tion in the source code, text, images or And the footer for the HTML file is as
Then right click in the layer palette and other HTML elements, is placed in the follows:
select Flatten image. white area.
There is nothing to stop us converting You can delete the following six cen- </div>
the image now: Filter | Web | Py-Slice tral cells (that is from 2-1 through to 6-1, </BODY>
will call the tool we need to do this. In as represented by lines 14, 19, 24, 29, </HTML>
the settings, select png below The format 34, and 39 in the HTML source code),
of the images. This format is more suit- as they simply represent the individual The <div> tag aligns the whole page
able than the other two alternatives: sections of the white area at the center in the center of the screen to ensure that
JPEG uses a so-called lossy compression of the page. Figure 5 gives you an idea the page will be correctly positioned for
algorithm, and this may cause lines to of the result. a higher resolution web browser. The
blur. GIF images do not have this disad- To make sure the menu bar really remainder is the HTML header and
vantage, but they are restricted to to 256 gives you menu functions, you will now footer, which are indispensible for any
colors. This would affect the color gradi- need to manually add the appropriate HTML page. For more details on creating
ents in our example. The PNG format links. In the code lines for cells 1-0 elegant and efficient web pages, read the
supports up to 16.7 million colors, uses article on Cascading Style Sheets else-
non-lossy compression, and any major where in this issue.
browser will render it.
Enable the Use separate directory for Conclusions
images? option to store the individual The options that GIMP provides for
images cut from the main image in a converting an image into HTML can
separate directory. Confirm by clicking really simplify the task of creating a skel-
OK; you can then view the results in eton page for a website. The technique
your browser under the filename and described in this chapter may not be
path specified in your Py-Slice settings. your best option for every conceivable
web page, but many designers recom-
Into the Source Code Figure 5: The HTML table generated from mend this approach as an efficient alter-
If you now load the HTML file in your the image, with some manual modifications, native for creating eye-catching graphi-
editor, you will note that GIMP has cre- follows this pattern. cal web pages. ■

W W W. L I N U X - M A G A Z I N E . C O M ISSUE 59 OCTOBER 2005 37

You might also like