|
Sweet Home 3D Forum » List all forums » » Forum: 3D problems » » » Thread: Floor have huge size in svg (tens of Mb) |
|
| Print at Jan 27, 2026, 3:45:23 PM | |
| Posted by Gildaniel at Feb 2, 2022, 9:06:09 PM |
|
Floor have huge size in svg (tens of Mb) There are floor size problem of .svg files, the bigger room - the bigger file size. Slow download of huge files, using in web. Is it possible to reduce the size somehow? Here 4 examples: 1. Only backround room, 4Mb https://woodmouse.ru/test/size1.svg 2. Only walls, 18Mb https://woodmouse.ru/test/size2.svg 3. Walls and rooms, 28Mb https://woodmouse.ru/test/size3.svg 4. Background room, walls and rooms, 49Mb https://woodmouse.ru/test/size4.svg |
| Posted by Daniels118 at Feb 3, 2022, 7:39:16 PM |
|
Re: Floor have huge size in svg (tens of Mb) Your problem is here: ![]() I've resampled the embedded image using an svg editor and now the file is just 123 KB: https://daniels118.altervista.org/temp/size1b.svg The black fill is actually a high resolution image. Where it comes from? |
| Posted by Gildaniel at Feb 11, 2022, 2:49:45 PM |
|
Re: Floor have huge size in svg (tens of Mb) > Where it comes from? Hello! This is just normal sweethome walls drawn and exported to svg. If they can be resampled, probably it's could be done within the export, not to use other tools? |
| Posted by Daniels118 at Feb 12, 2022, 1:31:11 PM |
|
Re: Floor have huge size in svg (tens of Mb) What follow is non a solution, just some considerations useful for further analysis. It seems SH3D encodes the pattern for all the walls in a single PNG image when exporting to the SVG format (the PNG is embedded into the SVG). This means even if you have just 2 small walls, the farther they are, the larger the image will be. Now this shouldn't be a great problem, because PNG supports compression and the blank space between walls is prone to give high compression ratios. The problem is the PNG image is produced without compression ![]() In fact, I have achieved small file size even without resampling the PNG, just running an optimizer. I will take a look to the code responsible for the exporting, but maybe Puybaret already know where and how to fix the issue. |
| Posted by Gildaniel at Feb 12, 2022, 2:47:34 PM |
|
Re: Floor have huge size in svg (tens of Mb) [quote I will take a look to the code responsible for the exporting, but maybe Puybaret already know where and how to fix the issue. Oh, thank you! I didn’t even think that the matter was in the walls, it always seemed to me that the larger the "garden" room, the larger the size of the picture. Usually I export first floor with garden (to show home positioning), and first floor without garden, and second picture almost two times smaller. Like here https://woodmouse.ru/3dplan/un/5.html |
| Posted by Daniels118 at Feb 12, 2022, 9:35:58 PM |
|
Re: Floor have huge size in svg (tens of Mb) Hello Gildaniel, I've built a plugin which solves the problem! You can download it from the sourceforge page. |
| Posted by Gildaniel at Feb 13, 2022, 4:12:16 PM |
|
Re: Floor have huge size in svg (tens of Mb) Ooh, Daniel, It works, so good!!! Now SVG weight is 1,5Mb instead of 49Mb before! I am so grateful to you! |
| Posted by sjb007 at Feb 14, 2022, 3:37:15 AM |
|
Re: Floor have huge size in svg (tens of Mb) Not sure why, Daniel, but it seems I'm your nemesis I have an architects floorplan as a background image in a big SH3D file I've been working on. It seems that your SVG Tuner really doesn't like that image. It just never finishes exporting after many minutes. It works in a few seconds without the plugin. If I disable the background containing layer, it works OK with your plugin, so it seems specifically linked to that background image. Last symptom is if I cancel a stalled export, then try a second export, nothing happens after selecting the file name. It would suggest something went badly wrong, and the function is no longer callable somehow. Nothing in the logs from your autologger plugin. Amazing job of pumping out these plugins by the way. |
| Posted by Daniels118 at Feb 14, 2022, 7:57:43 AM |
|
Re: Floor have huge size in svg (tens of Mb) Not sure why, Daniel, but it seems I'm your nemesis AHAHAH ![]() Please check the cpu usage using the task manager while exporting to svg. I suspect that compressing that image could be too heavy for the compression algorithm. I was expecting there might be problems, so I figured out a way to change the default settings without rebuilding the plugin. You could try to decrease the compression level by starting sh3d with a java property named png.compression,it accepts integer values in range 0-9 (the default is 9). |
| Posted by sjb007 at Feb 14, 2022, 10:19:14 AM |
|
Re: Floor have huge size in svg (tens of Mb) I used: .\SweetHome3D.exe -Dpng.compression=0Which should be no compression as I understand it. Anyway, same issue. The export never completes, the same as without the parameter, and the process cpu usage sticks at betweeen 16 and 20%. (I have a 4C/8T mobile i7.) The svg file is created, but 0 KB still after >10 minutes. I'll leave it running a while, but I think it is borked still. |
| Posted by sjb007 at Feb 14, 2022, 10:48:21 AM |
|
Re: Floor have huge size in svg (tens of Mb) Still nothing after 40 mins. I think it is safe to say that it is never going to complete. |
| Posted by sjb007 at Feb 14, 2022, 11:01:14 AM |
|
Re: Floor have huge size in svg (tens of Mb) Holy guacamole! It finished after a mere 48 mins. It produced a 6 MB file. I will try the higher levels and see if the time taken increases, and/or if the filesize changes. |
| Posted by Daniels118 at Feb 14, 2022, 11:03:56 AM |
|
Re: Floor have huge size in svg (tens of Mb) Ok,ok, 10 minutes were enough, I don't want your CPU burns :) Maybe the PNG encoding algorithm entered an infinite loop (just to be clear, this algorithm is not mine, it is part of the FreeHEP library already included in SH3D, my plugin just switches the default encoder from the one from Sun Microsystem to the one from FreeHEP). I'll try to reproduce the issue to find the bug, in the meanwhile please uninstall the plugin or don't try to export to SVG, I'm not going to refund you if your CPU melts down ![]() |
| Posted by Daniels118 at Feb 14, 2022, 11:07:09 AM |
|
Re: Floor have huge size in svg (tens of Mb) Oh, you replied while I was writing my last message. So there is no infinite loop, just a poor performance algorithm. If you can share the file that produces the problem it would be easier for me to reproduce the issue and find a workaround. |
| Posted by sjb007 at Feb 14, 2022, 1:07:45 PM |
|
Re: Floor have huge size in svg (tens of Mb) I'm not even convinced the compression is working. I tried with compression set at 0 and 1 so far and they both produced 6,052 KB files and both took approximately 48 min. I'm assuming the command I posted is what you intended. I'm just in the middle of running a level 5 test to see if that produces the same result. Once that completes I'll see if stripping the file back to just the background image still causes the long delay, and post it up for you as a stripped back example. |
| Posted by Daniels118 at Feb 14, 2022, 2:50:34 PM |
|
Re: Floor have huge size in svg (tens of Mb) I used: .\SweetHome3D.exe -Dpng.compression=0Sorry, I forgot to mention Java properties cannot be set this way when running SH3D from the exe. You have to create a configuration file named "SweetHome3D.l4j.ini" within the same directory where the exe is located (i.e. C:\Program Files\Sweet Home 3D) with the following content: -Dpng.compression=0 |
| Posted by sjb007 at Feb 14, 2022, 3:01:33 PM |
|
Re: Floor have huge size in svg (tens of Mb) Daniel, I sent you a private e-mail with the test file. |
| Posted by sjb007 at Feb 14, 2022, 6:12:38 PM |
|
Re: Floor have huge size in svg (tens of Mb) Okay, so I switched to using the ini, so I'm actually getting different behaviour. So a file created at compression=9 was ~1,015 KB, and at compression=1 the same source file created a file of 1,644 KB. Curiously compression=0 failed, truncating the file, and resulting in invalid svg. Even more curious is that all three take around 48 min, even the comp=0 failure. |
| Posted by sjb007 at Feb 14, 2022, 6:43:03 PM |
|
Re: Floor have huge size in svg (tens of Mb) One unpleasant thing I've discovered is if you use a small repeating pattern on a floor, the whole area is saved as a single large image. It does not use patterns and transforms available in the SVG spec. This is probably one of the worst offenders for bloating the svg plan export. Even the hashed fill of the walls is turned into a massive image. So for every wall type used, and every floor texture used you will have an image spanning the extents of their use, which can be 1000's of pixels in both dimensions. ![]() |
| Posted by sjb007 at Feb 14, 2022, 6:51:04 PM |
|
Re: Floor have huge size in svg (tens of Mb) Note that my last comment is not specific to the plugin. SH3D does this itself. I just thought it was very relevant to the OP's issue. |
| Posted by Daniels118 at Feb 14, 2022, 11:05:21 PM |
|
Re: Floor have huge size in svg (tens of Mb) Hi Stephen, I've released version 1.1 which is definitely faster, it can export your test file in about 1 second with 1.3 MB of size. The problem was not the compression algorithm, it was the way the PNG encoder from FreeHEP reads the pixels from the source image (a very inefficient way), so I have replaced the critical code with a most efficient one. I've aso changed the default compression level from 9 to 5, although it doesn't much difference. In regards to the repeating pattern you're right, unfortunately fixing it would require a huge work and I don't think is worth the effort. |
| Posted by sjb007 at Feb 15, 2022, 12:00:46 AM |
|
Re: Floor have huge size in svg (tens of Mb) Sweet! My CPU thanks you ![]() |
|
|
Current timezone is GMT Jan 27, 2026, 3:45:23 PM |