Showing posts with label Graphics. Show all posts
Showing posts with label Graphics. Show all posts

2009-08-09

Read 'Times Online' article comments earliest first

The comments appearing after articles in the Times Online are displayed in reverse chronological order (latest first), which I find difficult to read, so I wrote this GreaseMonkey jQuery script to click the Oldest first link after the page is loaded:

// ==UserScript==
// @name         Timesonline.co.uk earliest comment first
// @namespace    kamhungsoh.com
// @description  Show an article's comments, earliest comment first.
// @require      http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js
// @include      http://*.timesonline.co.uk/*
// ==/UserScript==

var evt = document.createEvent('HTMLEvents');
evt.initEvent('click', true, true);

$("a:contains('Oldest first')").each(function() {
  this.dispatchEvent(evt);
});

The script is a little more complicated than I expected. Apparently jQuery cannot send events (see the last response in the thread) that it itself did not bind to objects, so my script has to create a click event object and send it to the link. Otherwise, I would written $("a:contains('Oldest first')").trigger('click');

Also, the script's a little hacky because it will send a click event to all links containing the text 'Oldest first', though it seems pretty unlikely that a page will have more than one link of that type in the first place.

2008-12-13

Gimp 2.6: Order drawing tools by keyboard accelerators

It may be easier to remember keyboard accelerators (or shortcuts) if an application's tools follow the arrangement of the keys in the keyboard. Here's how to apply that idea to the Gimp 2.6 Toolbox.

The default arrangement of tools has this key order: E (ellipse select), R (rectangle select), F (free select), U (fuzzy select), Shift+O (select by colour) …

Gimp Default Toolbox

The new arrangement follows the QWERTY layout: Q (align), E (ellipse select), R (rectangle select), T (text), U (fuzzy select) …

Gimp Rearranged Toolbox

Here's how to find and move Gimp's drawing tools:

    Gimp Tool Dialog
  1. Open the Tools dialog (see picture on the right) by select menu item Windows / Dockable Dialogs / Tools.
  2. When you type a key, Gimp will highlight the tool in the Toolbox. For example, Q highlights the Align tool.
  3. Press the up or down arrow button in bottom of the Tools dialog to move the required tool to the desired position.

It's easier to customize Gimp's toolbox than Visio's toolbar because you can find a tool by typing its keyboard accelerator, while in Visio you have to browse through the tools in the Command menu until you find the required one.

See Also

2008-03-15

Making ID Photos with GIMP

You can make ID photos cheaply using GIMP:

  1. Take a head-and-shoulders picture with your digital camera.
  2. Load or paste the image into GIMP.
  3. Rotate the image, if necessary, to a portrait orientation using menu item Image / Transform / Rotate 90 ….
  4. Shrink the image to one quarter the original size using menu item Image / Scale Image. You have to calculate the required pixel size because the Scale Image doesn't have a "shrink by half" function.
  5. Create a new image with the dimensions of the original image, in landscape orientation.
  6. Select menu item Image / Configure Grid and set the spacing so that it matches the size of your shrunk image. The idea is to have a grid as per ASCII art below:
    +--+--+--+--+
    |  |  |  |  |
    +--+--+--+--+
    |  |  |  |  |
    +--+--+--+--+
    
  7. Select menu item View / Snap to Grid and View / Show Grid.
  8. Copy and paste your shrunk image into the new image. You should be able to fit 8 images in one picture. Use the grid to help you position the images in each cell. Positioning all images in the grid's cells also makes it easier to cut the photos after they have been printed.

My camera takes 3072 x 2304 pixel images (or 6:4.5 ratio), so if I use 15cm x 10cm (6:4 ratio) paper, the images on the left and right edges would be cropped unless I further shrink the images by 5%.

2008-03-11

How to Extend Image with GIMP

If you have an image with a plain background that is too short or narrow, here's how you can extend it using GIMP 2.x. Note that extending an image is not the same as stretching an image using a transformation; important elements in the image are not distorted, just moved (see ASCII art below).

+----+     +------+
|A  B| ==> |A    B|
+----+     +------+
  1. Open the image file.
  2. Select menu item Image / Canvas.
  3. In Set Image Canvas Size dialog, uncheck the link between Width and Height, enter the required dimensions, then press the Resize button.
  4. Select menu item Layer / Layer to Image Size. You have to extend the background layer because you cannot see any part of the image beyond the background layer's boundaries.
  5. Use Rectangle Select Tool, select area to move, then copy selection to clipboard.
  6. Paste selection into image (which creates a Floating Selection in the Layers dialog).
  7. Move the selection to the required position in the layer. If you want to precisely place the selection, you should zoom in and use the cursor keys.
  8. When you are satisfied with the position of the selection, use Layer / Anchor Layer to put it back into the background layer.
  9. Use the Color Picker Tool to select a colour, then use a Pencil Tool or Paintbrush Tool to touch up the background.

Note that you can only move the selection after you have created a Floating Selection, which confused me initially because I thought that just copying a selection would give me an object to move.

2007-10-28

GIMP and Inkscape Stylus Tracking Problem

If you use a Wacom Graphire tablet and drawing tools GIMP 2.4 or Inkscape 0.45.1 on Windows Vista, you may find the cursor unresponsive; for instance, it would halt and jump to a new location after a some seconds of use. The problem seems to be caused by the underlying GTK library not processing all the events from the tablet device. Drawing tools that use different libraries, such as Paint.Net don't have this problem.

A work-around is to avoid using devices via the WinTab interface. Just add the following option to the Windows shortcut for the GIMP and Inkscape: --no-wintab.

There's some drawbacks of this work-around:

  • You can't use the pressure sensor on the Wacom stylus to change the drawing cursor in the GIMP.
  • You can't use the eraser on the rear of the Wacom stylus as another drawing tool.

2008-05-06: Another bug to track is Wacom Bamboo Doesn't Function with GTK apps in Win32.

2007-10-26

GIMP 2.4 Released

GIMP 2.4 has been released. For occasional users with Windows Vista, the most noticeable change is that it only takes seconds to load after the first time; in version 2.2.x, it used to take about half a minute. However, support for Wacom tablet is not good; the pointer still freezes after some seconds. Maybe the next version of GTK would improve the situation?

2007-08-15

Synaptics Touchpad Sketch Utility

Tried drawing with the Synaptics touchpad; after all, there should be a way to map your finger's position to an absolute location in a window or on the screen. Found a little Synaptics Sketch utility for doodling, but it was pretty useless because it doesn't show your finger's position before you make a mark and you can only save your image in a proprietary "SKE" format. Oh, well.

2007-08-11

GIMP Transparent Backgrounds

Steps for making a transparent GIF layer in GIMP.

  1. Open your GIF image file.
  2. Open the Channels tab. You should see a single Indexed channel.
  3. Add Alpha Channel (Layer / Transparency / Add Alpha Channel). You should see a new Alpha channel added in the Channels tab.
  4. Make a selection by selecting a colour (Select / By Color then click on the area with the required colour).
  5. Optionally, enlarge the selection (Select / Grow, then enter the number of pixels in the Grow Selection dialog). See note below.
  6. Clear the selection (Edit / Clear).
  7. Save your GIF image file.

When making a transparent GIF with GIMP, sometimes the borders of the image can be a little ragged, especially next to a curve with antialiasing. One solution is to "grow" the selection by one pixel (Select / Grow) before clearing all the pixels for the transparent layer.