Repository navigation
JPEG/WebP/... part of the executable even if all I do is save a PNG #2486
Description
Activity
Wrong native.zip above. Use this one:
Thanks for raising this. This is something I definitely want to get fixed ASAP.
Reacted by Michal Strehovskýdon't you just need to set
Configuration.Defaultdirectly with the required formats to remove the rooting of the additional formats?actually looks like thats not currently possible, but i would have to think adding a setter to
Configuration.Defaultwould allow for unrooting our default formats... actually that might not work as the lazy would still be there. I would think we would need some form of contant to switch between modes somehow.... or inversly require all, none AOT, users to manaully make a configuration/initilization call with the default formats to seed the full defaults as required, but that feels horrid.ok looks like we should be able to introduce an MSBuild 'Feature switch' to toggle on the default behaviour of
Configuration.Default... i.e. is it seeded with some initial formats or not, with the default being on.Well based on my quick read of the Customizing Trimming in .NET 5 blog post anyway.
I believe it would require adding a new
propsfile to our nuget package that included in the 'transitive build' folder, as i beleive the other one only support direct dependencies.<None Include="..\..\SixLabors.ImageSharp.props" Pack="true" PackagePath="build" /> Feature switches are last resort option - they introduce differences in behavior, require explicit opt in, and are a general pain.
From just looking at the above root graph - would a SaveAsPng overload that requires non-null configuration work?
I think looking at using overloads and not falling back to
Configuration.Defaultis the best fix. There are only a few entry points which we can easily sanitize.
Prerequisites
DEBUGandRELEASEmodeImageSharp version
3.0.1
Other ImageSharp packages and versions
?
Environment (Operating system, version and so on)
Windows 11
.NET Framework version
?
Description
As requested on Twitter: https://twitter.com/James_M_South/status/1673489691956625410
When compiling https://github.com/pjmlp/ppm2png/tree/2b77cfc103f48bbcdce0512f6182153d6d4d8644/csharp with PublishAot, the produced executable is rather large. The reason why it's large can be inspected with Sizoscope. I made this change to the above repo in an attempt to make the size smaller but it didn't help much:
I'm attaching intermediate files that can be opened with Sizoscope:
native.zip but feel free to make your own.
One immediate issue is that this app also includes support for WebP/JPEG/etc. even though I don't need it.
Sizoscope root cause analysis for
WebpEncoder..ctorpoints toConfiguration.Defaultaccessed from here:There might be more issues.
Steps to Reproduce
Clone the repo and build the project. Add switches described in the sizoscope repo if you want to inspect with sizoscope.
Images
No response