DorkMatter.net

May 23, 2008

Adding Quotation Marks to Your Web Page

Filed under: Web Design — Jude @ 7:06 pm

I really like magazine layouts. I like those little boxes with additional information or quotes inside the main body of the text but if you want to do something similar in your web pages it can be extremely frustrating to get it looking good.
Here’s one method for creating a quote box.

Step 1. Create your quotation marks. Use something like GIMP to create 2 files for each quotation mark using a font and colour of your choice. Unfortunately if you want it to look alright in Internet Explorer you’ll either need to save this with a background colour to match your quote area or you’ll have to save it as a transparent GIF. IE does not handle transparent PNGs well and definitely won’t cope with SVGs without a plugin.
Here’s how mine look. I opted for GIFs.Left Quote Right quote

Step 2. Write your code.
Make a new blockquote and within that a paragraph tag. Why put a paragraph inside a blockquote? You’ll see in a minute.

<blockquote class="quote">
<p>Your quoted text goes here. </p>
</blockquote>

Step 3. Position your quotation marks.
To avoid having your images floating around all over the place and positioning themselves based on the text, it’s usually better to position it as a background image. It’s an especially useful thing when your text is generated dynamically and you don’t know how long it will be.
Now the reason for having the <p> tag becomes clear. Each element can only have 1 background image, so if you position the opening quote as the background image to the blockquote you need another element to put the closing quote in; the closing quote becomes the background of the paragraph tag.

The CSS for this would be something like this:

blockquote.quote {
padding: 3px 3px 0px 3px;
width:90%;
background-color: #F0F0F0;
background-image: url(leftquote.gif);
background-position: top left;
background-repeat: no-repeat;
text-indent: 20px;
}

blockquote.quote p {
padding-bottom: 1.3em;
background-image: url(rightquote.gif);
background-repeat: no-repeat;
background-position: bottom right;
}

The important parts there are background-image, background-repeat and background-position. They’re pretty self explanatory – choose the background image, position it and tell it not to repeat to avoid having a tiled background.

Put that all together and you should have something like this:

Your quoted text goes here.
There’s no point in viewing the source for this bit since wordpress likes to add its own stuff and take away mine. I had to write some horrible code to make it work.

May 21, 2008

GIMP: Restore a Torn Photograph (Part 2)

Filed under: GIMP — Jude @ 11:00 am

You’ll remember last week I started a pretty large photo restoration project trying to piece together an old photograph.

This week I’ll show you how I go about “healing” the tear line and removing some of the major blemishes from it.

When you’re working on something particularly heavy-going it can be difficult to see what’s going on after a while. I like to go away, have a break and go back to it with fresh perspective. That’s exactly what I did today and when I went back to start working on the project again I noticed I hadn’t lined it up quite as well as I thought.

Slight rotation required to align the edges

Initially it looked as though the picture was lined up pretty well – the bars on the window, the man’s face and even the edge of the picture looked fine but when I zoomed in to start removing the tear line I noticed the white border on the left wasn’t aligned correctly (see left). Everything else looked right so what’s the problem? Rotation.

That’s something to keep in mind when you scan images – no matter how carefully you line it up on the edge of the scanner either by static or airflow the image nearly always gets moved slightly.

Rotating the top portion by just -0.23° fit everything back into place.

Feathering caused by scanning needs to be removed before flattening the imageBefore beginning to heal the tear, areas of special detail will probably need their own treatment. You’ll see where the tear passes through the man’s face that there is still some black feathering from when it was scanned. On other areas of flatter colour, like the curtains or walls, it’s simple to clone this out but where there are detailed features on the face we’ll need to remove as much contamination as possible. The layers will need to be flattened later so it’s important to get rid of anything along the borders at this stage.

 

Harsh black edge is removedNow that the harsh black edge has been removed, the extent of the tear can be seen. It still looks severe but it should be much easier to heal up later.

When you’re happy that all the detailed areas have been cleaned up it’s time to save with a new file name (so you can go back if you go wrong) and merge the layers. Select the top layer and go to Layers>Merge Down to flatten the image into one layer.

Now let’s begin healing up the tear.

For small differences I like using the Heal Tool Heal Tool in gimp. It’s somewhere between Smudge and Clone and samples the colour and texture of the surrounding pixels so you can paint a kind of average colour. Ctrl+click on a clean area near to your tear to set the target area, now use your cursor as usual to paint over the tear. Be careful to keep your target away from the edges or you’ll get unsightly white or dark smudges in your freshly papered-over crack.

Heal tool helps smooth out creases and tears.The tear has been repairedHeal smooths it over but because the colours are based on the surrounding colours there’s still a visible darkened area. This is where Clone comes in handy.

Clone works in much the same way as Heal so use Ctrl+click to select a clean area and paint over the darkened line where the tear was. The key to avoiding circular patterns is to keep the brush moving rather than dab at areas. Clone will copy the area under the target cursor to where you’re painting. To avoid noticeable repetition you can build up layers by setting the brush opacity to 50%.

Left: Beginning to heal the tear along the border, Right: After healing and some cloning.

Now most of the tear has been removed you can get a better idea of how the picture once looked.Areas of flat colour like that are easy to fix. As you work along the tear, repeat the same process to close up any gaps. On areas like the curtains take care to keep your brush strokes vertical to blend in with the transitions from light to dark.

You’ll probably find you will need to switch between Clone and Heal as you fix up the tear. For areas where there is a lot of colour missing you could try cloning at 100% opacity to fill the gaps, then heal to blend it and then add detail again with 50% opacity clone. There are no rules on how best to do it so experiment until you get something you’re happy with. The Undo Command (ctrl+z) will come in very useful.

You’ll also find that you’ll have to change between brush sizes depending on the detail required. For example, replacing the window uprights required a very small clone brush. For large areas of one colour increase the brush size to reduce repetition.

Here’s how the photo looked after fixing most of the tear. I’ve left the face and shoulder area alone to work at in detail (left).

To try and repair the face zoom right in – enough to work easily on the area but far enough to have good overview.

Much of the man’s chin was lost when the photograph was torn so it will have to be reconstructed. For this I first cloned the area, using a very small brush, trying to match the skin tones with the contours of his chin. This was pure guesswork since we’ll never really know how he looked.

Cloning produced a rather chunky pixelated look so this was softened using the Heal Tool. The image below shows before, after cloning, after healing on chin.
Repairing the chin using clone and heal

There’s so much of the face missing we’ll have to guess at that too. Using a combination of Cloning and Healing, sample areas near to the tear and replace the lost areas as done with the chin.This was by far the most challenging part of the photograph.

Here’s how the face looked after a lot of work.
Face repaired

The original photo had a stain right on the corner of the mouth. After some deliberation I decided to leave it there. Trying to repair that would have meant that 70% of the mouth was replaced and in my opinion that would have had too much impact on the face.

I also chose to leave the stamp mark from the original picture and the crease that ran through the woman’s body.

I felt that the stamp didn’t detract from the image and rather it added to the character of the image.

The crease through the woman’s body was left because to remove it would have altered the image a lot. You can see that there’s a large colour difference either side of the crease requiring a lot of blending between the two tonal areas which may have resulted in a “touched-up” look.

So here is the before and after:

Before restorationThe restored photograph

I hope to print this onto some cotton rag to complete the restoration.

If you want to have a go at this, go here and read through part 1 of the tutorial and download accompanying file if you want to work on this image.

Do you have any comments or opinions on this? Did you try the restoration yourself? Got a better method? Let me know with a comment.

May 19, 2008

Inkscape: Filling with Pattern

Filed under: inkscape — Jude @ 5:53 pm

How often do you opt for a solid or gradient fill for your Inkscape drawings? Have you ever used the Pattern Fill?

Here’s an example of a star shape filled solid pink next to one filled “Ermine”.
Ermine pattern fill on a shape
This is as simple as setting any other fill.

Applying a pattern fill

You can change the opacity and blur filters on Pattern Fill but not the colour… at least not without cheating a bit!

This method is by no means predictable but can create interesting effects. Select your patterned object and go to Effects>Color and try out some of the colour effects. It seems that not all effects work with all patterns. Polka Dots, Stripes and Checkerboard seem to work best with Randomize and RGB Barrel colour effects.

You can also change the scale and orientation of your pattern. This can be buggy so save your work first.

Adjusting the PatternPatterns Can be LayeredUse the Node Select Tool to select your patterned fill. You’ll notice to the top left an ‘x’ shape with circular and square handles. To increase the size of the pattern just move the square handle away from the ‘x’ and to rotate move the circular handle around the x.

Since most of the patterns are semi-transparent you can layer them up (right).
You don’t have to use the presets to fill your objects – you can make patterns out of objects!

Select objects to make a pattern

Create the objects you want to use as your pattern as well as an object you want to fill with pattern. Here I’m using a square for the background with a shape on top. Group your pattern objects (Ctrl +G) and then go to Object>Pattern>Objects to Pattern.

New pattern used to fill an objectTo fill your other object with your new pattern just click on it, select pattern fill and choose your new pattern. It will probably have a name like Pattern3806.

I’m unsure why the edges are visible. I tried using a thick outline for the square shape but it was unsuccessful. If you have any tips for that drop me a comment below.

Shape filled with bitmap patternFinally if you want to fill a shape with a bitmap it’s just as simple. Go to File>Import and select your bitmap image. Now as before, select the bitmap and go to Object>Pattern>Objects to Pattern. You now have a new pattern to fill with.

Any comments/questions/suggestions? Let me know!

May 16, 2008

GIMP: Restore a Torn Photograph (Part 1)

Filed under: GIMP — Jude @ 4:02 pm

A while ago my soon-to-be mother-in-law dropped by with an family photograph she had found in a box of old pictures. She was putting together her family tree and this was the only existing picture of some long-dead relations – but it was torn in half and pretty battered. To make matters worse, since I had taken this copy the original had been lost. Could anything be done to restore it? Here’s my attempt.

The image was scanned as below at 400dpi. I realise I could have pieced the picture together before scanning but I thought scanning them as two pieces would allow for greater flexibility.

Torn Image is scanned inOne half of the picture separatedYou’ll notice that there is a certain amount of overlap; an area of paper is visible where the two pieces sheered away from each other when it was ripped. This will need to be remedied later.
To start piecing it back together I had to get rid of the black area created by the scanner. Thankfully the Scissors Select Tool Scissors Selectwas made for this kind of thing!

Look out for an in-depth tutorial on this tool in the next few days.

I cut out each half and pasted it into its own layer. I could then move the bottom half up the canvas and begin piecing it together.

The torn areas from the top layer continue to show through while underneath it the missing part of the picture is hidden. You can also see that although the Scissors Tool did an excellent job of detecting the edge of the photo, there’s still a feathering of black.

The next stage is to move the layers around until the picture is as well aligned as possible. Luckily with this picture the vertical and horizontal bars of the sash window made it painless to line up. Without something like that you could carefully align it by eye or use the edges as a guide. When moving the pieces around the arrow keys will let you to move each layer by a pixel or two at a time.

A few large areas of paper were showing where the tear occured. To get rid of this it simply needs to be removed from the top layer as the missing fragment should still be present in the layer below. For this I’m going to use my favourite – Scissor Select.

The torn edge is selected to be removed Torn edge is removed

The light brown area along the margin is where some of the coating has lifted away from the paper. This will have to be rectified later by reproducing that part of the image.

Once the torn edge has been minimised the photograph looks more crumpled than torn and you can start to see the man’s face.

The torn image pieced together in GIMP

The final stage for now is to zoom in and work along the tear, removing any feathering that may have occurred.

Stick around over the next few days when I’ll be showing you how to reduce the blemishes in the photograph and begin to sympathetically enhance it. If you want to work along with me you can download the original file. As always, don’t forget to read the license. Creative Commons License

An Update on Today’s Tutorial

Filed under: General — Jude @ 2:32 pm

I haven’t forgotten that last week I promised you a couple of photo restoration tutorials. Well, the one I had planned for today turned out to be pretty complex. In order to cover everything really thoroughly I’ll be using this one photograph for a few tutorials including some instruction on using GIMP.

I’m going to an art show tonight so if it’s ready before I’ll publish Part One and if not, expect it tomorrow. Here’s what you’ve got to look forward to:

  • Restoring a Torn Photo in GIMP
  • Improving Damage, Water Stains and Discolouration
  • Detailed Study of the Scissor Tool
  • …plus some bonus material that I haven’t finalised yet.

Since this will be quite advanced, I look forward to your input; particularly if you have alternative methods or an opinion on the final piece.

May 14, 2008

Inkscape: Combining Shapes 101

Filed under: Vector, inkscape — Jude @ 9:30 am

The Path menu in InkscapeBack when I first started using Inkscape some of the things I found difficult to make work were the boolean operations in the path menu; things like Union, Difference, Intersect etc. To me the results were difficult to predict and some of the operations seemed pretty similar.

In this article I aim to explain these tools and show you how to get predictable controlled results.

Union
The first thing you need to do is select the two (or more) objects you want to combine. Let’s begin with the Union option. Select your objects and go to Path>Union (Ctrl++). This will combine the shapes, with the top object taking on the colour and opacity of the lower.

Before & After
Two shapes to be combinedTwo shapes after the union operation. The paths are combined.
You can see the paths have been combined. This can be really useful when making complex shapes. You can save yourself a lot of node editing if you can construct your shape in this way.

The difference between the two shapes.Difference
Difference works in much the same way except the top object is removed from the bottom shape.

Intersection excludes ares which do not overlapIntersection
This excludes everything except the areas where the two shapes overlap.

With exclusion areas that overlap are removedExclusion
Exclusion is probably my favourite of the boolean operations. Everything but the overlapped area remains and as before the top shape takes on the properties of the bottom shape.

Division operation

Division
Division only works if you have outlines, otherwise the result won’t be visible. It colours the top object but each retains its own path; so the edge of the star shape can be selected separately from the square.

Cut Path Boolean operationCut Path
This operation breaks the path where the two objects intersect allowing you to remove the section.

So there you have it. I hope this clears things up if you have been confused by these path options. I’ll be covering the rest of the path menu in the next few weeks.

May 12, 2008

GIMP: Spice Up Your Photos with a New Sky

Filed under: GIMP — Jude @ 4:48 pm

Last December I took a series of photos at a beach near my home town. I wanted to frame some to hang in my hallway but to space the frames nicely I needed 6 photos… I only had 5 good shots. Time for some GIMP trickery!

After picking my favourites I was left with a few other shots that weren’t up to scratch. I liked the foreground in this first photo but the detail in the sky did not print well and it just wouldn’t have looked right with the others. On the second photo the sky was nicely exposed but this left the foreground dark. If only I could have the foreground from the first photo and the sky from the second.

The foreground was good but the sky was lacking in this photo This photograph had an interesting sky but the foreground was too dark

With a nice defined horizon this should be really easy – except for the sea spray. It would ruin the picture to try to remove it so I’ll have to work around it.

I was standing on slippery rocks on a very windy day when I took these which explains the wonky horizons. To remedy this go to Tools>Transform Tools>Rotate (or Shift+R) and rotate until the horizons are level. For this example I had to rotate around -1°. You may find showing grids and guidelines, View>Show Grid, helps you get it level when performing this kind of task.

Some cropping is required after rotatingRotating creates blank areas on your canvas where you’ve straightened up. The blank area plus some of the photograph will have to be cropped to square the image.

Use the Crop Tool GIMP’s crop tool to draw a rectangle inside your photograph avoiding any blank areas. Press Enter to complete the crop when you’re happy with the selection.

Now the images are straight we’ll begin combining them. On one of your cropped photos go to Image>Image Properties to get the size of your image. Make a new file in GIMP with those dimensions.

Using the Rectangle Select Rectangle select tool in GIMP select the foreground in your first picture from the horizon down. Press Ctrl+C to copy it. In your new document create a new layer. Go to Layer>New Layer… and then Ctrl+V to paste in the bottom portion of your new image. Repeat by selecting the sky from your second image and paste it as a new layer below.
Each layer should look something like this:

The foreground is cut out and pasted into a new document. The sky is copied and pasted into the new document
You’ll notice there’s a little something missing from the foreground above the horizon.
So why not use one of the other selection tools and cut out the sea spray as well? At first I tried this and I realised pretty quickly why it looked so wrong – the sky showing through the spray belongs to a much lighter sky giving it an ugly superimposed look. Here’s how wrong it looks:
Copying the sea spray creates an undesirable superimposed look
To do that I used Select by Colour Select by Colour to pick out the sky and remove it, leaving the spray colour behind. It’s obviously really fake. The water has been lit by a much brighter sky and it’s given it a very obvious line on the horizon.

Instead I’m going to use the Clone Tool to copy some of the spray above the horizon.

Clone settingsSelect the Clone Tool GIMP’s clone tool and choose a suitable brush. I’m using a speckled brush to imitate the pattern of the spray.
First move your mouse over the area you want to clone from. I’ve placed it on the white area of the wave. Hold Control and click on the area. Now move your cursor again to the area where you want to colour and paint as normal. You’ll notice two cursors which are in tandem. The first shows the area you’re cloning from, so be sure not to go outside of that area or you’ll end up painting rocks in the sky.
If you need to readjust where you’re cloning from just Ctrl+click on a new area and begin painting again.

Cloning the wave

You can remove some of your cloning with the Eraser Tool to thin the spray so that more of the sky shows through.
To finish use the Crop Tool again to remove any areas of blank canvas.
The combined image

License Agreement

Creative Commons License

May 9, 2008

Weekend Tutorials

Filed under: General, inkscape — Jude @ 11:34 am

It’s Friday, I’m feeling a bit lazy so today I’m just going to point you in the direction of some interesting Inkscape tutorials that you might want to take a look at over the weekend.

I have some major bug fixing to do on one of my other sites but will prepare some shiny new tutorials for next week!

Illustrating Tomato is a nice tutorial from kalaalog.com. It’s not so much the tomatoes I find interesting, but the technique of first hand drawing them and then making shapes around the drawing. Gives a nice hand-drawn finish.

Inkscape Docs Interpolate Tutorial – if you haven’t got this far through the Inkscape documentation take a look at this well-written tutorial on interpolate. It’s a very cool tool in inkscape for morphing from one shape or colour to another.

Gradients to Path is such a simple yet brilliant idea. A really easy way to make a gradient or abstract shape using markers on a line.

3D Text by Nicu is an easy to follow tutorial on getting an embossed look on text using the blur filter. Could work well with non-text objects too.

That should keep you going until next week when I’ll be concentrating on some fairly heavy going GIMP tutorials on photo restoration. Have a great weekend!

May 7, 2008

Inkscape: Easy Speech Bubbles

Filed under: 2 Minute Tut', Vector, inkscape — Jude @ 11:23 am

Speed up your comic writingDo you write web comics? To take some of the effort out of it and save time, here’s an easy way to make speech bubbles that you can use each time you write a new comic.

Elipse converted to path in InkscapeThe Rounded Speech Bubble
Start with an ellipse. In this example I’ve given it a grey outline and blurred it slightly. Click on the shape and go to Path>Object to Path.

Ellipse with additional node

Here we’ll add the point to the speech bubble to the bottom-left of the ellipse, so shift-click using the Edit Paths Tool Edit Path by Nodes on the bottom and left nodes to select them and Add a Node Insert Node between them. Now select just the new node and change it to be a Corner Node Make node corner

Ellipse begins to look like a speech bubbleThe speech bubbles point has now been sharpenedPull the new node in the direction you want for your speech bubble. It’s now taking on a speech-bubble-like shape but it doesn’t look right yet. For that you’ll need to edit your new nodes Bezier handles to form a sharper point. Still using the Edit Paths Tool move the node’s handles so that they are at about a 45° angle and pointing back towards your original ellipse shape.

Elongating the handles makes the point sharperYou can also lengthen the handles on your corner node to make the point thinner. The finished speech bubbleAll that remains is to create a text area inside your bubble and fill it with some sample text of your choice. You can flip your bubble horizontally and/or vertically to change the direction and to move the point, simply select the corner node with the Edit Paths Tool and drag it in the direction of your character.

It’s really easy to repeat the process using a square. You’ll probably want to round the corners. You can do this by changing the Rx and Ry values for your square or rectangle:
Making a rounded rectangle

Check out this post on Playing with Polygons for details on how to make star bursts and other shapes.

Tip: To make a thought bubble start with a softened star burst shape:
Softened star burst
Now resize it so that it’s wider than it is long. Add a few circle shapes et voila!

A variety of comic strip shapes

You can download the files for these images and play with them yourself. Check out the License Agreement first.
Creative Commons License

May 6, 2008

GIMP: Pencil Drawing MacBook Decal

Filed under: GIMP — Jude @ 6:20 pm

The finished octopusA while back I wanted to make a decal for my MacBook. The idea was to make an octopus that would sit on top of my laptop with some tentacles curving around the screen area.

I began with a pencil drawing. I roughly marked out the edge of the screen on paper as well as a void area where the corner was and figured out roughly how the octopus’ tentacles would work. Then I sketched out the octopus using my markers as a guide and scanned it.
Line drawing of an octopus with markers for the macbook template
My pen scrawls are not pretty, so the first thing to do was remove them. Opening the image in GIMP I used the Eraser Tool Gimp Eraser Tool to remove the lines and the page creases to clean up the image so I could work on it more easily. I left some of the paper texture so I could give the octopus a distressed texture but you might want to get rid of all of it.
You can see there that the pen lines intersect some of the pencilled area so after erasing the pen some of the pencil lines will have to be put back in.

Here’s how the image looks after some minor cleaning.
Cleaned up image
I wanted to keep this image so I could go back and make changes if needed so I made a copy and placed it on a new layer above and called it “Outline”. It’s not a true outline yet because the white background of the paper is still present. To get rid of this, use Select by Colour Select by Colour to select the pencil colour and then Select>Invert to to invert the selection and press Delete to get rid of the white area. On this occasion doing it this way rather than just selecting the background colour worked best but depending on how your image scans in you may find you can just select the background colour.
Here’s how the “Outline” layer looks:
Outline, minus the paper colour
To start adding colour I made a new layer below “Outline” and began colouring using the paintbrush tool. You’ll find having the above Outline layer visible helps at this stage! To blur the lines between the two colours I used Smudge Smudge Tool. I’ll show you how it looks with and without the outline below:

Coloured with outline aboveThe Octopus’ colouring
When you scan a pencil drawing it tends to look really washed out or else the line is dark but the paper is also dark. I find it easy to start with a light image and darken the lines later if needed. To darken the Outline layer go to Colour>Hue/Saturation… and reduce the lightness.
You’ll find that darkening the pencil lines really enhances it. Here you can see the difference. I’ve also added some texture to the colour with a speckled brush and a slightly darker shade. You could Bucket Fill with a texture or pattern if you had something less hand-drawn in mind. Octopus with added speckles
Parts of the octopus, like around the curve of the head, are too sketchy for my liking so to add more definition I made a new layer above “Outline” and using the Eye Dropper Tool Eyedropper Tool I selected the pencil colour and drew in additional lines and shading. It can be difficult to match the pencil size and strength so you may find you need to experiment a bit before it blends with your original pencil lines. A little bit more definition makes all the difference:

Added more detail
That looks almost ready to me. Now to finish cleaning up the image use a Mask Layer to white-out everything but the octopus.

Make a new layer at the top and colour the entire layer white (or the colour of your choice) – this will be your background colour. If you skip this step and have a transparent layer you won’t be able to see your mask. Choose Layer>Mask>Add Layer Mask and choose White (Full Opacity). The mask colours everything the colour of the layer, except the areas where you paint. Think of it like this; it’s like placing a piece of paper on top of your drawing. To see the drawing below you need to cut out an area to let it show through. That’s what we’ll be doing next.

For clean lines we’ll blank out everything but the shape of the octopus below.
First select your drawing. I found the Scissors Select Tool Scissors Select does a really nice job of this. Making sure you’re still on your new Layer Mask layer, choose a starting point on the outline of your image and then click along the outline to make the selection. The tool automatically fills in the edges between each node:

 

 

Scissors Select Tool in action
Once you’ve selected the image, press Enter to confirm the selection. Now use the Bucket Fill Tool Bucket Fill to fill in the selection. Any colour is ok since this is just a mask and won’t show in the final image. You can be fancy and change the opacity or just go for full opacity if you simply want to cut it out. Now when you’re happy with the mask go to Layer>Mask>Apply Layer Mask to complete it.

You should now have your completed image!

The finished octopus

Now for the decal. You’ll need to acquire some printable vinyl available from specialist photo paper suppliers. The vinyl will either have an adhesive or will cling statically – probably the better option for a MacBook decal. Check which side is printable and if needed flip your image so it prints out as intended. All that remains to be done is to print and cut out your image. Done!

 

Creative Commons LicenseView License

Next Page »

Powered by WordPress