Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Readers > Onyx Boox

Notices

Reply
 
Thread Tools Search this Thread
Old 09-09-2018, 07:11 AM   #1
zsdiogo
Member
zsdiogo doesn't litterzsdiogo doesn't litter
 
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
And the result:
Click image for larger version

Name:	Screen Shot 2018-09-08 at 09.37.59.jpg
Views:	422
Size:	477.4 KB
ID:	166175

Detail comparison:
Click image for larger version

Name:	Screen Shot 2018-09-08 at 09.39.12.png
Views:	377
Size:	649.6 KB
ID:	166176

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.
zsdiogo is offline   Reply With Quote
Old 09-09-2018, 08:51 AM   #2
whopper
Addict
whopper can tie a knot in a cherry stem with his or her tonguewhopper can tie a knot in a cherry stem with his or her tonguewhopper can tie a knot in a cherry stem with his or her tonguewhopper can tie a knot in a cherry stem with his or her tonguewhopper can tie a knot in a cherry stem with his or her tonguewhopper can tie a knot in a cherry stem with his or her tonguewhopper can tie a knot in a cherry stem with his or her tonguewhopper can tie a knot in a cherry stem with his or her tonguewhopper can tie a knot in a cherry stem with his or her tonguewhopper can tie a knot in a cherry stem with his or her tonguewhopper can tie a knot in a cherry stem with his or her tongue
 
whopper's Avatar
 
Posts: 350
Karma: 22726
Join Date: Mar 2008
Location: Europe
Device: Boox max 2
bookmarking this thread because I had the same problem.
whopper is offline   Reply With Quote
Advert
Old 09-13-2018, 10:39 AM   #3
retrography
Member
retrography is on a distinguished road
 
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).
retrography is offline   Reply With Quote
Old 09-13-2018, 01:15 PM   #4
zsdiogo
Member
zsdiogo doesn't litterzsdiogo doesn't litter
 
Posts: 20
Karma: 110
Join Date: Jun 2018
Device: Boox Note 10.3
Quote:
Originally Posted by retrography View Post
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).
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.
zsdiogo is offline   Reply With Quote
Old 12-08-2018, 02:40 AM   #5
orpheus2011
Connoisseur
orpheus2011 doesn't litterorpheus2011 doesn't litterorpheus2011 doesn't litter
 
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
Could anyone advise on what's going wrong?

Many thanks
orpheus2011 is offline   Reply With Quote
Advert
Old 12-10-2018, 04:21 AM   #6
zsdiogo
Member
zsdiogo doesn't litterzsdiogo doesn't litter
 
Posts: 20
Karma: 110
Join Date: Jun 2018
Device: Boox Note 10.3
Quote:
Originally Posted by orpheus2011 View Post
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
Could anyone advise on what's going wrong?

Many thanks
It sounds like it might be a problem with the dependencies. Do you have ghostscript installed?
zsdiogo is offline   Reply With Quote
Old 12-12-2018, 02:08 AM   #7
orpheus2011
Connoisseur
orpheus2011 doesn't litterorpheus2011 doesn't litterorpheus2011 doesn't litter
 
Posts: 92
Karma: 216
Join Date: Oct 2011
Device: Kindle
Quote:
Originally Posted by zsdiogo View Post
It sounds like it might be a problem with the dependencies. Do you have ghostscript installed?
Many thanks - it was indeed the missing gs package! Works great now, but could you kindly recommend how to amend the convert command to keep the gridlines?
orpheus2011 is offline   Reply With Quote
Old 12-12-2018, 02:52 AM   #8
zsdiogo
Member
zsdiogo doesn't litterzsdiogo doesn't litter
 
Posts: 20
Karma: 110
Join Date: Jun 2018
Device: Boox Note 10.3
Quote:
Originally Posted by orpheus2011 View Post
Many thanks - it was indeed the missing gs package! Works great now, but could you kindly recommend how to amend the convert command to keep the gridlines?
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.
zsdiogo is offline   Reply With Quote
Reply

Tags
max 2, note

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

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


All times are GMT -4. The time now is 11:53 PM.


MobileRead.com is a privately owned, operated and funded community.