Skip to content

Commit

Permalink
Add easy recompression to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
georg-jung committed Aug 9, 2021
1 parent bf2f023 commit 2e2290e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,21 @@ This project provides multiple NuGet packages:

## Usage

Example usage for `MozJpegSharp.GdiPlus`:
Recompression using just `MozJpegSharp`:

```csharp
var inFile = "in.jpg";
var outFile = "out.jpg";
var inBytes = await File.ReadAllBytesAsync(inFile);
var compressed = MozJpeg.Recompress(inBytes.AsSpan(), quality: 80);
await File.WriteAllBytesAsync(outFile, compressed);
```

Example usage for `MozJpegSharp.GdiPlus`:

```csharp
var inFile = "in.jpg"; // does not need to be jpg
var outFile = "out.jpg";
using var bmp = new Bitmap(file);
using var tjc = new MozJpegSharp.TJCompressor();
var compressed = tjc.Compress(bmp, MozJpegSharp.TJSubsamplingOption.Chrominance420, 75, MozJpegSharp.TJFlags.None);
Expand Down

0 comments on commit 2e2290e

Please sign in to comment.