Wednesday, November 27, 2019

Solving a jigsaw puzzle in GIMP

When doing an online puzzle hunt, you'll sometimes come across a puzzle that requires cutting out some jigsaw pieces and assembling an image. This can be tedious. First, you need access to a printer (and often, preferably a color printer). Once printer, you need scissors to cut out the pieces. This is quite laborious and time-consuming. After that, assembling the pieces by hand can be painstaking. If the pieces are small, it requires some dexterity to manipulate them, and pieces can be easily bent, accidentally moved, or blown away by the wind. It's often easier just to solve these jigsaw puzzles on the computer in an image manipulation program. Here, I demonstrate how to do so using GIMP in a video:


The example I use is the puzzle "Theft of a Picasso" from Puzzle Boat 6. First, I use the Windows built-in Snip & Sketch tool to take a screenshot of one set of jigsaw puzzle pieces. The shortcut is Windows + Shift + S.


I then paste the screenshot into GIMP.


Once pasted in GIMP, I use the Fuzzy Select Tool - - to select the entire background and delete it. Just click the "magic wand" button, left-click anywhere on the white background, and press Delete, and you'll be left with just the jigsaw pieces on a transparent background:


Now, we still can't manipulate the puzzle pieces individually since they're still all part of the same layer. We need to cut out each piece and put it in its own layer. We can do this using the Rectangle Select Tool -  - and the Free Select Tool (aka Lasso) - . The Rectangle Select Tool is useful when you can draw a rectangle around one of the jigsaw pieces without including parts of any other pieces. The Free Select Tool is useful when you need to do a free-form cut to avoid including parts of other pieces. Here's an example of using the Free Select (aka Lasso) Tool:


There are two ways to use the Lasso Tool:
  1. You can click spots to draw straight lines between points (above)
  2. You can click and drag to draw a free-form shape (below)

Note that you don't need to be super accurate when using the Rectangle/Free-Form Select Tools because the background is transparent.

Once you've made your selection either using the Lasso or Rectangle Select Tools, you can float the selection using Right Click -> Select -> Float (Ctrl + Shift + L). Then you can create a new layer from the floating selection using Right Click -> Layer -> To New Layer (Ctrl + Shift + N). Switch to the Move Tool - - and you can now move the jigsaw piece around independently.

To repeat for the other pieces, make sure you select the original layer (Pasted Layer) first. You can use Page Down and Page Up to change layers, or you can click the layer in the Layers toolbox.



Once you've created separate layers for all the puzzle pieces, you can use the Move Tool to assemble the pieces and solve the puzzle! If you aren't able to move a piece, double check that "Layer" is selected in the Move toolbox

Happy puzzling! Please feel free to leave comments if you have any questions or concerns.

Update (11/28/19): An alternative way to cut out pieces that you can't draw a rectangle around without including parts of other pieces is to draw the best rectangle you can and then subtract the parts from the other pieces: Use Rectangle Select Tool to draw a rectangle around the piece of interest


then hold down Ctrl (a little "-" should appear to the top-right of the cross-hairs) while drawing another rectangle you want to subtract from the current selection


And one final way you can cut out such a piece is as follows:

  1. Draw the first rectangle to include as much of the piece as possible:


  2. Then hold down Shift while drawing additional rectangles to add those rectangles to the current selection. (When you hold down Shift, you should see a little "+" appear to the top-right of the cross-hairs.)