0

Can someone explain if / how I can reduce the (seemingly huge) file size of the Cat2 SVG?

I've tried optimising CAT2 in Inkscape (simplifying (to reduce nodes), smoothing, optimising) & even using compressed SVG I can only get it to 1600kb. It doesn't seem THAT much more complicated than Cat1? Am I doing something wrong or is it simply that much more complex?

CAT1 (46kb) https://svgur.com/s/e4Y

CAT2 (2652kb) https://svgur.com/s/e5b

Maybe it is that much more complex and suited as a PNG. Would appreciate insight and advice! Thanks.

EDIT: Have realised CAT2 is not a 'proper' vector image. This is probable cause.

The SVG text contains: "<image width="198.29097" height="139.4967" preserveAspectRatio="none" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANS ..........

I don't think 'trace bitmap' (I copied the line drawing from GIMP to Inkscape then ran 'trace bitmap') has worked/works in the way I thought it did. The person who drew CAT2 couldn't provide vector files. I'm trying to convert his drawings to vector images (using GIMP and Inkscape). The first cat image was from someone else and a true vector image (drawn in Illustrator).

5
  • Delete the inkscape specific syntax. Yes inkscape files are svg but not svg you want to put on the web.
    – joojaa
    Feb 8, 2022 at 13:40
  • 2
    I think it's because it's not a suitable vector image. Looking a bit closer have realised the edges are blurred and pixelated. The SVG text contains: "<image width="198.29097" height="139.4967" preserveAspectRatio="none" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANS e Feb 8, 2022 at 14:11
  • I don't think 'trace bitmap' (I copied the line drawing from GIMP to Inkscape then ran 'trace bitmap') has worked/works in the way I thought it did. The person who drew CAT2 couldn't provide vector files. I'm trying to convert his drawings to vector images (using GIMP and Inkscape). The first cat image was from someone else and a true vector image (drawn in Illustrator). Feb 8, 2022 at 14:15
  • All you really need to do is tell inkscape to export a svg not save it. Otherwise incscape holds on to all editability of the document.
    – joojaa
    Feb 9, 2022 at 6:55
  • @joojaa - in Inkscape "Save as" is used to create an optimised SVG (without the Inkcape XML). Export is only for bitmap images.
    – Billy Kerr
    Feb 9, 2022 at 12:20

2 Answers 2

3

You have the original image still embedded in the SVG. The '<image>'-tag you've pointed out is basically the whole large PNG file encoded in Base64, which makes it even bigger. Tracing an image doesn't delete it, just puts the vectorized version on top of it. So manually remove the reference image before saving.

As for the tracing, don't use multiple scans, which makes many paths for the different gray-levels. What you want to use is 'Single scan' with 'Brightness cutoff'.

1

@Xrott has provided the correct answer here. After examining the SVG, I see the exact same problems. This is really an operator issue, nothing to do with the quality of the original, or Inkscape.

Anyway, I thought I'd illustrate the steps from start to finish, including the final step of optimising the SVG file, so you can get your desired result - a small file size.

To trace a simple line drawing in Inkscape use these settings

enter image description hereClick to see larger

Once you have clicked Apply, you then need to delete the raster image which will now be under the Trace. If you don't, then that will hugely increase the file size.

In the Objects Panel (enable by clicking Object > Objects), select the image and delete it.

enter image description here

To save your SVG without all the Inkscape XML, Do File > Save As, give your file a new name. In the file type dropdown choose "Optimised SVG".

Set the Optimised SVG Output options as shown below, and hit OK. This will remove all the Inkscape-specific XML and will also help keep the file size smaller. The finished file size will be approx 48kb

enter image description hereClick to see larger

Note: You could also get the file size even smaller if you Simplify the path - in Preferences > Behaviour, set the Simplification Threshold to 0.0002. Then select the traced object and do Paths > Simplify. When I tried this I was able to get the optimised SVG down to about 16kb

4
  • Thanks for this. I've followed your steps and can get it to 144KB. Do I need to repeat the steps / were there other steps to get it to 48kb? Feb 14, 2022 at 12:05
  • Ah. OK. I think I see. So in the objects panel there were 8 separate paths, each adding a bit more detail to the trace. I removed all of them except one. When I saved that, it's come to 15KB but it's lost a lot of the smaller details. Feb 14, 2022 at 12:10
  • @user8731804 - nope no other steps. You have many separate paths because you didn't do a Single Scan trace. Don't use a multiple scan for line art like this. Delete everything except the raster image, and do the scan again with the settings shown in this answer, and of course don't forget to delete the raster image.
    – Billy Kerr
    Feb 14, 2022 at 12:33
  • @user8731804 also note, if you don't do the final simplify step, then most details should remain, although there will be more nodes, and a higher file size. However note also that an auto trace can never be perfect. There will always be some degradation in quality. If this is unacceptable, then you could recreate the drawing manually using the Pen Tool.
    – Billy Kerr
    Feb 14, 2022 at 12:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.