TinyPNG icon indicating copy to clipboard operation
TinyPNG copied to clipboard

Added missing background transform to TinyPNG convert call

Open manzanotti opened this issue 1 year ago • 1 comments

manzanotti avatar May 22 '24 12:05 manzanotti

This fixes #57

manzanotti avatar May 22 '24 12:05 manzanotti

Rather than serializing twice in the scenario that we have a background transform, we can just supply the value if we have it. The JSON serializer settings we're using will omit any null values.

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

Fair point, done.

manzanotti avatar May 27 '24 12:05 manzanotti

@ctolkien Any chance this could be released to NuGet?

On that note, are there any other issues you wanted resolving before releasing v4 properly? Happy to help out.

manzanotti avatar May 31 '24 08:05 manzanotti

@manzanotti - v4 has gone to NuGet. Thanks for your help in this one!

ctolkien avatar Jun 03 '24 04:06 ctolkien

https://github.com/ctolkien/TinyPNG/releases/tag/4.0.0

ctolkien avatar Jun 03 '24 04:06 ctolkien