how to convert base64 to Image and save in a folder in asp.net core ? as System.Drawing is not there ?
This might work: https://github.com/JimBobSquarePants/ImageProcessor
@GuardRex thanks but its in early stages I don't know it implements the required functionality or not. If it is then how?
you don't need System.Drawing for that, I have working code on .NET Core that converts base64 images into files, see the method ConvertBase64EmbeddedImagesToFilesWithUrls here. In my SimpleContent project, images added in the wysiwyg are added as base64, and then when it posts to the server I convert that to actual files.
The only problem is without System.Drawing or other tools we don't have a good way to process the images to resize or optimize them.
@leo9223 I like what @joeaudette posted. Just picking back up for a sec tho on the status of System.Drawing
, it's not clear exactly where they are with it. There's some discussion on System.Drawing
over in CoreFX: https://github.com/dotnet/corefx/issues?utf8=%E2%9C%93&q=is%3Aissue+system.drawing
Also check this one out: https://github.com/dotnet/corefxlab/tree/master/src/System.Drawing.Graphics
@joeaudette thank you so much its working for me :) for the time being I just have to upload the picture because I am reducing and then posting.
@GuardRex alright will look into that thanks :)
I'm actually having a tough time getting your code to work, @joeaudette. I've got the base64 byte[], but the rendered output using your example just yields an image that I can't view;
public async Task<IActionResult> SaveCoverPicture([FromBody] Base64ImageString data) {
if (User.Identity.IsAuthenticated) {
var user = await Users.FindByEmailAsync(
User.Claims.GetLogin()["ProviderEmail"]);
var base64string = data.data;
var base64array = Convert.FromBase64String(base64string);
var filePath = Path.Combine($"{Environment.ContentRootPath}/wwwroot/img/user/{Guid.NewGuid()}.jpg");
System.IO.File.WriteAllBytes(filePath, base64array);
}
return new StatusCodeResult(400);
}
I am also facing same issue as mentioned above...
Is it possible to get reference of old version of System.Drawing.dll into .net core application?
Or anyone have solution for above issue?
This issue is being closed because it has not been updated in 3 months.
We apologize if this causes any inconvenience. We ask that if you are still encountering this issue, please log a new issue with updated information and we will investigate.
Most helpful comment
you don't need System.Drawing for that, I have working code on .NET Core that converts base64 images into files, see the method ConvertBase64EmbeddedImagesToFilesWithUrls here. In my SimpleContent project, images added in the wysiwyg are added as base64, and then when it posts to the server I convert that to actual files.
The only problem is without System.Drawing or other tools we don't have a good way to process the images to resize or optimize them.