We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Obtain the same treatment than in photoshop

Hi,


Actually, When my user have a big image in my app, I say us to use photoshop, load the image and save it in “for the web”.
This traitment reduct the size of the image (I don’t know how)

How I can do that with your component ?

Thanks
Sylo

Hi Sylo,

Thank you for considering Aspose products, and welcome to Aspose.Imaging support forum.

The Photoshop’s “Save for Web” tool provide means to prepare JPEG files for the web, helping with the trade-off between file size and image quality. You can achieve the same with Aspose.Imaging for .NET API while using the below provided code snippet.

C#


//Load an image
using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Load(myDir + “sample.bmp”))
{
//Create an instance of JpegOptions for saving the resultant image
var JpgCreateOptions = new Aspose.Imaging.ImageOptions.JpegOptions();
//Set the quality to desired value
JpgCreateOptions.Quality = 70;
//Set the Source property of JpegOptions
JpgCreateOptions.Source = new FileCreateSource(string.Format("{0}\result.jpeg", myDir), false);
//Create a new JpegImage while passing the instance of JpegOptions, and mentioning the resultant image size
using (var JpgImage = (Aspose.Imaging.FileFormats.Jpeg.JpegImage)Aspose.Imaging.Image.Create(JpgCreateOptions, image.Width, image.Height))
{
//Save the input image pixels in resultant image boundaries
JpgImage.SavePixels(JpgImage.Bounds, image.LoadPixels(image.Bounds));
//Save the result
JpgImage.Save();
}
}

Please download the latest version of Aspose.Imaging for .NET 2.2.0, and give it a try at your end. In case you have face any difficulty or have more questions, please feel free to write back any time.

Hi Sylo,

Sorry I forgot to mention in my previous response that you will not be able to use the above code snippet in evaluation mode, that is without setting a valid license. This is because Aspose.Imaging APIs restrict the usage of core functionality such as Image.LoadPixel and Image.SavePixel methods in evaluation mode. Please check the evaluation restrictions from below linked technical article.
http://www.aspose.com/docs/display/imagingnet/Evaluation+Version+Limitations

I would suggest you to get a 30 days temporary license in order to test the product without any limitations. Once you have received your license, you have to add the below provided statements at the start of your application to set the license.

C#


Aspose.Imaging.License imagingLicense = new Aspose.Imaging.License();
imagingLicense.SetLicense(“Aspose.Total.lic”);

Please note, you have to pass the License file path location to the SetLicense method, whereas you may receive the license file with any name depending upon the selection of APIs you make during the order placement.

Please feel free to write back in case you face any difficulty or have questions for us.