2012. december 31.

Multi-screen tablet usage: configuring the displays

ATTENTION! THIS POST IS OUTDATED!
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:

<pre><code>
import pygame
from pygame.locals import *

print "Pygame imported without errors."
 </code></pre>

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.

#!/bin/bash
#Ubuntu 10.04 Lucid Lynx

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

#START
echo "WELCOME TO AUTOMATED SCANIMAGE"
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"
fi

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
date=1
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
 fi
done

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:
http://www.jingai.com/scanningguide/profiling%20slides.html
http://www.ddisoftware.com/qimage/icc.htm

A tool called Argyll can be downloaded through Synaptic.
http://www.argyllcms.com/doc/ArgyllDoc.html
http://www.argyllcms.com/doc/Scenarios.html#PS1

To calibrate a scanner you will need something to scan that is accurate in color, i.e.:
http://www.targets.coloraid.de/
http://www.silverfast.com/show/it8-targets/en.html

(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:

  1. GSCAN2PDF
    scan image
    on 8-bit depth and 300 dpi resolution.
    save in PNM file format.
    this results in an approx. 20MB size file.
  2. CONVERT
    resize
    to 50%
    convert bigimg.pnm -resize 50% smallimg.pnm
    file size abt. 5MB
  3. PNMTOPS
    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
  5. PDFCROP
    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...