AspNetCoreImageResizingService
AspNetCoreImageResizingService copied to clipboard
ASP.NET Core sample image resizing service
ASP.NET Core Sample Image Resizing Service
This is a demo web application for the “ASP.NET Core Sample Image Resizing Service” post on the Dmitry Sikorsky’s blog. It demonstrates how to build image resizing service on ASP.NET Core using the CoreCompat.System.Drawing package for the image processing.
It downloads an image specified by the URL, crops it using the parameters (provided in the URL too), and writes the cropped image into the output stream.
This is the original photo of my cat:
Original photo of my cat
This is the URL used to crop the photo: http://localhost:60233/image?url=http://sikorsky.pro/images/my_cat.jpg&sourcex=240&sourcey=240&sourcewidth=360&sourceheight=360&destinationwidth=200&destinationheight=200
And this is the cropped photo:
Cropped photo of my cat
Usually I use something like this to prepare images for the mobile devices depending on their real screen resolutions and image container sizes. This allows to save the traffic and image downloading time. Also, it makes images look better because they don’t need any scaling.
Updated to use .NET Core 3.1.
Using the Application
- Run the application.
- You will have 404 error and it is OK.
- Navigate to http://localhost:60233/image?url=http://some-image-url&sourcex=0&sourcey=0&sourcewidth=100&sourceheight=100&destinationwidth=100&destinationheight=100.
- You will get 100x100 fragment from the given image.