https://github.com/nagilum/tinify
C# wrapper for the Tinify (TinyPNG) API.
https://github.com/nagilum/tinify
Last synced: 3 months ago
JSON representation
C# wrapper for the Tinify (TinyPNG) API.
- Host: GitHub
- URL: https://github.com/nagilum/tinify
- Owner: nagilum
- Created: 2015-11-27T13:47:53.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-12-03T13:01:32.000Z (over 9 years ago)
- Last Synced: 2025-01-16T13:46:54.887Z (4 months ago)
- Language: C#
- Size: 4.88 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Tinify
C# wrapper for the Tinify (TinyPNG) API.
The Tinify API allows you to compress and optimize JPEG and PNG images.
**Usage**
```csharp
// Init a new instance of the class.
var tinify = new Tinify("--your-api-key-from-tiny-png--");// Upload and shrink an image.
var resp = tinify.Shrink(Server.MapPath("~/wallhaven-88501.jpg"));
```If you specify a second file in the `Shrink` function, it will automatically download the shrinked file.
You can also pass along credentials and info to tell tiny-png to upload the shrinked file directly to Amazon S3.The response object you get back from the wrapper can be used to scale, fit, or adjust the image before downloading it again.
```csharp
// Create a cover with the uploaded image.
tinify.Cover(resp, 200, 200, Server.MapPath("~/wallhaven-88501-tinify-cover-200x200.jpg"));// Create a thumbnail with the uploaded image.
tinify.Fit(resp, 200, 200, Server.MapPath("~/wallhaven-88501-tinify-fit-200x200.jpg"));// Scale the uploaded image.
tinify.Scale(resp, 0, 200, Server.MapPath("~/wallhaven-88501-tinify-scale-200x200.jpg"));
```The HTTP status code and description from the last request can be found in the `tinify.LastHttpStatusCode` and `tinify.LastHttpStatusDescription` respectivly.