0

enter image description here

enter image description here

enter image description here

I try to resize an image but I want to do it in another class library.

When I send this, I get an error which I showed in the screenshots.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

0

The root cause is read/write permission.

using(var stream= new FileStream(filepath,FileModel.Create)){
    await item.CopyToAsync(stream);
    // open the orginal image
    Image img = Image.FromStream(stream);
    // error occurs here, we need to copy and paste it into a new object 
    // var img2 = new Bitmap(img);
    // img2.Save(i2newPath, ImageFormat.Jpeg);
    Image newImage = ImageConverterHelper,JPEGConverter(img,filePath) 
    ...
}

For more details, you can check the related issue.

by copying the image internally into a Bitmap instance and saving this image instead of the original image, the error disappeared.

Jason Pan
  • 15,263
  • 1
  • 14
  • 29