In this article, We will learn the Tinyfy API to compress the image from the Local path as well as from the URL in C#.
Follow the below steps to get your API key :
Note:
Now we have the API key. Follow the below steps to compress your images :
public static async System.Threading.Tasks.Task Main(string[] args) { try { Tinify.Key = "abcdefghijklmnopqrstuvwxyz"; // ------- Change your Tinyfy key here await Tinify.Validate(); var destinationDirectory = @"D:/Images/Compressed/"; if (!Directory.Exists(destinationDirectory)) { Directory.CreateDirectory(destinationDirectory); } var fromImagePath = @"D:/Images/Data/Ghanshyam.jpg"; string fileName = Path.GetFileName(fromImagePath); Tinify.FromFile(fromImagePath).ToFile(destinationDirectory + fileName).Wait(); } catch (System.Exception ex) { Console.WriteLine(ex.Message.ToString()); } }
public static async System.Threading.Tasks.Task Main(string[] args) { try { Tinify.Key = "abcdefghijklmnopqrstuvwxyz"; // ------- Change your Tinyfy key here await Tinify.Validate(); var destinationDirectory = @"D:/Images/Compressed/"; if (!Directory.Exists(destinationDirectory)) { Directory.CreateDirectory(destinationDirectory); } var imgUrl = @"http://staging.thecodehubs.com/wp-content/uploads/2020/07/ghanshyam-godhani.jpeg"; string fileName = Path.GetFileName(imgUrl); Tinify.FromUrl(imgUrl).ToFile(destinationDirectory + fileName).Wait(); } catch (System.Exception ex) { Console.WriteLine(ex.Message.ToString()); } }
In this article, we have to show Create and Used PIPE in angular
In this article, we have to show Create and Used PIPE in angular
In this article, we have to show Create and Used PIPE in angular