Created
April 23, 2025 18:46
-
-
Save conholdate-gists/72882d13dd231d82157e86ff0451517e to your computer and use it in GitHub Desktop.
Resize Image in C# | Scale JPG PNG GIF BMP Picture
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load image | |
using (Image image = Image.Load("aspose-logo.png")) | |
{ | |
// Cache image data | |
if (!image.IsCached) | |
{ | |
image.CacheData(); | |
} | |
// Specify width and height | |
int newWidth = image.Width / 2; | |
image.ResizeWidthProportionally(newWidth); | |
int newHeight = image.Height / 2; | |
image.ResizeHeightProportionally(newHeight); | |
// Save image | |
image.Save("ResizeImageProportionally_out.png"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load image | |
using (Image image = Image.Load("aspose-logo.jpg")) | |
{ | |
// Resize image and save the resized image | |
image.Resize(300, 300); | |
image.Save("SimpleResizing_out.jpg"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load image | |
using (Image image = Image.Load("image.svg")) | |
{ | |
// Resize image as PNG | |
image.Resize(image.Width * 10,image.Height * 15); | |
image.Save("Logotype_10_15.png", new PngOptions() | |
{ | |
VectorRasterizationOptions = new SvgRasterizationOptions() | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment