Introduction to graphic design and image manipulation with open source tools

Offered by Guillaume Larocque, Quebec Centre for Biodiversity Science.

October 31, 2017. McGill University.

Link to Prezi presentation.

To install GIMP, go to this site and follow instructions.

To put GIMP in single window mode, click on Window>Single Window Mode, and restart GIMP.

Exercise 1 - Basic image cropping, rotation and resizing.

  1. Download this image from the National Library of Congress from 1915-1920.
  2. Open it in GIMP using File>Open.
  3. From the tools, click on the Rotate icon and rotate the image so to make the road at the back approximately horizontal.
  4. Use the “Rectangle Select” tool to keep only the part of the image that contains the main protagonists.
  5. Click on Image>“Crop to selection” to remove the non-selected portion of the image.
  6. Use the Colors>Curve interface to make the dark areas of the image a bit darker, while making the other shades of the image untouched. Your curve should look like this:
  7. Use the Clone tool and the Healing tool to remove small specks in the image. After clicking on the tool's icon, click on a reference area close to the speck you want to remove, and then click CTRL and click on the speck. Make sure that the brush size is appropriate. You can play with the opacity of a brush for a more subtle effect.
  8. Use Image>“Scale image” and the “Crop” tool with a fixed size to obtain an image that is exactly 120dpi (pixels per inch) at 8.5×11 inches. Use the Image>Print size to verify that it works.

Exercise 2 - Layers, cropping and manipulation of colors.

You are given the image of a leaf, and you have to add an animal of your choice from another photo on top of the leaf.

  1. Download this image of a leaf and open it in GIMP.
  2. Go to unsplash and download the photo of an animal of your choice. We will try to put that animal on the leaf. So choose something that works, but is original!
  3. Open the image you downloaded in GIMP. Use the Free select tool to delineate carefully the outline of the animal you wish to extract. At this point, you can just delineate the outside.
  4. Click on Copy (CTRL-C) and then go to the GIMP page with the leaf and click on Edit>Paste as>New layer. In the list of layers, double-click on the layer name (Should be “clipboard”) and change it to the name of your animal.
  5. Using the Scale tool , resize the layer and re-position over the leaf with the Move tool.
  6. If there are parts of the animal that you would like to crop out (e.g. space between the legs), delineate it with the Free select tool and press DELETE to remove it.
  7. Click on the layer in the layer menu and then open Colors>“Brightness, Contrast” to adjust the image so that it looks realistic on the leaf. Do the same with Colors>“Hue, saturation”.
  8. Right-click on the layer that contains the leaf in the layer menu and choose Add Alpha Channel. This will allow the layer to contain transparent parts.
  9. Click on the Fuzzy Select Tool . Click on the background of the photo with the leaf. Adjust the threshold value in the Tool options and click again on the background until you include all of the background, but exclude the leaf. Click on DELETE to remove the background.
  10. Go to unsplash or a site like and download an image, texture or pattern to use as a background.
  11. Download and open the texture in GIMP. Copy the image and click on Edit>Paste as>New layer. Click on the layer in the layer menu and drag it below the other layers.
  12. Adjust the colors of your background to your liking.

Exercise 3 - Layer masks.

In this exercise, you will play with layer masks in GIMP. You will first select an element of an image and make the rest of the image black and white. You will then apply an effect know as “tilt-shift” photography to your photo. This effect artificially plays with the depth-of-field of the image to make it look like only the central elements are in focus. This gives an overall impression that the whole image is very small, like a scale model.

  1. Download this image from a street scene in India.
  2. Significantly increase the contrast and saturation of the image.
  3. From the layer dialog, create a copy of the layer by clicking on the “Create a duplicate of the layer” icon.
  4. Click on the top layer and click on Colors>Desature to make the entire layer black and white.
  5. Click on the top layer and right-click “Add layer mask” and Black (Full transparency). Now the mask completely covers the layer below.
  6. Click on the Paintbrush tool, and select a size of +/- 50. With the paintbrush, click and move the cursor on the yellow taxis on the image. You can always click on the eye icon on the layer dialog to temporarily hide the black and white layer to reveal the color layer below.
  7. Repeat the operation so that you now only see the taxis in Yellow, and the rest of the image in black and white.
  1. For the second part of the exercise, hide the black and white layer with the mask and create two duplicates of the color layer.
  2. Click on the topmost layer and select Filters>Blur>Gaussian Blur. Choose a blur value of 15.
  3. Right click on the topmost layer and select Add Mask> White (Full opacity). This will make the non-blury layer visible everywhere where it is opaque on the Mask.
  4. Click on the gradient tool and create a gradient that starts from the middle (vertically) of the image and goes down to one-third of the image. This should make the bottom part of the image blurry.
  5. Repeat the operation with the other duplicate of the image for the top part. Start by applying the Gaussian blur and then add the mask and apply the gradient from the center to the top third of the image.
  6. Your image should now be blurry on the top and bottom and should have the tilt-shift look. What happens if you now make the mask from step 1 visible? What if you change their order?

Exercise 4 - GIFs!

You will be making a GIF animation that highlights how cool your research is!

  • Find some photos or graphs from your research that you want to highlight.
  • Click on File>New and select a 640×480 document with a White background.
  • Open the content you want to put in the animation in GIMP and copy it as new layers using Edit>Paste as…>New layer. Resize the content to fit into the page using the Scale Tool.
  • Reorder the layers, knowing that the bottom layer will be played first and the top layer last.
  • Change the name of each layer to designate the associated content. After the name of the layer add (500ms) to get something like: “First photo(500ms)”. The number in parenthesis is the duration of this slide in the GIF animation.
  • For slides with text, click on the Text tool and and choose the font and font size from the Tool options before adding the text. When you are done placing and resizing the text, add (500ms) to the name of the text layer.
  • To give a background to your text, first choose a foreground color by clicking on the Foreground and Background Color icon. Then, add an empty layer to the bottom of the text (by clicking the Create a new layer icon ) that has that foreground color. When satisfied with both the text and the background, right click on the text layer and choose Merge Down. The text is now fused with the background and you can't remove it.
  • You can test your animation by clicking on Filters>Animate>Playback.
  • When you are happy with your work, choose File>Export as>GIF Image, and then click on As animation, leaving the other options unmodified. If it asks if you want to crop, click yes.
  • You can now open your animation in a web browser!

To install Inkscape, go to this site and download the version for your platform. If you are on Mac OSX, carefully read the extra steps needed.

Exercise 5

You receive a logo in Bitmap format that you have to recreate because the image resolution is too low. Your task is to recreate this logo in Inkscape. It is the logo of a group of students working on Northern Research in Quebec (see

  1. In Inkscape, click on File>Document Properties. Specify a width and height of 200 mm. Note that the background is transparent by default. To have a white background for the output image, click on Background color, and make the Alpha channel opacity (A) 100%.
  2. Click on File>Import and choose the iiw_logo.png file from your computer. This will be used as a reference. You can make it bigger and place it beside the canvas.
  3. Start by creating a square that fills most of the canvas. When done, click on the square and adjust the width W and height H on the top menu so that both values are equal.
  4. Click on the square, then on the droplet icon , and click on the darker blue part of the bitmap icon to make the square the same color as one of the “stars” from the icon.
  5. Go to Object>Fill and stroke>Stroke paint and click on the X to remove the stroke.
  6. Click on the square and then click on Path>Object to path. This will transform the object into a path that you can manipulate.
  7. Making sure that the “Edit paths by nodes” () is selected, double click on the middle of one of the sides of the square to add a node. Do this for each side.
  8. Drag the corner nodes of the square to move them toward the center to reproduce the general shape of the star. Make sure all sides are identical and the image is symmetrical.
  9. Click and drag on one of the center nodes while holding the SHIFT key to pull out a handle that allows to adjust the curvature of the lines. Click on the same node while holding the SHIFT key to add curvature in the other direction. Give all sides the proper curvature using this approach.
  10. Once you are satisfied with the shape of the star, click on it with the arrow and click on Edit>Duplicate.
  11. Click on the new star that was just created on top of the other one, click on the droplet icon and then click on the paler turquoise color of the bitmap icon to make it the same color.
  12. Click twice on the turquoise star until you see the rotating handles. Click on one of the corner handles and rotate the star 45 degrees.
  13. Center both stars on the page by clicking on each one, clicking on Object>Align and distribute and by selecting Relative to page, and the Center on vertical axis icon.
  14. Click on the green star and then on PAGE DOWN to move the star under the dark blue one.
  15. Your logo should look something like this:
  16. Export your logo as a PNG image by clicking on File>Export PNG image. Click on Export area “Page” and then select a size of 500x500px.

Exercise 6

You are asked to propose a “badge” for the QCBS that is inspired by the elements of the current logo. You have to use one of the three organisms present on the QCBS logo and a circular photo cutout, with the QCBS name in a circle around the photo. The final product could look something like this (or not).

  1. Create a new Inkscape document and make it 200mmx200mm.
  2. Go to Unsplash and download a photo that you think would be appropriate for the background of the badge. You can search by keyword (e.g. “texture”), click on the image you like and then click on download.
  3. Resize the image to 800px wide in GIMP.
  4. Copy the image from GIMP to Inkscape using copy-paste. Put it on the side of your page.
  5. Create a circle that fills about 75% of the page. Make the width and height of the circle identical in the top menu. Center align the circle on the page, both horizontally and vertically. Make two copies of this circle and keep them on the side. We'll need them later.
  6. Resize your photo and put it under the circle so that the part of the photo that you want to keep is inside the circle. If the photo is on top of the circle, select the photo and move it below (PAGE DOWN).
  7. Select both the circle and the image (press SHIFT while clicking on both), and click on Object>Clip>Set. Now the photo should be in the form of a circle.
  8. Download this png file containing the QCBS logo in bitmap/raster format. Open it in Inkscape.
  9. We will now turn this image into vector format. Click on the QCBS logo and select Path>Trace bitmap. Select single scan and Brightness cutoff. Then click on OK.
  10. There is now a vector version of the logo on top the original one. Click on it and move it to the side.
  11. Click on the new vector logo, and select Path>Break apart. This will separate the elements that don't touch each other.
  12. Choose which of the owl, the butterfly or the iris you want to isolate. If necessary, remove the design elements that protrude out of the organism by double clicking on it and deleting the associated nodes (DEL key after clicking on them). You might need to adjust the curvature handles.
  13. Note that the white elements that were inside the black parts have been made black. To make them “holes” in the object, select the entire region around the organism and click on Path>Combine. This will make the entire selection white. Make it black so that you can see it. Select the grouped organism and copy-paste it to the Inkscape page containing the badge.
  14. Resize and move the organism to the approximate center of the badge (based on visual perception rather than absolute center). Make it white, or another color of your choice.
  15. Click on the circle you copied earlier and make the stroke width around 10px and make the stroke dark grey, or what you like. Make the Fill empty (none). Move it on top of the other circle.
  16. Click on the Create text objects icon (letter A) and click somewhere beside the page. Choose a font size of 25 in the top menu bar. Type in the name of the QCBS in full in French and English.
  17. Select both the the text and the circle that you (should) have left on the side. Click on Text>Put on path. The text should now be wrapped in a circle. Adjust the font size of the text and place it around the badge. Resize as necessary. Note that if you want the bottom portion to be upside-up, you need to create two arcs, one for the top (French) and one for the bottom (English), and put the text in each language on around the circle individually.
  18. Click on the organism, go to Filters>Shadow and glow>Drop Shadow. Change Horizontal and vertical offsets to 3px and the Blur Color>Alpha channel of the shadow to 200 (mostly opaque).
  19. If you want to add a little “glossy” effect, you can create white semi-transparent semi-circular shapes on the top and the bottom of the circle (see example badge above). First, start by creating a square, convert to a path, make it into the shape you want, adjust the position, size and transparency, and move above the photo, but below the other shapes. Repeat for the bottom portion.
  20. Adjust other elements to your liking. You have a badge!

Exercise 7 - Editing R figures in Inkscape with svglite package.

  1. Install the svglite package.
  2. Load the library.
  3. Run the following code to produce a graphic, or adapt this code with one of your own figures from R.
    tot <- colMeans(VADeaths)
    text(mp, tot + 3, format(tot), xpd = TRUE, col = "blue")
    barplot(VADeaths, beside = TRUE,
            col = c("lightblue", "mistyrose", "lightcyan",
                    "lavender", "cornsilk"),
            legend = rownames(VADeaths), ylim = c(0, 100))
    title(main = "Death Rates in Virginia", font.main = 4)
  4. You should now have the figure in a SVG file in your current working directory. If you are not sure where that is, type getwd();
  5. For curiosity, you can open the SVG file in Notepad or TextEdit to see what the structure of the file is like. You could edit the file from there if you wanted!
  6. Open this image in Inkscape by clicking File>Open and then selecting the SVG file.
  7. Change the colors of the bars to make them gradients that start darker at the bottom and become lighter at the top. To do so, click on the bar that you want to adjust, click on Fill and the Linear Gradient icon. Adjust the color of the gradient ends and the orientation by interacting with the gradient handles. When you are happy of one bar with a given gradien, select that bar click on Edit Copy/CTRL-C, select the other bars of the same color and click on Edit>Paste Style. All bars should now have the same gradient. Repeat with other bars to change the colors as you desire.
  8. Make the legend bigger by selecting all the elements of the legend (click-drag), pressing CTRL-G to make it a group and then resizing it with the resize handles to make it bigger.
  9. Note that the text in svglite comes with the textLength property set to a given value. So, if you try to change the font size of the text, it will only make the text 'higher' and not wider. To fix this, open Edit>XML Editor, and empty out the textLength property for the text objects. Note that you can also remove it from the SVG file in a text editor.

Complete documentation is here.

Let's add text and a border to an image.

iiw <- image_read("")
iiw<-image_annotate(iiw, "Intercultural indigenous workshop", size = 30, gravity = "north", color = "white",font="verdana")
iiw<-image_border(iiw, "#cccccc", "20x20")
image_write(iiw, "iiw.jpg")

Make an animation and save it as a GIF. This uses the gganimate functionality of ggplot2.

img <- image_graph(600, 400, res = 96)
datalist <- split(gapminder, gapminder$year)
out <- lapply(datalist, function(data){
  p <- ggplot(data, aes(gdpPercap, lifeExp, size = pop, color = continent)) +
    scale_size("population", limits = range(gapminder$pop)) + geom_point() + ylim(20, 90) + 
    scale_x_log10(limits = range(gapminder$gdpPercap)) + ggtitle(data$year) + theme_classic()
img <- image_background(image_trim(img), 'white')
animation <- image_animate(img, fps = 2)
image_write(animation, "animation.gif")