View Single Post
Old 02-15-2018, 01:25 PM   #335
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 9,611
Karma: 6774048
Join Date: Nov 2009
Device: many
Need Help with Access-Aide_v030.zip

Hi All,

It seems tk does not like svg images and for Access-Aide_v030.zip I will need to create a scaled png from any .svg images used the epub.

To do that for tkinter I either need heavy svg related code such as librsvg, librsvg2, cairo, and etc just to rasterize an svg.

Instead of those huge libraries, I found a very nice little project called nanosvg on github. This c code is actually in the form of headers that can be easily compiled to create a nano svg2png command line program I wrote called nsvg2png.

Please see the attached Access-Aide_v031.zip and unzip it and look inside the src/ directory.

I can compile the nsvg2png.c using a very simple one-line compile command on osx and all of this works just fine.

Code:
kbhend$ unzip Access-Aide_v031.zip
Archive:  Access-Aide_v031.zip
   creating: Access-Aide/
  inflating: Access-Aide/accessgui.py  
  inflating: Access-Aide/missing_image.png  
   creating: Access-Aide/osx/
  inflating: Access-Aide/osx/nsvg2png  
  inflating: Access-Aide/plugin.png  
  inflating: Access-Aide/plugin.py   
  inflating: Access-Aide/plugin.py.keep  
  inflating: Access-Aide/plugin.xml  
   creating: Access-Aide/src/
  inflating: Access-Aide/src/BUILD.TXT  
  inflating: Access-Aide/src/LICENSE.txt  
  inflating: Access-Aide/src/nanosvg.h  
  inflating: Access-Aide/src/nanosvgrast.h  
  inflating: Access-Aide/src/nsvg2png.c  
  inflating: Access-Aide/src/stb_image_write.h  
   creating: Access-Aide/unx32/
   creating: Access-Aide/unx64/
   creating: Access-Aide/win32/
   creating: Access-Aide/win64/

kbhend$ cd Access-Aide

kbhend$ cd src

kbhend$ ls
BUILD.TXT		LICENSE.txt		nanosvg.h		nanosvgrast.h		nsvg2png.c		stb_image_write.h


kbhend$ # compiling it is very easy

kbhend$ gcc -Wall -O2 -I. -o nsvg2png nsvg2png.c

kbhend$ ls -al
total 456
drwxr-xr-x   9 kbhend  staff    306 15 Feb 13:12 .
drwxr-xr-x  14 kbhend  staff    476 15 Feb 11:55 ..
-rw-r--r--   1 kbhend  staff     94 15 Feb 11:33 BUILD.TXT
-rw-r--r--   1 kbhend  staff    880 15 Feb 11:25 LICENSE.txt
-rw-r--r--   1 kbhend  staff  77806 15 Feb 11:24 nanosvg.h
-rw-r--r--   1 kbhend  staff  38111 15 Feb 11:24 nanosvgrast.h
-rwxr-xr-x   1 kbhend  staff  78068 15 Feb 13:12 nsvg2png
-rw-r--r--   1 kbhend  staff   2825 15 Feb 11:31 nsvg2png.c
-rw-r--r--   1 kbhend  staff  18599 15 Feb 11:24 stb_image_write.h

kbhend$ cp ../../drawing.svg ./

kbhend$ ./nsvg2png ./drawing.svg

parsing ./drawing.svg
Rasterizing image 1000 x 1000

kbhend$ ls
BUILD.TXT		drawing.svg		nanosvg.h		nsvg2png		stb_image_write.h
LICENSE.txt		drawing.svg.png		nanosvgrast.h		nsvg2png.c
So if someone has access to an old linux box and compile nsvg2png for 32 and 64 bit executables and can compile it for win32 and win64 and make those builds available to me it would be wonderful!

That way I could add them to Access-Aide plugin (similar to how flightcrew is done).

I have added a zip with sample svg images and a very simple test.epub to test Access-Aide with once you have added the nsvg2png exectuable to the right place.

Thanks in advance for any help.

KevinH
Attached Files
File Type: zip sample_svgs.zip (34.2 KB, 587 views)
File Type: epub test.epub (74.3 KB, 608 views)
File Type: zip Access-Aide_v031.zip (139.1 KB, 656 views)

Last edited by KevinH; 02-15-2018 at 03:08 PM.
KevinH is online now   Reply With Quote