SVG renderer <SOLVED>
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
SVG renderer <SOLVED>
Edition:LM13 with cinnamon
Which is the default SVG renderer. I'm guessing it's rsvg. All the icons included the distro are inkscape svg(contain a lot of inkscape clutter like grid/guide positions, etc). Would it be better if they were plain svg, optimized manually and/or with scour(would it reduce rendering time?).
Which is the default SVG renderer. I'm guessing it's rsvg. All the icons included the distro are inkscape svg(contain a lot of inkscape clutter like grid/guide positions, etc). Would it be better if they were plain svg, optimized manually and/or with scour(would it reduce rendering time?).
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: SVG renderer
Nice question but how would one assess rendering time in the context of day-to-day usage? Note that I'm not defending "clutter" in anyway!gauravjuvekar wrote:Edition:LM13 with cinnamon
Which is the default SVG renderer. I'm guessing it's rsvg. All the icons included the distro are inkscape svg(contain a lot of inkscape clutter like grid/guide positions, etc). Would it be better if they were plain svg, optimized manually and/or with scour(would it reduce rendering time?).
Re: SVG renderer
A quick google search revealed this.
http://www.mediawiki.org/wiki/SVG_benchmarks
Common logic says that the bigger a file, more time is needed to render it, as more code needs to be parsed/interpreted.
I guess it won't matter much in daily usage(milli seconds) but would certainly save space;scour reduced https://github.com/linuxmint/mint-x-ico ... irefox.svg to 29.64% of its size, from about 7168 lines to about 530 lines. That's for one file. Now consider that for hundreds of applications multiplied by a lot of icon sets. Also consider icons in cinnamon themes, applets, etc.
That file was about 254 kb. Assuming 100 such files multiplied by 5 themes, it comes to about 127000 kb. 29.64% of that is 37642.8 kb. Thats 87.26 mb saved. And I didn't include themes/applet svg files. Now one could fit many small apps like inkscape, geany and many games(gbrainy and stuff that comes preinstalled in ubuntu) preinstalled in the ISO image.
http://www.mediawiki.org/wiki/SVG_benchmarks
Common logic says that the bigger a file, more time is needed to render it, as more code needs to be parsed/interpreted.
I guess it won't matter much in daily usage(milli seconds) but would certainly save space;scour reduced https://github.com/linuxmint/mint-x-ico ... irefox.svg to 29.64% of its size, from about 7168 lines to about 530 lines. That's for one file. Now consider that for hundreds of applications multiplied by a lot of icon sets. Also consider icons in cinnamon themes, applets, etc.
That file was about 254 kb. Assuming 100 such files multiplied by 5 themes, it comes to about 127000 kb. 29.64% of that is 37642.8 kb. Thats 87.26 mb saved. And I didn't include themes/applet svg files. Now one could fit many small apps like inkscape, geany and many games(gbrainy and stuff that comes preinstalled in ubuntu) preinstalled in the ISO image.
Re: SVG renderer
Well, thanks to you, I've installed Inkscape and and python-scour and will play around some.gauravjuvekar wrote:A quick google search revealed this.
http://www.mediawiki.org/wiki/SVG_benchmarks
Common logic says that the bigger a file, more time is needed to render it, as more code needs to be parsed/interpreted.
I guess it won't matter much in daily usage(milli seconds) but would certainly save space;scour reduced https://github.com/linuxmint/mint-x-ico ... irefox.svg to 29.64% of its size, from about 7168 lines to about 530 lines. ....
I fully agree that a lot of unessential material is present on our computers but, each time the topic comes up, people go on about how cheap storage and RAM and processing power have become. So there's not really any necessity or incentive to keep things clean.
Also, there's the whole fonts and languages and locales business. LibreOffice packs a bunch of extensions by default, making things even more bloated. I could go on ... But this thread is about SVG bloat.
Re: SVG renderer
Could you put up the code to do this? I have firefox.svg on my desktop.gauravjuvekar wrote:... scour reduced https://github.com/linuxmint/mint-x-ico ... irefox.svg to 29.64% of its size, from about 7168 lines to about 530 lines. That's for one file. ...
Basically, I'd like to know how to reduce individual svg files.
Thanks in advance!
Re: SVG renderer
Okay, this is what I did:aes2011 wrote:Could you put up the code to do this? I have firefox.svg on my desktop.gauravjuvekar wrote:... scour reduced https://github.com/linuxmint/mint-x-ico ... irefox.svg to 29.64% of its size, from about 7168 lines to about 530 lines. That's for one file. ...
Basically, I'd like to know how to reduce individual svg files.
Thanks in advance!
Code: Select all
python /usr/share/pyshared/scour.py -i in.svg -o out.svg
Code: Select all
Original file size: 254626 bytes; new file size: 84178 bytes (33.05%)
Re: SVG renderer
Okay, now I want to know how to do it for all the svg files in a folder and subfolders? Is that possible or does it require advanced CLI skills?
Re: SVG renderer
Sorry for the late reply. I emailed Clem and he said it's a go ahead. I have already started the task.
See
https://github.com/gauravjuvekar/mint-x-icons
and
https://github.com/gauravjuvekar/mint-themes.
-------------------------------------------------------------
For bulk, I have a simple and dirty bash script to do half of the job. It's not very efficient as it calls inkscape for each file making it very slow. Also, your file name shouldn't contain any spaces.
You need to put it in a <just-a-file-name>.sh and make it executable, then put this file in the directory containing the svg icons that you want to optimize.
It will create two sub-directories-"inkscape" and "scour".
The script first uses inkscape to remove unused definitions and then output as plain svg and puts these files in the inkscape folder. Then it takes those files from the inkscape folder, scours them with the given options and outputs the scoured files into the scour directory.
Then, I manually open each file in the scour directory, hand-optimize it some more and validate it via validator.w3.org. However, before all of this, I open each file in inkscape and see if there are any elements outside the page(visible area) and remove them.
If you are saying that the fonts used in svgs need to be installed on the system(thus making dependencies of the fonts being substituted for other ones), then it doesn't apply as almost all the SVGs that I encountered have the text(fonts) converted to paths(bloating the size largely for text that will rarely be read) eg, see https://github.com/gauravjuvekar/mint-x ... ct-new.svg
See
https://github.com/gauravjuvekar/mint-x-icons
and
https://github.com/gauravjuvekar/mint-themes.
If you want to do with individual files for testing rather than for a series of files requiring consistency, doaes2011 wrote: Could you put up the code to do this? I have firefox.svg on my desktop.
Basically, I'd like to know how to reduce individual svg files.
Thanks in advance!
Code: Select all
$ scour --help
... <scour outputs options here>
...
...
$scour -i <your input file>.svg -o <the name of your output file>.svg --<play> --<around> --<with-the-options> --<that-scour --help displays above>
Note:My method below does not do subfolders, you could tweak it if you like. I don't bother with subfolders, as am doing it in alphabetical batches which are approximately 20-30 for each letter. Also, you should run it in terminal so that you can see errors if any.aes2011 wrote: Okay, now I want to know how to do it for all the svg files in a folder and subfolders? Is that possible or does it require advanced CLI skills?
For bulk, I have a simple and dirty bash script to do half of the job. It's not very efficient as it calls inkscape for each file making it very slow. Also, your file name shouldn't contain any spaces.
Code: Select all
mkdir ./inkscape
count=1
echo Inkscaping
for i in *.svg
do
inkscape -z --vacuum-defs --export-plain-svg=./inkscape/$i $i
echo Done $count
count=`expr $count + 1`
done
echo Inkscape done, scouring
mkdir scour
cd ./inkscape
count=1
for j in *.svg
do
scour -i $j -o ../scour/$j --create-groups --enable-id-stripping --enable-comment-stripping --shorten-ids --remove-metadata --quiet
echo Done $count
count=`expr $count + 1`
done
echo Press enter to exit
read x
It will create two sub-directories-"inkscape" and "scour".
The script first uses inkscape to remove unused definitions and then output as plain svg and puts these files in the inkscape folder. Then it takes those files from the inkscape folder, scours them with the given options and outputs the scoured files into the scour directory.
Then, I manually open each file in the scour directory, hand-optimize it some more and validate it via validator.w3.org. However, before all of this, I open each file in inkscape and see if there are any elements outside the page(visible area) and remove them.
What do you mean by there's the whole fonts and languages and locales businessAlso, there's the whole fonts and languages and locales business. LibreOffice packs a bunch of extensions by default, making things even more bloated. I could go on ... But this thread is about SVG bloat.
If you are saying that the fonts used in svgs need to be installed on the system(thus making dependencies of the fonts being substituted for other ones), then it doesn't apply as almost all the SVGs that I encountered have the text(fonts) converted to paths(bloating the size largely for text that will rarely be read) eg, see https://github.com/gauravjuvekar/mint-x ... ct-new.svg
Re: SVG renderer
Gaurav, thank you for taking the time to replygauravjuvekar wrote:Sorry for the late reply. I emailed Clem and he said it's a go ahead. I have already started the task.
See
https://github.com/gauravjuvekar/mint-x-icons
and
https://github.com/gauravjuvekar/mint-themes.
...What do you mean by there's the whole fonts and languages and locales businessAlso, there's the whole fonts and languages and locales business. LibreOffice packs a bunch of extensions by default, making things even more bloated. I could go on ... But this thread is about SVG bloat.
If you are saying that the fonts used in svgs need to be installed on the system(thus making dependencies of the fonts being substituted for other ones), then it doesn't apply as almost all the SVGs that I encountered have the text(fonts) converted to paths(bloating the size largely for text that will rarely be read) eg, see https://github.com/gauravjuvekar/mint-x ... ct-new.svg
Two points ...
First, I'm a total noob in this svg business with no programming experience. Actually, I'm a total noob. So 99% of what you said went way over my head.
Second, forget about the LibreOffice stuff. That isn't related at all to the work you're doing (and is about bloat in general for which things like localepurge or Bleachbit are more appropriate).
What I'm doing is just playing with very simple svg icons (just shapes and paths) to understand the basics with the help of various tutorials.
Re: SVG renderer
I'll simplify the script more.
Open gedit, use the select all button above (Code: Select all), and copy the code into gedit. Then save the file somewhere with the extension .sh like abc.sh
Right click the saved file (through the file browser)--->properties------>permissions tab---->check the execute: Allow executing file as program---->close the properties box.
Put all the files that you want to work on in a separate folder. Copy the file that you just made executable in the same folder as the svgs and run it(by double clicking, preferrable running it in terminal as it would display when all files have been worked on.)
The script will create two subfolders in the folder where you placed the original svgs and the executable. The first folder "inkscape" includes intermediate files. These files would be the same as if they were opened in inkscape, vacuumed defs through file--->vacuum defs and saved as Plain svg rather than inkscape svg through the file---->save as option
The second folder "scour" contains the final output files. They are scoured with the options --create-groups --enable-id-stripping --enable-comment-stripping --shorten-ids --remove-metadata
I am also mostly a noob. Don't be afraid of the command line, appending --help to the name of any command simplifies it very much.
Code: Select all
mkdir ./inkscape
count=1
echo Inkscaping
for i in *.svg
do
inkscape -z --vacuum-defs --export-plain-svg=./inkscape/$i $i
echo Done $count
count=`expr $count + 1`
done
echo Inkscape done, scouring
mkdir scour
cd ./inkscape
count=1
for j in *.svg
do
scour -i $j -o ../scour/$j --create-groups --enable-id-stripping --enable-comment-stripping --shorten-ids --remove-metadata --quiet
echo Done $count
count=`expr $count + 1`
done
echo Press enter to exit
read x
Right click the saved file (through the file browser)--->properties------>permissions tab---->check the execute: Allow executing file as program---->close the properties box.
Put all the files that you want to work on in a separate folder. Copy the file that you just made executable in the same folder as the svgs and run it(by double clicking, preferrable running it in terminal as it would display when all files have been worked on.)
The script will create two subfolders in the folder where you placed the original svgs and the executable. The first folder "inkscape" includes intermediate files. These files would be the same as if they were opened in inkscape, vacuumed defs through file--->vacuum defs and saved as Plain svg rather than inkscape svg through the file---->save as option
The second folder "scour" contains the final output files. They are scoured with the options --create-groups --enable-id-stripping --enable-comment-stripping --shorten-ids --remove-metadata
I am also mostly a noob. Don't be afraid of the command line, appending --help to the name of any command simplifies it very much.
Re: SVG renderer
Hi Gaurav,
Have you seen this link: Run scour for a batch of svgs (https://answers.launchpad.net/ubuntu/+s ... ion/148801) ?
I used the following from there:
So I created a folder called "scouring" and moved a bunch of svg files there. Then I opened a terminal in that folder and ran the command above.
The --OPTIONS depends on what we want and can be omitted.
Have you seen this link: Run scour for a batch of svgs (https://answers.launchpad.net/ubuntu/+s ... ion/148801) ?
I used the following from there:
Code: Select all
find . -name "*.svg" -type f -print0 | xargs -0 -I file sh -c 'F="file"; F="${F%.svg}.opt.svg"; /PATH/TO/scour.py --OPTIONS -i "file" -o "$F"'
The --OPTIONS depends on what we want and can be omitted.