Inkbook Introduction
Posted by cheshirekow in Inkbook, Uncategorized on June 7, 2011
Inkbook is a new project I’ve started to replace Xournal for my needs. What I really want is a tightly integrated, full-features inking experience for Ubuntu.
What’s wrong with xournal?
Xournal is great. I use it all the time. However, there are a lot of really simple features I would like it to have. I took a look at the code, and it’s pretty hard to understand. The lack of good documentation means it’s not worth my time. There’s no sense in committing a ton of time trying to learn the code base, just to find out that an apparently simple feature is impossible to implement without restructuring the whole thing. So, I’m just restructuring the whole thing :).
I’ll start by going through all the things that I don’t like about Xournal.
Memory Usage
One of the biggest problems I have with Xournal is it’s memory usage. A typical 10 page Xournal document consumes around 300MB of RAM, and takes about 60 seconds to open. This is a big nuisance to me. I suspect that Xournal stores the whole document in memory, which is the cause.
Bitmaps
A lot of times I really want to paste some snippet into my notes. There is a Xournal patch for using bitmaps, and it’s not terrible, but the images render fuzzy and it’s difficult to scale and place them in the document. I usually end up exporting the whole thing to PDF for later reference. I’ve written a script which can copy parts of the screen to the clipboard (like the Adobe Reader snapshot tool), so I’d really like to be able to drop a bunch of images into a notebook and draw around them, write on them, etc.
Layers
I think that layers are a really useful tool, but it’s hard to use them in xournal. First of all, you have to select them from a drop down list at the bottom of the screen, not a list box. You can’t reorder them. And if you move to a lower layer, all the layers above it disappear.
Pen Options
Only three line widths and no fast-access colorwheel.
Shapes
Can only draw shapes by having the recognizer interpret them. Why not have shape tools that allow you to drop the shape and then resize, move around?
No lasso tool
Rectangular selection just doesn’t cut it for me. Especially when I have potato shaped drawings that I want to move around, without moving the text around it.
Inkbook
What I really want is a digital notebook. Inkbook aims to be just that. Inkbook is really a merger of features that I like from both Xournal and Inkscape, and an attempt to fix some of the problems I have with both. Here is a list of the features I’m currently focusing on.
- very large documents
- ability to organize notebooks (like folders)
- ability to link individual pages to multiple notebooks
- multiple layers per page
- multiple page sizes
- continuous range of brush sizes
- continuous color picking
- bitmap cut & paste
- grouping of paths
- objects (shapes)
- collaboration (openbook module?)
Very large documents and Organization
I want to be able to have several dozens of pages in a document, which basically means that the entire document can’t be stored in memory. Therefore, I’m attemping to store the data an a sqlite database. This also addresses the desire to have better organizational facilities. I’m implementing separate database objects for notebooks, pages, layers, objects, and paths.
A notebook is an ordered list of notebooks and an ordered list of pages (i.e. a folder). A page is an ordered list of layers. A layer is an ordered list of objects. An object is an ordered list of objects, images, or paths. A path is an ordered list of drawing primitives (most likely a one-to-one mapping to the cairo API).
Organization and View
For organizing notebooks, I plan to have a triew-view (i.e. directory tree). I’ll have a thumbnail page view which shows the current pages and those near it, and allows for scrolling through the whole notebook. This will be a custom widget which renders each of the pages via their thubmail image. I’ll have a list-view to organize layers on the page. The list view will also show list complex objects so they can be easily selected and edited (but it wont display any information about handdrawn paths, as there will be a large number of these). The main view will display a viewport of the page.
Current Progress
I’ve got a proof-of-concept running with the sqlite database file backend and working views the notebook organization and layers. I’ve got a proof-of-concept for the thumbnail view but it needs more work. It’s written in C++ and meant to be very easy to understand and extend. I’m using Gtkmm3 (unstable) because it’s GTK, but it’s C++, and it has cairo as the native API. Here’s a screenshot:
Emulating Adobe Reader’s Snapshot tool in Ubuntu
Posted by cheshirekow in Ubuntu on June 7, 2011
In this post I presented a simple python script for copying image files to the gnome clipboard. In this post, I’ll show how I use this script with imageMagik to emulate the snapshot tool in Adobe Reader. I originally wanted to use this just for Evince (default Ubuntu document reader) but have found all kinds of situations where it’s handy outside of Evince.
The end goal here is to have a key binding which, when pressed, starts a “selection mode” where any part of the screen can be selected. That selection is then copied to the gnome clipboard so that it can be pasted into a document (i.e. a libreoffice or openoffice document, though I usually use it to paste into Xournal).
The script
Here is the script I use to do just that.
#!/bin/bash #prefix for filename prefix='screenshot'; timestamp=`date '+%d-%m-%y-%N'`; extension='.png'; file="/tmp/$prefix-$timestamp$extension"; import $file python $HOME/Codes/python/imgclip/imgclip.py $file |
The import
tool is part of the imageMagik
package. It does the screenshot taking part, by changing the mouse cursor to a “selection” tool. It saves the screenshot in /tmp/screenshot_TIMESTAMP.png
where the timestamp is generated by the date
command. The script then runs imgclip
to copy the screenshot to the clipboard. I have this script bound to a command in compiz. The command is
bash $HOME/Codes/shell/screenshot/screenshot.sh |
Here is a screencast of it in action:
ImgClip (xclip for images)
Posted by cheshirekow in Python on June 7, 2011
Here is a little python script I wrote to emulate xclip for image files. xclip, if you don’t know, is a simple command line tool for setting/retrieving text from the clipboard. For instance the following command
ls -l | xclip -i -selection clipboard |
copies the current directory listing to the gnome clipboard, where it can then be ctrl + v
pasted into a forum post, email, etc.
I really wanted something that does the same for image files. Unfortunately the following does not work:
cat image.png | xclip -i -selection clipboard |
I’m not sure of the details of how the gnome clipboard works… but this doesn’t do it. I discovered a way to do it easily using pygtk. Here is a python script that does exactly what I want:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #! /usr/bin/python import pygtk pygtk.require('2.0') import gtk import os import sys def copy_image(f): assert os.path.exists(f), "file does not exist" image = gtk.gdk.pixbuf_new_from_file(f) clipboard = gtk.clipboard_get() clipboard.set_image(image) clipboard.store() copy_image(sys.argv[1]); |
P.S. I pasted this code into this post using the following command
cat imgclip.py | xclip -i -selection clipboard |
Make sure to set the script to executable
chmod +x imgclip.py |
And then use it like this
./imgclip.py /path/to/some/image.png |