RazrFalcon / resvg

An SVG rendering library.
Mozilla Public License 2.0
2.74k stars 220 forks source link

Allow enabling GIF, JPEG, and PNG independently #738

Closed IvanUkhov closed 5 months ago

IvanUkhov commented 5 months ago

It is good to keep the dependencies to a minimum, and in this PR, raster-images is split into three: gif, jpeg, and png.

RazrFalcon commented 5 months ago

I think this is too extreme. More over, PNG support cannot be optional. This is kinda a bug to begin with.

I can accept GIF being optional. Maybe JPEG. But that's it.

IvanUkhov commented 5 months ago

Could you please explain why PNG cannot be optional? raster-images implies that encoding is not always necessary and can be disabled. But then it does not fully disable it due to the default features of tiny-skia. Moreover, I am actually coming with a use case. In my case, I do not need encoding but only the RGBA buffer of the produced PixelMap. So it is unfortunate to see PNG being pulled in. Perhaps there are more like me.

RazrFalcon commented 5 months ago

The png crate is like 3% of the final binary. It doesn't matter.

Also, text flattening requires PNG support for emojis. So no, PNG is here to stay.

raster-images implies that encoding is not always necessary

raster-images affects only decoding of images inside the image element.

Here is a cargo bloat output per crate:

12.1%  21.0% 362.0KiB std
11.3%  19.5% 337.5KiB usvg
 7.4%  12.7% 220.0KiB rustybuzz
 5.4%   9.4% 161.6KiB tiny_skia
 4.9%   8.4% 145.1KiB resvg
 3.1%   5.3%  92.3KiB ttf_parser
 1.9%   3.3%  57.4KiB jpeg_decoder
 1.6%   2.9%  49.2KiB svgtypes
 1.4%   2.5%  43.2KiB roxmltree
 1.3%   2.3%  40.2KiB tiny_skia_path
 1.3%   2.2%  38.6KiB png
 1.0%   1.7%  28.7KiB simplecss
 0.9%   1.6%  27.3KiB miniz_oxide
 0.8%   1.3%  22.6KiB fontdb
 0.6%   1.0%  17.2KiB fdeflate
 0.6%   1.0%  17.0KiB [Unknown]
 0.5%   0.9%  15.7KiB imagesize
 0.4%   0.7%  12.2KiB data_url
 0.4%   0.7%  11.8KiB weezl
 0.3%   0.5%   9.0KiB pico_args
 0.3%   0.5%   8.6KiB gif
 0.3%   0.5%   8.6KiB unicode_bidi
 0.2%   0.3%   4.9KiB kurbo
 0.2%   0.3%   4.5KiB unicode_ccc
 0.1%   0.2%   4.1KiB flate2
 0.1%   0.1%   1.9KiB unicode_vo
 0.0%   0.1%   1.2KiB crc32fast
 0.0%   0.0%     440B memmap2
 0.0%   0.0%     440B smallvec
 0.0%   0.0%     380B slotmap
 0.0%   0.0%     336B simd_adler32
 0.0%   0.0%     336B log
 0.0%   0.0%     128B bytemuck
 0.0%   0.0%     128B unicode_bidi_mirroring
 0.0%   0.0%     100B unicode_script
 0.0%   0.0%      96B unicode_properties
 0.0%   0.0%      28B arrayvec

As you can see, raster images support is the least of your concerns.

IvanUkhov commented 5 months ago

It is not so much about the size for me. It is more about not having to have the dependencies I do not need. This is a crate about SVG, not PNG, after all. But I understand. Thank you for explaining.