Skip to content

Commit

Permalink
Added missing background transform to TinyPNG convert call
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Manzotti committed May 22, 2024
1 parent 7474a06 commit 93c7cc4
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/TinyPNG/Extensions/ConvertExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,21 @@ public static async Task<TinyPngConvertResponse> Convert(this Task<TinyPngCompre

string requestBody = JsonSerializer.Serialize(new { convert = new { type = convertOperation } }, TinyPngClient._jsonOptions);

if(!string.IsNullOrEmpty(backgroundTransform))
{
requestBody = JsonSerializer.Serialize(new
{
convert = new
{
type = convertOperation
},
transform = new
{
background = backgroundTransform
}
}, TinyPngClient._jsonOptions);
}

HttpRequestMessage msg = new(HttpMethod.Post, compressResponse.Output.Url)
{
Content = new StringContent(requestBody, Encoding.UTF8, "application/json")
Expand Down

0 comments on commit 93c7cc4

Please sign in to comment.