using (var g = Graphics.FromImage(res)).public static Image PutOnCanvas(Image image, int width, int height, Color canvasColor)./// the image remains the same size, and it is placed in the middle of the new canvas.return ImageCodecInfo.GetImageEncoders().FirstOrDefault(t => t.MimeType = mimeType).public static ImageCodecInfo GetEncoderInfo( string mimeType).img.Save(path, imageCodecInfo, encoderParams).public static void Save( string path, Image img, ImageCodecInfo imageCodecInfo).img.Save(path, jpegCodec, encoderParams).var encoderParams = new EncoderParameters(1). ![]() var jpegCodec = GetEncoderInfo( "image/jpeg" ).var qualityParam = new EncoderParameter(Encoder.Quality, 100L).public static void SaveJpeg( string path, Image img). ![]() To create an image from byte array to image format. Public static Image byteArrayToImage(byte byteArrayIn) Public static byte imageToByteArray( imageIn) Public static Image Crop(Image img, Rectangle cropArea) Resize an image and maintain aspect ratio Public static Image Resize(Image image, int newWidth, int maxHeight, bool onlyResizeIfWider) Public static Image PutOnWhiteCanvas(Image image, int width, int height) The image remains the same size, and it is placed in the middle of the new canvas Public static Image PutOnCanvas(Image image, int width, int height, Color canvasColor) Public static ImageCodecInfo GetEncoderInfo(string mimeType) Public static void Save(string path, Image img, ImageCodecInfo imageCodecInfo) Public static void SaveJpeg(string path, Image img) Note: Classes within the System.Drawing namespace are not supported for use within a Windows or ASP.NET Service. ![]() Under System.Drawing, you will have following namespaces: To allow reading and writing to the files and data streams. Basic graphics functionality is provided by the System.Drawing namespace. To provide advanced GDI+ imaging functionality. To provide advanced two-dimensional and vector graphics functionality To provide access to GDI+ basic graphics functionality Here, I had used the link given above and customized it as per my project requirement. This is basically a tool to resize the image. Create a Imager.cs class to achieve the same. Resize image proportionate Ratio and Store in JPG format.įor details, refer to the following link.In this article, you will come to know about the followings things:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |