- Getting Started
- Browser Support
- Languages Support
- Shortcuts
- Activation
- Examples
- Customize the Editor
- Use-cases
- Plugins
- APIs
- Development Frameworks
- Server Integrations
- Server SDKs
- Migration Guides
- Changelog
.NET Image Resize
How it works
- Upload image to the server.
- Image is resized when it is stored on the server.
Image Upload
The Server Upload section describes the steps to upload an image to a server. Resizing images on the editor only changes the size displayed in the browser. Changing the physical size of an image occurs on the server side.
Resize Image
The editor's .NET SDK uses the .NET MagickImage.Resize method to resize images before storing them on disk. You can use all the options available for it.
MagickGeometry resizeGeometry = new MagickGeometry(300, 300);
resizeGeometry.IgnoreAspectRatio = true;
FroalaEditor.ImageOptions options = new FroalaEditor.ImageOptions
{
ResizeGeometry = resizeGeometry
};
object response = FroalaEditor.Image.Upload(System.Web.HttpContext.Current, fileRoute, options);
Complete Example
<script>
new FroalaEditor('.selector', {
// Set the image upload URL.
imageUploadURL: '/FroalaApi/UploadImageResize',
imageUploadParams: {
id: 'my_editor'
}
})
</script>
using System;
using System.Web.Mvc;
using ImageMagick;
namespace demo.Controllers
{
public class FroalaApiController : Controller
{
public ActionResult UploadImageResize()
{
string fileRoute = "/Public/";
MagickGeometry resizeGeometry = new MagickGeometry(300, 300);
resizeGeometry.IgnoreAspectRatio = true;
FroalaEditor.ImageOptions options = new FroalaEditor.ImageOptions
{
ResizeGeometry = resizeGeometry
};
try
{
return Json(FroalaEditor.Image.Upload(System.Web.HttpContext.Current, fileRoute, options));
}
catch (Exception e)
{
return Json(e);
}
}
}
}
Do you think we can improve this article? Let us know.