CreateOptions and SaveOptions do not exist anymore?

Hi,

I used the code below to change the weight of images but with the latest version of imaging.dll the compilers says to me that SaveOptions and CreateOptions do not exist. What should I do ?

Regards,

MemoryStream ms = new MemoryStream();
MemoryStream msOut = new MemoryStream();
Aspose.Imaging.RasterImage image;
Aspose.Imaging.Image img = Aspose.Imaging.Image.Load(ms);
Aspose.Imaging.CreateOptions.PngCreateOptions createOptions = new Aspose.Imaging.CreateOptions.PngCreateOptions();
createOptions.Height = 150;
createOptions.Width = 150;
createOptions.Source = new Aspose.Imaging.Sources.FileCreateSource(@"C:\\temp\\" + nom, true);
Aspose.Imaging.Image outimage = Aspose.Imaging.Image.Create(createOptions);
Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(outimage);
graphics.Clear(Aspose.Imaging.Color.White);
graphics.DrawImage(img, outimage.Bounds);
msOut = new MemoryStream();
outimage.Save(msOut, new Aspose.Imaging.SaveOptions.JpegSaveOptions());

Hi Jean,

Sorry for the inconvenience faced. You are right there were some changes made in previous Aspose.Imaging API. CreatOptions and SaveOptions are obsolete now and ImageOptions namespace has replaced aforesaid namespaces. for PngOptions class, please check the Article:
https://reference.aspose.com/imaging/net/aspose.imaging.imageoptions/pngoptions/

Moreover, now image size (width and height) arguments are part of Image.Create method. Please amend you code as following. Hopefully it would serve the purpose. A page for API changes detail in documentation will be also available soon.

//Aspose.Imaging.CreateOptions.PngCreateOptions createOptions = new Aspose.Imaging.CreateOptions.PngCreateOptions();
Aspose.Imaging.ImageOptions.PngOptions createOptions = new Aspose.Imaging.ImageOptions.PngOptions();

//createOptions.Height = 150;
//createOptions.Width = 150;

//Aspose.Imaging.Image outimage = Aspose.Imaging.Image.Create(createOptions);
Aspose.Imaging.Image outimage = Aspose.Imaging.Image.Create(createOptions, 150, 150);

//outimage.Save(msOut, new Aspose.Imaging.SaveOptions.JpegSaveOptions());
outimage.Save(msOut, new Aspose.Imaging.ImageOptions.JpegOptions());

Please feel free to contact us for any further assistance.

Best Regards,

Hi,

Thank you for your quick answer, your code is working perfectly well!

Have a nice day,

Hi Jean,


It’s good to know that you have manged to get your desired results. Please feel free to ask for any further help. We will be more than happy to extend our support.

Best Regards.