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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Soenneker.Gen.Razor.ImageOptimizer.Webp" Version="4.0.124">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Gen.Razor.ImageOptimizer.Webp" Version="4.0.124" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Gen.Razor.ImageOptimizer.Webp">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.Gen.Razor.ImageOptimizer.Webp --version 4.0.124
                    
#r "nuget: Soenneker.Gen.Razor.ImageOptimizer.Webp, 4.0.124"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Soenneker.Gen.Razor.ImageOptimizer.Webp@4.0.124
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.Gen.Razor.ImageOptimizer.Webp&version=4.0.124
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Gen.Razor.ImageOptimizer.Webp&version=4.0.124
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

alternate text is missing from this package README image 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 wwwroot directories are skipped successfully.
  • Outputs at least as new as their source are skipped unless ImageOptimizerWebpForce is true.
  • 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 webp in ImageOptimizerWebpSourceExtensions is rejected to protect source files.
  • ImageOptimizerWebpFailOnError=false reports 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.

There are no supported framework assets in this package.

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
Loading failed

Update dependency Soenneker.Libvips.Util to 4.0.154 (#85)