Author Topic: Ho to make an SVG file smaller  (Read 10404 times)

June 12, 2018, 03:14:28 AM
Read 10404 times

garystevens834

  • Jr. Member

  • Offline
  • ***

  • 18
  • Gender
    Male

    Male
  • Personal Text
    I a newbie to Inkscape
I have a lot of SVG files that are pretty large in size(150kb)and I need to make them smaller than 15kb. Using Inkscape what ways are there to make the smaller?

Gary
« Last Edit: June 13, 2018, 10:31:51 PM by garystevens834, Reason: wasn\'t worded right. »
  • 0.92
  • OS X EL CAPITAN

June 12, 2018, 04:37:15 AM
Reply #1

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
Hi again Gary.

For the 2 files which you've showed me, there's probably no way to make them smaller.  Usually files that you find on the internet have already been made as small as possible.  In some cases, possibly some contents can be removed or replaced to make them smaller.  But I'd say that generally, you won't be able to make them smaller.

However, it certainly can't hurt to look at them anyway.  There is something called "optimization" for SVG files.  So it's possible that saving them as Optimized SVG would make them smaller.  I don't know if the website where you want to upload them would accept them.  But it can't hurt to try. 

But anyway, they would have to be considered on a case by case basis.  Can you share a couple of different files for us to test with?  You can just attach them to your next reply.

Besides optimization,  if the image has filters in it, for example, that could be swapped out with a flat fill, and make it smaller.  Although that will change the appearance of the image.  Or maybe if the image has something in it which you don't want, you could just delete it.

If it was an image you made yourself, you could use File menu > Clean Up Document, and possibly make it smaller.  But that has probably already been done for images you find on the internet.

Anyway, if you could share a couple of examples, we can get a better idea what might be possible.

(I'm going to move this to a different board, but don't worry,  you'll see the link to follow.)
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann                       

June 12, 2018, 12:55:30 PM
Reply #2

Lazur

  • IC Mentor

  • Offline
  • ******
  • Inkscape Filters Wizard

  • 1,154
  • Gender
    Male

    Male
Hi.

There are quite alot of tricks one can pull off the hat.
First there is a way to reproduce the image's look with a (possibly completely) different structure.
Second, you may shrink the file by tinkering with the codes straight -this may result in performance issues in some cases, but it can make the file smaller big time.
Like, for a straight output you don't need any inkscape related data like guides, hence save as plain svg.
Next, you can set the number of spaces used to a smaller value as far as I know,
then, you can set the number of digits used.
The latter can damage the file beyond repair upon further editing, but it may be good to go for cnc etc.


There were 2 optimizing file challenges at the other forum you may be interestd in:
challenge #1
challenge #2

June 13, 2018, 10:37:04 PM
Reply #3

garystevens834

  • Jr. Member

  • Offline
  • ***

  • 18
  • Gender
    Male

    Male
  • Personal Text
    I a newbie to Inkscape
In am new to the Inkscape so as of now the only thing I done is to import a file. I have some SVG file that are large in size (150kb) and I need to get them smaller than 15kb. What things can I do to make there's changes? Any help you can give would be great since I'm new to this program and thanks for spending the time to respond to my question.

garystevens64
  • 0.92
  • OS X EL CAPITAN

June 13, 2018, 11:32:37 PM
Reply #4

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
There's not much more I can say, that I didn't already say.

As Lazur suggested, you could probably re-save each file as Plain SVG, and reduce the size by a small amount.  I'm still not sure what Optimized SVG is, but I'd be glad to try it, if you could provide a couple of test files.

Other than that, the only way to reduce the file size, is to draw the image with different type of objects or features.  Like for example, if an image uses a lot of filters (filters typically provide fancy, 3d-like effects) they could be replace with regular solid fills, and cut the file size that way.  Of course, that will change the appearance of the image.   Or if there are imported raster images in the file, or other hidden contents, those could be removed.

But for the other files that I've seen, there's absolutely nothing in them that can be changed.  Typically when artists provide these files, they've already made the files as small as possible.  I suppose it's possible you might find one here and there with a lot of excess data, but I don't think it would be very common.

This is the best I can do, to come up with some kind of "process".

 -- open the file
 -- File menu > Clean Up Document
 -- Watch the status bar as you click that, so you can see how much data was removed.  Most of the time I expect it will say "removed 1 def" (which would probably remove less than 1 kb).
 -- Save as Plain SVG (might remove 10 to 15 kb, I'm guessing)

As for recreating the image with different elements, we'd have to look at the files.  Or you could learn more about using Inkscape, and be able to do it yourself.

Oh wow!  I tried Optimized SVG.  There's actually a dialog where you can pick and choose which data you want to keep or not.  I managed to take a 96 kb file down to 21 kb !!  I don't see any major changes in the appearance of the image.  I'll make some screenshots of the settings I used in the dialog.  Be right back.
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann                       

June 13, 2018, 11:46:48 PM
Reply #5

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
Ok, as far as I understand the settings, these are what I would use.  Maybe some others might help too, but some of them I don't understand clearly.

First, File menu > Save As > Optimized SVG
Then a dialog will open which has 3 tabs.  (sorry about my weird theme color)

Options tab:
o1.png
*o1.png
(15.12 kB . 462x493)
(viewed 8110 times)


SVG Output tab:
o2.png
*o2.png
(16.97 kB . 458x493)
(viewed 8104 times)


IDs tab:
o3.png
*o3.png
(13.25 kB . 456x490)
(viewed 8135 times)


On the Options tab, you might be able to get away with reducing the first option (number of significant digits) to 4 or maybe even 3, without messing up the image.  I don't think it would reduce the file size by a significant amount, but who knows.  You can test it to find out.

Hopefully none of these data which will be removed, will be required by the site where you're uploading the images.  At least the instructions you showed me didn't mention these data.
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann                       

June 14, 2018, 01:20:17 PM
Reply #6

Lazur

  • IC Mentor

  • Offline
  • ******
  • Inkscape Filters Wizard

  • 1,154
  • Gender
    Male

    Male
Never used that option myself but that seems to cover the second way I mentioned.
Number of digits is how your coordinates are stored. On screen you can't really render half pixels, so the amount should be safe by the largest height/width/page size of your document in px's decimals +1 I guess.
This can make significant shrinking but be precautious -working with lowered number of digits can produce some "glitches" upon further editing.

Depth of indentation can reduce a smaller amount. As far as I know the default is 3, resulting in a minimum of 2 characters/object in the svg tree, depending on how much grouping it contains.

Removing the xml declaration might not be a good idea, some renderers may not render the file.

June 15, 2018, 03:43:19 PM
Reply #7

Moini

  • IC Mentor

  • Offline
  • ******

  • 1,568
    • VektorRascheln
Indentation can be removed completely, it doesn't serve any other purpose than making the file human-readable. If you don't intend to manually edit the file (i.e. in a text editor), there's no reason to keep any indentation.

June 16, 2018, 05:57:07 PM
Reply #8

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
Hah, I was curious about that indentation option, which is why I didn't touch it.  If removing indentation can remove more data, that must mean the blank spaces actually add kb's or at least bytes to the file size.  How confusing is that!
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann                       

June 17, 2018, 05:31:32 AM
Reply #9

Moini

  • IC Mentor

  • Offline
  • ******

  • 1,568
    • VektorRascheln
Of course they do add data - there's info in the fact that things are moved a couple of places to the right.

June 17, 2018, 12:00:12 PM
Reply #10

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
I never would have guessed that in a million years!
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann                       

June 21, 2018, 09:51:28 PM
Reply #11

garystevens834

  • Jr. Member

  • Offline
  • ***

  • 18
  • Gender
    Male

    Male
  • Personal Text
    I a newbie to Inkscape
I copied this information from the "Uploading Decals Guide" on uploading SVG files. I've also attached a sample SVG file that I'm trying to make smaller and then upload.  Any help that you can give me I appreciate.

1. Only SVG image files can be uploaded and used for this feature.
2. Prepare the file beforehand using appropriate image editing software.
3. Also, SVG files larger than 15 kb can not be uploaded.

Important Points Regarding SVG files.

・The file size can not exceed 15 kb
・Lettering will be converted to outlines
・Ensure special blending modes such as addition and multiplication have not been used
・Ensure that bitmaps have not been embedded
  • 0.92
  • OS X EL CAPITAN

June 21, 2018, 11:50:30 PM
Reply #12

Lazur

  • IC Mentor

  • Offline
  • ******
  • Inkscape Filters Wizard

  • 1,154
  • Gender
    Male

    Male
Looking at your file the largest portion of the data seems to come from that oddly drawn black outline around the lettering.
There are way too many unnecessary nodes in that.

Attaching an svg with a quick redrawing of the top part.

Contrary the file is larger due to my svg settings are of maxed out decimals for precision.

June 22, 2018, 12:27:49 AM
Reply #13

garystevens834

  • Jr. Member

  • Offline
  • ***

  • 18
  • Gender
    Male

    Male
  • Personal Text
    I a newbie to Inkscape
I'm trying to remove all of the unnecessary nodes from all parts of the logo. This should change the file size right? And where do I go to see what the file size is? I can't seem to be able to find it.  I thank you so much for all of you help with this and I'm sorry if some of these questions sound a bit nuts but remember I'm new to this software. And I waiting for some "Inkscape Beginners Guide Books I bought from Packt Publishing.
  • 0.92
  • OS X EL CAPITAN

June 22, 2018, 11:43:47 AM
Reply #14

Moini

  • IC Mentor

  • Offline
  • ******

  • 1,568
    • VektorRascheln
Your file manager should be able to display file sizes. Or you can use the command line on macOS, too, to output the size of a file.

June 22, 2018, 01:21:28 PM
Reply #15

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
Path menu > Simplify will reduce the number of nodes.  If you do it only once, it will not distort the image too much.  But if you do it twice, it likely will distort the image too much.  Also, don't do it to all the paths at once.  It works better to do it to one path at a time.

If one click distorts the path too much, you can reduce the Simplification Threshold, so it does not remove as many nodes per click.  Inkscape Preferences > Behavior

I have to say, I'm really rather shocked that someone would upload this file to the internet, without cleaning up the ridiculous number of nodes in the text!  They must not be coming from graphics professionals.  Or maybe someone using a less sophisticated vector tool?

On a side note, you do realize that this image, and the other 2 you showed me are copyrighted, and licensed logos, which you might not have permission to use or edit.  I actually don't know how these decal companies get away with selling them.  So I'm probably going to bow out of this issue, just to be safe.  I've said everything I can say anyway.
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann