
Any HTTP errors are converted into exceptions, which are thrown by the client library. And for error handling, the Tinify API uses HTTP status codes to indicate success or failure. Tinify API also helps in preserving the metadata of the image like copyright information, the GPS location and the creation date. Which parts of the image are cropped away is determined automatically. You must provide both a width and a height.


Scale: Scales the image down proportionally.Fit: Scales the image down proportionally so that it fits within the given dimensions.The resizing method describes the way your image will be resized. To resize an image, call the resize method on an image source and supply width, height and resizing method. The compression ratio can be up to 70%, but that depends on the image. The below image shows the size difference between both the images. String sFilePath = sOptimizedFile = source = Tinify.FromFile(sFilePath) Tinify.Key = API_KEY //TinyPNG Developer API KEY Just, provide the source image path to Tinify API and destination path. With two lines of code, image compression can be achieved. Using it for compression or resizing is very simple. To use with ASP.NET Core, first install the Tinify nuget package. You can find your API key on the TinyPNG developer dashboard. Provide your name and email address to get access of developer dashboard. You can get the pricing details from here. You can use different TinyPNG account after 500 images and continue with your compression free of charge or you can also opt for a paid subscription. It compresses first 500 images for free every month. The Tinify API allows you to compress and optimize JPEG and PNG images. The effect is nearly invisible but it makes a very large difference in file size!

TinyPNG uses an algorithm to reduce the number of colors in a way that’s unnoticeable to the naked eye.īy selectively decreasing the number of colors in the image, fewer bytes are required to store the data.

TinyPNG uses smart lossy compression techniques to reduce the file size of your PNG files. In this post, let’s find out how to compress and resize/scale images in ASP.NET Core using TinyPNG API.Ĭompress and Resize/Scale Images in ASP.NET Core Along with web interface, they also expose REST API (Free/Paid) to compress images on the fly. In fact, we always use TinyPNG to compress images, created for this blog. TinyPNG is a great place to compress JPEG or PNG images. Large size images are slow to load and optimizing them can reduce bandwidth and help your website load faster.
