public void Unsharpmask(object b22) { KalikoImage image = new KalikoImage("C:\\Users\\Dima\\Pictures\\1.jpg"); // Create a thumbnail of 128x128 pixels KalikoImage thumb = image.GetThumbnailImage(128, 128, ThumbnailMethod.Crop); // Apply unsharpen filter (radius = 1.4, amount = 32%, threshold = 0) thumb.ApplyFilter(new UnsharpMaskFilter(1.4f, 0.32f, 0)); // Save the thumbnail as JPG in quality 99 (very high) thumb.SaveJpg("C:\\Users\\Dima\\Pictures\\1111.jpg", 99); }
public static bool GenerateAvatar(Image inputImage, string userName, string mimetype) { try { string DestinationPath = HttpContext.Current.Server.MapPath("~/Storage/Avatars"); var originalImage = new KalikoImage(inputImage); originalImage.GetThumbnailImage(MaxWidth, MaxHeight, ThumbnailMethod.Pad).SaveJpg(DestinationPath + '\\' + userName + ".jpg", 90); return(true); } catch (Exception ex) { return(false); } }
// generate a thumbnail while removing transparency and preserving aspect ratio public static string GenerateThumbFromUrl(string sourceUrl) { var randomFileName = GenerateRandomFilename(); var request = WebRequest.Create(sourceUrl); request.Timeout = 300; var response = request.GetResponse(); var originalImage = new KalikoImage(response.GetResponseStream()) { BackgroundColor = Color.Black }; originalImage.GetThumbnailImage(MaxWidth, MaxHeight, ThumbnailMethod.Pad).SaveJpg(DestinationPath + '\\' + randomFileName + ".jpg", 90); return(randomFileName + ".jpg"); }