2012. december 31.

Multi-screen tablet usage: configuring the displays

In later editions of xinput it is possible to map the input device to the tablet screen automatically by using the 'xinput --map-to-crtc <device> <crtc>' option.
Check device with 'xinput list' and check crtc with  'xrandr'.
In my case the sylus was '12', the eraser '14' and the laptop screen 'LVDS1'

I had some time to take care about this problem of configuring the tablet screen to be able to take notes while reading stuff from the external display.

Here's my solution:

Make a nautilus script. It makes life easier.
You'll have to run all codes every time, otherwise this won't work.

Here's the pattern to use:
xsetwacom set 'Serial Wacom Tablet' Rotate [NONE | CW | CCW | HALF]
xsetwacom set 'Serial Wacom Tablet eraser' Rotate [NONE | CW | CCW | HALF]
xsetwacom --set "Serial Wacom Tablet" "TwinView" none
xsetwacom --set "Serial Wacom Tablet eraser" "TwinView" none
xinput -set-prop "Serial Wacom Tablet" "Wacom Tablet Area" x1, y1, x2, y2
xinput -set-prop "Serial Wacom Tablet eraser" "Wacom Tablet Area" x1, y1, x2, y2
Here's how to do it:
The amount to multiply resolution pixel numbers is: 24,2
You multiply with this number, and than round the number to a whole.

How to define x1, y1, x2 and y2?

Embedding code on Blogger

Thank you for NYRPNZ for the following solution, and css-tricks for the text wrapping part:

By default, you can use <code> and </code> in Blogger to keep the formatting of a code intact, and to differenciate it from the rest of the text. However, with this tweak you can create a new tag that will put an eye-catching ugly gray box in your post to surround your code.

Customize your Template, go into advanced, and then select the "Add CSS" subcategory. Insert this code (By the way, this is what the code will actually look like on your site when you have finished):

pre {
  background-color: #DFDFDF;
  color: #000000;
  border: 1px dotted gray;
  width: 95%;
  padding: 10px;
/* to make the text inside the pre tag wrap: */
  white-space: pre-wrap;       /* css-3 */
  white-space: -moz-pre-wrap;  /* Mozilla, since 1999 */
  white-space: -pre-wrap;      /* Opera 4-6 */
  white-space: -o-pre-wrap;    /* Opera 7 */
  word-wrap: break-word;       /* Internet Explorer 5.5+ */

Now to embed code, switch to HTML mode, paste the code into your post, then surround it with <pre><code>and </code></pre> like this:

import pygame
from pygame.locals import *

print "Pygame imported without errors."

Important Note: In case you actually have <> brackets in your code, you will have to replace them with &lt; for < signs and &gt; for > signs. In case you actually need to embed an ampersand followed by some characters followed by a semicolon, you will need to replace the ampersand with &amp;. Yes, this is annoying. Unfortunately I can find no better way to do this on Blogger at the moment.

Scanning script for SCANIMAGE

As I wrote before, the program called scanimage cannot scan to numbered files repeatedly.
Well, not anymore.

I wrote a little script to automate the scanning.
I did this because I dislike gscan2pdf scanning to temp. I find it too risky not having the file in a safe place after scanning.

#Ubuntu 10.04 Lucid Lynx

#Automatization of "scanimage" to create sequentially numbered output.

echo ""

echo "Please give me the size of scan area in mm"
echo -n "width: "; read x
echo -n "height: "; read y
#make it failsafe:
if [[ $x>213.8 || $x = "" ]]; then x="213.8"; fi
if [[ $y>300 || $y = "" ]]; then y="300"; fi

echo "Scan area will be: $x x $y mm"
echo ""

echo "Please choose scan mode: L for Lineart, G for Gray. Press enter for Color."; read mode
#make it failsafe:
if [[ $mode == [Ll] ]]; then mode="Lineart" && ext="pbm"
elif [[ $mode == [Gg] ]]; then mode="Gray" && ext="pnm"
else  mode="Color" && ext="pnm"

echo "Scan mode will be $mode"

#print "to start printing press enter to quit press escape"
#scan and save
#go back to enter or escape
while true; do
 echo -n "Press 'enter' to scan; anything else to quit' "; read scan;
 if [[ $scan = "" ]]; then
  let "date =`date +%Y%m%d%H%M%S`"
  echo "Scanning will progress with the following parameters:"
  echo "size: $x x $y, mode $mode, filename: $date.$ext"
  scanimage -x $x -y $y --mode $mode > $date.$ext
 else break

echo "Finished scanning. Thank you for using this script :-*"

Scanner Color Correction

The combination of Canon LiDE210 and SANE provides me a usable scanner on Ubuntu.
However when scanning in color, colors are NOT accurate.

Color calibration is however not so simple as I thought.

The scanner needs to have an ICM/ICC profile.

Here are some sites regarding color correction:

A tool called Argyll can be downloaded through Synaptic.

To calibrate a scanner you will need something to scan that is accurate in color, i.e.:

(which I do not have, so this is it for now. Until then I will simply use a post-processing color correction method.)

2012. december 29.

Small size Color PDF

After years of struggling with color PDF-s, I realized today that color PS exists, which lead to a fast solution on the given problem.

Here's how it goes:

    scan image
    on 8-bit depth and 300 dpi resolution.
    save in PNM file format.
    this results in an approx. 20MB size file.
    to 50%
    convert bigimg.pnm -resize 50% smallimg.pnm
    file size abt. 5MB
    convert to ps
    pnmtops -equalpixels smallimg.pnm > smallimg.ps
    file size abt. 10MB
  4. PS2PDF
    convert to pdf
    ps2pdf12 smallimg.ps smallimg.pdf
    */Sadly, I could not manage to have the pdf cropped to the proper size with ps2pdf, so I have to do it manually in the next step. However if You know the solution to this problem do not hold back on sharing it with me!/*
    file size abt. 200KB
    crop pdf of unnecessary margin
    pdfcrop smallimg.pdf
    (resulting in smallimg-crop.pdf)
    final file size abt. 200KB
This is how you do a good quality color pdf from good quality large images.

...And a couple months later (19 May 2013) I realized that my method of producing black-and-white pdfs, which I use since years, is just as good to produce color pdfs as the above or even better because with the old method I do not have to use pdfcrop, ad the pdf page size of the color cover will be compatible with the b&w pages...

2012. augusztus 26.

Watermarking PDF-s

Program used:
PDFTK (get from Synaptic)
* Apply a Background Watermark or a Foreground Stamp


pdftk [input filename="filename" pdf="pdf" ] stamp [stamp filename="filename" pdf="pdf"] output [output filename="filename"]

What happens?

I made a transparent background GIF with GIMP, converted it to pdf, with Mogrify, and applied it to the pdf.

Application of a different size watermark image than the original pdf page happens with scaling the watermark image to fit the height and with keeping the watermark's size ratio, and fitting it in the center of the original page.

2012. június 28.

Scanned Image Color Correction

Seems like using -contrast-stretch 1x10% in ImageMagick's convert is useful after scanning color image bit depth 8 density 300 with gscan2pdf and Canon LiDE 210.

2012. június 9.

New Era

I upgraded my life to using Android.
I feel totally high-tech. And my SE MW600 is working perfectly out of the box with the Motorola Defy. Life is beautiful :-)

2012. április 24.

Canon LiDE 210 scanning statistics

Scanning speed:
only about 3 pages/minute.
scan mode Lineart, Dpi 300, Threshold 40, Threshold Curve 50

Error type #1:
Scanner head does not move. This produces an empty page.
Happens not every time, but only in cases when I press scan button before the head returns to the original position.

2012-04-24: out of 293 pages 11 pages: #4, #6, #11, #82, #143, #191, #205, #214, #231, #274, #278.

Error type #2:
Scanning error. Produces messed up image.

2012-04-24: out of 293 pages 1 page: #113.

2012. április 15.

Learning to type

I'm trying out kTouch now, and creating a set of meaningful words for my own practice. Well, practicing letters is a must do, but it's much better to have regular words too...

2012. április 13.

Chrome & Shockwave Flash using 100% of CPU

I'm just making a note here:

Shockwave flash running on Google Chrome uses about 100% of my CPU capacity.

This causes the cooling ventillation to run high speed, which produces much noise, and it also causes the machine to gain a quite high heat.

2012. április 3.

Testing gscan2pdf output formats

Lineart 300dpi 260x200mm scans
123 pages

Downsample to: no downsampling

Compression: Automatic
FileSize: 29.1MB

Compression: LZV
FileSize: 29.1MB

Compression: ZIP
FileSize: 29.1MB

Compression: PackBits
FileSize: 47.4MB

G3 and G4 encoding didn't work for me.

Compression: PNG
FileSize: 30.4MB

Compression: JPEG 75% compressed
FileSize: 221.7MB

Compared to my method of converting pnm through ps to pdf:
FileSize: 22.4MB (This is the smallest pdf on 300dpi)

FileSize: 13MB

Compared to my method of converting pnm to djvu:
FileSize: 13MB (Equal size)

gscan2pdf Session
FileSize: 591.1MB

Sum FileSize: 114.6MB

Sum Filesize: 33.5MB

not working.

Can change compression method (LZW, ZIP, JPEG, PackBits, G3, G4, none)
not tested

Can change compression quality
not tested

2012. április 2.

Using the Canon LiDE 210 on Ubuntu

Now, that I got "Alice" (laptop) to recognize "Susy" (scanner), I will try out a variety of scanning software to pick the best for my needs.

Here's a list of "frontends" that work with SANE (Scanner Access Now Easy)
(Here's a daemon for mapping scanner buttons, for the case I find the ideal software.)

This is what I do:
a) I digitalize black-and-white documents in large amounts.
b) I digitalize color photographs
This is what I need a scanning program to be:
b) accurate in color

The winner of FAST scanning of monochrome documents is:

Reviews follow below.

a) FAST scanning of monochrome text documents

Command Line Frontends

installation: comes with SANE.

- easy to use
- easy to define scan area (x and y in millimeters)
- can't be automated to scan repeatedly to numbered documents. -> NOT ANYMORE!


scanimage --mode Lineart --resolution 1200 >img1200.pnm
approx 50 seconds. it is so detailed it is basically grayscale. 17.1MB 10096x14173px
scanimage --mode Lineart --resolution 600 >img600.pnm
approx 10 seconds. good quality. a bit noisy. 4.3MB 5048x7086px
scanimage --mode Lineart --resolution 300 >img300.pnm
approx 6 seconds. good quality. same amount of noise as on res600. maybe it's better to scan res600 and resize 50% than to scan res300. 1.1MB 2520x3543px
scanimage --mode Lineart --resolution 150 >img150.pnm
approx 6 seconds. Quality not acceptable. 271.6KB 1250x1771px

further testing: I'll have to play with threshold and other parameters to maybe get a better result.

installation: scanadf needs the SANE source code to be patched to install it. this means I should patch, configure, make and make install, which, now, I will not do.

Graphical Frontends

installation: through synaptic

- can configure all what scanimage can
- can save files numbered
- can do postprocessing
- no pnm, only tiff or jpeg


Lineart with various resolutions and output file type

for some reason Eikazo likes to die on me. I set some parameters, scan, and then I cannot change anything anymore, and cannot scan anything anymore...

This is an archiving software. yes, it can scan using SANE, but it's main purpuse is to crate tagged, searchable a database from all the files you scan.
I don't need such a thing. I don't install.

- configuration is the same as scanimage with the same defaults
- can post-process: rotate, clear, OCR
- can save to a variety of files (pdf, gif, jpg, png, pnm, ps, tif, text, gscan2pdf-session, djvu). pdf and tif are with a variety of options on compression or downsampling.
- it's quick to scan. I just have to press the button everytime I'm finished positioning the next page.
- you can click "scan" button to queue the next scanning to save some seconds.
- I found none so far.
- takes 13 seconds to reposition the head. But this is probably a hardware thing.
Testing #1:

I easily made the scanner to go post it's scannig size limits. No catastrophe happened, thank god. SANE ReadMe warns, that this type of abuse can damage the scanner hardware.
Okay, I think it was the "Page Options" "All" which is probably for Automated Document Feeder. I don't dare to change # to more than 1. Anyway, it's written in scanadf's manual: "Use of this program with backends that do not support ADFs (e.g. flatbed scanners) will likely result in repeated scans of the same document. In this case, it is essential to use the start-count and end-count to control the number of images acquired."
scanning quality, size and time results are the same as in scanimage.

Testing #2

In the reality, it takes 19 seconds to scan a 200x280mm page. It takes 6 seconds to scan 300dpi, and it takes 13 seconds to reposition. This is awful. I will have to see if there is something to be done to fasten the repositioning.

Canon LiDE 210 flatbed scanner on Ubuntu

So I got this brand new flatbed scanner: Canon LiDE 210.

I have read here, that it works with Ubuntu. Actually that was a good reason for picking this scanner. Remember, I still have the Ubuntu 10.04 LTS running on Alice.

This is how I got it work:
1.) sudo add-apt-repository ppa:plaxx/random-fixes
2.) Open System> Administration> Software Sources
...go to "Other Software" tab
Edit "http://ppa.launchpad.net/plaxx/random-fixes/ubuntu lucid main"
Change "lucid" to "maverick"
(leave the source checked!)
3.) sudo apt-get update
4.) sudo apt-get install libsane sane-utils
5.) reboot

In the process of trying I installed the latest SANE and libusb, I don't know what kind of effect this had on the outcome.

This is what happened before I got "Susy" (this is how I named the LiDE 210) to work:
1.) I unboxed the scanner. Made a video of it, 'cause this little thing is amazing.
2.) Plugged it in the USB...
3.) ...nothing happened.
Oh, no problem, this wasn't Ubuntu if everything worked out of the box.

So let's see, what we can do to get the scanner running:
1.) Check the SANE site for details on how the scanner is supported:
genesys1.0-62CanoScan LiDE 210USB0x04a9/0x190acompleteGL124 based, resolution from 75 to 2400 dpisane-genesys
2.) Install the newest SANE version (1.0.22)
3.) Install libusb-dev files through Synaptic
4.) Install the newest libusb version
5.) Plugging in the scanner again...
...still nothing happens.
6.) Restarting the computer...
...still nothing
7.) Trying out on Windows7...
...it works! Yeah! At least the product is functioning for sure.

Okay... let's go another round... how should an usb scanner work on Ubuntu?
1.) Checking Ubuntu Documentation.
2.) Checking Support Forums... Found something worth a try. (Changing the bottomlesspit thing's repository from lucid to maverick, as it is originally for maverick.)
3.) Doing the update end install thing again
4.) Restarting...
...and it works! :-) Finally.

2012. február 21.

Manual Wireless Network Configuration

Unencrypted WLAN connect manually

sudo ifconfig wlan0 down
sudo dhclient -r wlan0
sudo ifconfig wlan0 up


sudo iwconfig wlan0 essid "Name Of Network"
sudo iwconfig wlan0 mode Managed
sudo iwconfig wlan0 ap MA:CA:DD:RE:SS:ZZ
sudo dhclient wlan0

Search For Networks:
sudo iwlist scan

Possible Network Handling Software: