09-09-2018, 07:11 AM | #1 |
Member
Posts: 20
Karma: 110
Join Date: Jun 2018
Device: Boox Note 10.3
|
Smoothing out KNote notes
So I've spent the last semester using KNote to take my lecture notes, and I've been pretty happy with it. There are some features (like selection tools) that could be there and aren't, but that's not a big problem.
When I started using my notes to study for the exams, though, I noticed that the way the notes are exported is less than ideal. Although they are exported as PDF, the writing is not vectorised, and zooming a bit on the notes is enough to see the jagging and pixelization on the writing. Moreover, I think the guidelines behind the writing just add to the clutter, and there's no option to export the notes without the guidelines (except of just removing them before exporting) I eventually found a way to work around this that I would like to share, and it is very simple. Using imagemagick one can remove the background and convert the PDF file to a set of bitmap files. The output (which is just black and white) can then be fed into potrace to vectorise the handwriting. Both programs are open-source. An early bash script for this would be along the lines of: Code:
#!/usr/bin/env bash FULL_EXT=${1?Error: no name given} NAME_EXT=$(basename $FULL_EXT) FULL_NOEXT=${FULL_EXT%.pdf} NAME_NOEXT=${NAME_EXT%.pdf} mkdir ~/tmp convert ${FULL_EXT} -fill white +opaque "#000000" -background white -alpha remove ~/tmp/${NAME_NOEXT}.bmp a="potrace -b pdf " for entry in ~/tmp/* do a+=$entry\ done a+="-o ${FULL_NOEXT}.pdf" $a rm -r ~/tmp Detail comparison: One could then construct a routine where the notes are synced from the KNote app to e.g. Dropbox, Dropbox syncs the files to a local folder on the computer, and then a script that monitors the folder for new versions of the files processes the files in the above way. So every time the notes are opened in the computer they would already be automatically processed. EDIT: I forgot to say that, due to vectorisation, one can indefinitely zoom in the notes without loss of resolution. Last edited by zsdiogo; 09-09-2018 at 07:14 AM. |
09-09-2018, 08:51 AM | #2 |
Addict
Posts: 350
Karma: 22726
Join Date: Mar 2008
Location: Europe
Device: Boox max 2
|
bookmarking this thread because I had the same problem.
|
Advert | |
|
09-13-2018, 10:39 AM | #3 |
Member
Posts: 23
Karma: 50
Join Date: Jul 2018
Location: Amsterdam
Device: Onyx Boox Max 2 / PocketBook Inkpad 3 / Kindle Paperwhite 3
|
Great idea. One tip: If you explode that PDF with poppler’s pdfimages, you can simply take the writing layer images and discard the rest (including the background template).
|
09-13-2018, 01:15 PM | #4 |
Member
Posts: 20
Karma: 110
Join Date: Jun 2018
Device: Boox Note 10.3
|
Yeah, I though about trying to expand the PDF to see if I could do something like that. But luckily all the backgrounds are in some shade of grey, and so it's easy to use imagemagick to solve two problems with one command: convert to bitmap and exclude all non-black colours.
|
12-08-2018, 02:40 AM | #5 |
Connoisseur
Posts: 92
Karma: 216
Join Date: Oct 2011
Device: Kindle
|
I have installed both imagemagick and potrace through brew on my Mac, but when attempting to run the script in Terminal, I keep getting this error:
Code:
bash graf.sh note8.pdf convert: FailedToExecuteCommand `'gs' -sstdout=%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pngalpha' -dTextAlphaBits=4 -dGraphicsAlphaBits=4 '-r72x72' '-sOutputFile=/var/folders/65/rnwl3xfs09vdnmb4v36ksh1c0000gn/T/magick-6019unPXRJTYmLWU%d' '-f/var/folders/65/rnwl3xfs09vdnmb4v36ksh1c0000gn/T/magick-6019mC1jfwxXKtfZ' '-f/var/folders/65/rnwl3xfs09vdnmb4v36ksh1c0000gn/T/magick-6019iTtQTQd9b6Vx'' (1) @ error/pdf.c/InvokePDFDelegate/290. convert: no images defined `/Users/siavush/tmp/note8.bmp' @ error/convert.c/ConvertImageCommand/3300. potrace: /Users/siavush/tmp/*: No such file or directory Many thanks |
Advert | |
|
12-10-2018, 04:21 AM | #6 | |
Member
Posts: 20
Karma: 110
Join Date: Jun 2018
Device: Boox Note 10.3
|
Quote:
|
|
12-12-2018, 02:08 AM | #7 |
Connoisseur
Posts: 92
Karma: 216
Join Date: Oct 2011
Device: Kindle
|
|
12-12-2018, 02:52 AM | #8 |
Member
Posts: 20
Karma: 110
Join Date: Jun 2018
Device: Boox Note 10.3
|
Well PoTrace is very good at what is does, but it is also very restrictive in terms of features. If you give it the pic with the grid it will also trace over the grid. What you could do is just extract the grid and keep it somewhere in your PC, and add a line on the script with imagemagick to merge the output PDF with the grid PDF.
|
Tags |
max 2, note |
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Knote custom templates (noteTemplate) | alansingfield | Onyx Boox | 16 | 07-26-2019 06:24 PM |
Knote - png - OneNote - ocr in pc | crAss | Onyx Boox | 5 | 10-05-2018 02:18 PM |
Font smoothing in the viewer | JackGruff | Library Management | 0 | 10-10-2012 08:09 AM |
DR800 Font smoothing | dima_tr | iRex | 1 | 07-04-2010 04:25 PM |
PRS-600 Notes on Notes (not good) | FlyFree | Sony Reader | 24 | 12-08-2009 07:23 PM |