Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.Net Core Image Manipulation (Crop & Resize) / File Handling

Tags:

I have spent the last 5 hours trying to find a feasible way to accomplish what seems to me quite an easy task if it was a previous version of the .NET family that I was working with:

  1. Uploading a picture
  2. Resizing & Cropping the picture
  3. Saving the new picture into a directory

I have come accross to couple of libraries that are either in pre-release stage or in a not-complete stage.

Has anyone at all accomplished the above tasks without specifically including the System.Drawing namespace and/or adding a dependency for an earlier version of the .NET framework?

UPDATE on 08 / 08 / 2016

I ended up using System.Drawing something which is very annoying and disappointing. If you are developing a software used by thousands of developers, and if all these developers are relying on the components of this software, I believe, one cannot just come up with a new version, "sweet talk" about it during the conferences to show off your public speaking skills rather than giving a shit about your work and on one hand proudly hold in high esteem of it, and on the other, strip away the mostly used and demanded portions of it.

I do understand and appreciate with great excitement myself - of the new era of .net with the core framework - being a loyal asp dev since the first days of classic asp - however, to me, it is just an uncomplete product causing more frustrations and dissappointment than pleasure. When there are millions of websites in today's content-driven world, completely relying on content management, you can't just come up and say, "Hey, I have this brilliant, techonology, leaner, faster blah blah" but errr, you will have some problems with "managing" your content..

It should not be forgotten that, although, MS (and us) is very excited about this new core framework, with now being open source etc, there are other languages and frameworks out there that are doing what MS is promising to do, for a very very long time now.

like image 885
Subliminal Hash Avatar asked Aug 07 '16 17:08

Subliminal Hash


Video Answer


2 Answers

ImageSharp ImageSharp

ImageSharp is a new, fully featured, fully managed, cross-platform, 2D graphics API.

Designed to democratize image processing, ImageSharp brings you an incredibly powerful yet beautifully simple API.

Compared to System.Drawing we have been able to develop something much more flexible, easier to code against, and much, much less prone to memory leaks. Gone are system-wide process-locks; ImageSharp images are thread-safe and fully supported in web environments.

Built against .Net Standard 1.1 ImageSharp can be used in device, cloud, and embedded/IoT scenarios.

like image 124
Soren Avatar answered Oct 15 '22 18:10

Soren


You can use the Microsoft ASP.NET Core JavaScript Services to invoke arbitrary NPM packages at runtime from .NET code which means you can choose any npm package that provide image scaling and invoke it.

The following example shows how to use JavaScriptServices to resize image https://github.com/aspnet/JavaScriptServices/tree/dev/samples/misc/NodeServicesExamples

Hope that Helps

like image 34
Hossam Barakat Avatar answered Oct 15 '22 18:10

Hossam Barakat