Soenneker.Gen.Razor.ImageOptimizer.Webp
4.0.124
Prefix Reserved
dotnet add package Soenneker.Gen.Razor.ImageOptimizer.Webp --version 4.0.124
NuGet\Install-Package Soenneker.Gen.Razor.ImageOptimizer.Webp -Version 4.0.124
<PackageReference Include="Soenneker.Gen.Razor.ImageOptimizer.Webp" Version="4.0.124"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="Soenneker.Gen.Razor.ImageOptimizer.Webp" Version="4.0.124" />
<PackageReference Include="Soenneker.Gen.Razor.ImageOptimizer.Webp"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add Soenneker.Gen.Razor.ImageOptimizer.Webp --version 4.0.124
#r "nuget: Soenneker.Gen.Razor.ImageOptimizer.Webp, 4.0.124"
#:package Soenneker.Gen.Razor.ImageOptimizer.Webp@4.0.124
#addin nuget:?package=Soenneker.Gen.Razor.ImageOptimizer.Webp&version=4.0.124
#tool nuget:?package=Soenneker.Gen.Razor.ImageOptimizer.Webp&version=4.0.124
Soenneker.Gen.Razor.ImageOptimizer.Webp
Build-time WebP image optimization for Razor applications using the bundled libvips command-line distributions.
Quick start
Install the package in a Razor or Blazor project:
dotnet add package Soenneker.Gen.Razor.ImageOptimizer.Webp
Build the project. PNG and JPEG files beneath wwwroot produce adjacent .webp files automatically. Source images remain unchanged.
wwwroot/images/photo.jpg
wwwroot/images/photo.webp
Configuration
The defaults work without configuration. Override them in the consuming project when needed:
<PropertyGroup>
<ImageOptimizerWebpEnabled>true</ImageOptimizerWebpEnabled>
<ImageOptimizerWebpWwwRootPath>$(ProjectDir)wwwroot</ImageOptimizerWebpWwwRootPath>
<ImageOptimizerWebpSourceExtensions>png;jpg;jpeg</ImageOptimizerWebpSourceExtensions>
<ImageOptimizerWebpQuality>80</ImageOptimizerWebpQuality>
<ImageOptimizerWebpEffort>4</ImageOptimizerWebpEffort>
<ImageOptimizerWebpLossless>false</ImageOptimizerWebpLossless>
<ImageOptimizerWebpStripMetadata>true</ImageOptimizerWebpStripMetadata>
<ImageOptimizerWebpForce>false</ImageOptimizerWebpForce>
<ImageOptimizerWebpFailOnError>true</ImageOptimizerWebpFailOnError>
</PropertyGroup>
| Property | Default | Description |
|---|---|---|
ImageOptimizerWebpEnabled |
true |
Enables generation during builds. |
ImageOptimizerWebpWwwRootPath |
$(ProjectDir)wwwroot |
Directory scanned recursively for source images. |
ImageOptimizerWebpSourceExtensions |
png;jpg;jpeg |
Semicolon- or comma-separated source extensions. |
ImageOptimizerWebpQuality |
80 |
WebP quality from 1 through 100. |
ImageOptimizerWebpEffort |
4 |
Encoder effort from 0 (fastest) through 6 (slowest). |
ImageOptimizerWebpLossless |
false |
Enables lossless WebP encoding. |
ImageOptimizerWebpStripMetadata |
true |
Removes image metadata from generated output. |
ImageOptimizerWebpForce |
false |
Regenerates outputs even when they are up to date. |
ImageOptimizerWebpFailOnError |
true |
Fails the build when an image cannot be processed. |
Set ImageOptimizerWebpOutputPath to write generated files elsewhere. Relative paths are resolved from the project directory, and the directory structure beneath wwwroot is preserved.
<PropertyGroup>
<ImageOptimizerWebpOutputPath>$(ProjectDir)optimized</ImageOptimizerWebpOutputPath>
</PropertyGroup>
Build behavior
- Missing
wwwrootdirectories are skipped successfully. - Outputs at least as new as their source are skipped unless
ImageOptimizerWebpForceistrue. - Output directories are created automatically.
- A completed temporary encode replaces the final output, so an encoder failure does not destroy the previous valid asset.
- Conflicting source names are detected before an output is overwritten. Including
webpinImageOptimizerWebpSourceExtensionsis rejected to protect source files. ImageOptimizerWebpFailOnError=falsereports an image failure and continues with the remaining inputs. Requested cancellation always stops the task.- Design-time and cross-targeting builds do not run the optimizer.
- Windows x64 and Linux x64 libvips tools are bundled through
Soenneker.Libvips.Util.
If Soenneker.Gen.Razor.ImageOptimizer is also installed, remove webp from its ImageOptimizerFormats setting so only this package owns WebP output.
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.124 | 43 | 10/19/2026 |
| 4.0.123 | 46 | 10/18/2026 |
| 4.0.122 | 49 | 10/17/2026 |
| 4.0.121 | 48 | 10/16/2026 |
| 4.0.120 | 62 | 10/15/2026 |
| 4.0.119 | 43 | 10/15/2026 |
| 4.0.118 | 72 | 10/15/2026 |
| 4.0.114 | 67 | 10/14/2026 |
| 4.0.113 | 75 | 10/14/2026 |
| 4.0.112 | 71 | 10/14/2026 |
| 4.0.106 | 81 | 10/13/2026 |
| 4.0.105 | 83 | 10/13/2026 |
| 4.0.103 | 86 | 10/12/2026 |
| 4.0.102 | 96 | 10/12/2026 |
| 4.0.101 | 94 | 10/11/2026 |
| 4.0.100 | 90 | 10/10/2026 |
| 4.0.99 | 94 | 10/9/2026 |
| 4.0.98 | 85 | 10/8/2026 |
| 4.0.97 | 151 | 10/7/2026 |
| 4.0.96 | 83 | 10/6/2026 |
Update dependency Soenneker.Libvips.Util to 4.0.154 (#85)



