Free Support Forum -

Rezise don't works with jpg file

Hi, i'm using aspose imaging for .net with a valid licence.
i have this method to resize a jpg file (any size) to a standart size 270X240 pixels
The method don't report any problem, but, the size of JPG does not change.

This is the code

string sPathName = tbxFileName.Text.ToString();
using (var image = Aspose.Imaging.Image.Load(sPathName))
int newWidth = 270;
int newHeight = 240;

//image.Resize(newWidth, newHeight, Aspose.Imaging.ResizeType.LanczosResample);
image.Resize(newWidth, newHeight, Aspose.Imaging.ResizeType.NearestNeighbourResample);

I tried with several files of different sizes (JPG) without resultsI tried with several files of different sizes (JPG) without results

Thanks in advance
Luis Fabres

Hello again. Perform more tests with Resize method, and now I see some changes, but the truth is that I expected other results, since in reality the image I'm trying to adapt not shrinking, but it is cut.
Is there any method to do that images are smaller?
Thanks in advance

Hi Luis,

Thank you for using Aspose products.

I have evaluated your presented scenario while using the latest version of Aspose.Imaging for .NET 2.1.0. I am afraid, the issue didn’t replicate on my end, in fact the results are exactly as desired. I would request you to please give a try to the latest build on your side. In case your problem persists please provide us a few samples for our review.

Babar Hi, thanks for your answer..
As you say, the resize method works properly... but what I need for a development is to "preserve" the image, but reduce it in size. In other words I need to make the image smaller.
Is there any method in the library aspose I can do this?

Thanks in advance
Luis Fabres

Hi Luis,

Thank you for writing back.

I am afraid, I am not clear about your requirement. If you wish to change the dimensions of an image then Image.Resize method can do it for you. It is up to your requirement if you wish to save the re-sized canvas as a new image or overwrite the changes to the loaded image. By preserve, you meant not to overwrite the changes to original image, for that, please call the overloaded version Image.Save method that accepts parameters, such as stream object or path to new image file. In case you call the version that does not accept any parameters then the changes will be saved on the originally loaded image.

For better elaboration, I would request you to please provide a sample image as well as desired results so we could guide to further in this regard.

Hi Luis,

It is to bring in your knowledge that with the release of Aspose.Imaging for .NET 2.6.0, the API has exposed ResizeWidthProportionally and ResizeHeightProportionally methods for the Image class. These methods can be used to re-size existing images on the fly while preserving the aspect ratio. Please check the detailed article on Resize Images Proportionally, and feel free to contact us in case you face any difficulty.