EzDev.org

ImageProcessor

ImageProcessor - :camera: A fluent wrapper around System.Drawing for the processing of image files. An open-source solution for on-the-fly processing of images using .NET :: ImageProcessor a .net library for on-the-fly processing of images.


Make sure that an image larger than 5 mb is reduced below that size c#

I'm using ImageProcessor to reduce the resolution or quality of an image, but I'm don't know how to make sure that the image resultant size it's below 5 megabytes. I tried setting the image dimensions to 3840-2160 but I want to use a better option.

Here it's my code:

private static byte[] redimensionImage(ref byte[] photoBytes)
    {
        var byteCuantity = ConvertBytesToMegabytes(photoBytes.Count());
        ISupportedImageFormat format = new JpegFormat();

        using (MemoryStream inStream = new MemoryStream(photoBytes))
        {
            using (MemoryStream outStream = new MemoryStream())
            {
                // Initialize the ImageFactory using the overload to preserve EXIF metadata.
                using (ImageFactory imageFactory = new ImageFactory(preserveExifData: true))
                {
                    // Load, resize, set the format and quality and save an image.
                    using (var imageProcessor = imageFactory.Load(inStream))
                    {
                        var originalHeight = imageProcessor.Image.Size.Height;
                        var originalWidth = imageProcessor.Image.Size.Width;

                        //calculate aspect ratio
                        var aspect = originalWidth / (float)originalHeight;
                        int newWidth, newHeight;

                        var dimenssionTooSmall = false;
                        if (originalWidth <= originalHeight && originalWidth < 100)
                        {
                            //calculate new dimensions based on aspect ratio
                            newHeight = (int)(100 / aspect);
                            var resizeLayer = new ResizeLayer(new Size(100, newHeight), ResizeMode.Min);
                            imageProcessor.Resize(resizeLayer);
                            dimenssionTooSmall = true;
                        }
                        else if (originalHeight < originalWidth && originalHeight < 100)
                        {
                            //calculate new dimensions based on aspect ratio
                            newWidth = (int)(100 / aspect);
                            var resizeLayer = new ResizeLayer(new Size(newWidth, 100), ResizeMode.Min);
                            imageProcessor.Resize(resizeLayer);
                            dimenssionTooSmall = true;
                        }

                        if (byteCuantity > 1 || dimenssionTooSmall)
                        {
                            //format.Quality = 6;

                            imageProcessor.Resize(new ResizeLayer(new Size(3840, 2160), ResizeMode.Min));

                            imageProcessor.Format(format);
                            imageProcessor.Save(outStream);
                            return outStream.ToArray();
                        }
                        else
                        {
                            return inStream.ToArray();
                        }
                    }
                }


            }
        }
    }

Thanks and regards.


Source: (StackOverflow)

ImageProcessor error - Couldn't load IImageService

I am bumping my head for 5 hours trying to find a solution for a simple problem. I created a new LocalFileImageService but I am getting the following error

Couldn't load IImageService: MCWeb_3SR.Klase.LocalFileImageService2, MCWeb_3SR.Klase

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.TypeLoadException: Couldn't load IImageService: MCWeb_3SR.Klase.LocalFileImageService2, MCWeb_3SR.Klase

Here is my config entry

<service name="LocalFileImageService2" type="MCWeb_3SR.Klase.LocalFileImageService2, MCWeb_3SR.Klase" />

end here is my Service code

namespace MCWeb_3SR.Klase
{
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Net;
    using System.Threading.Tasks;
    using System.Web;
    using ImageProcessor.Web.Helpers;
    using ImageProcessor.Web.Services;

    /// <summary>
    /// The local file image service for retrieving images from the file system.
    /// </summary>
    public class LocalFileImageService2 : IImageService 
    {
        /// <summary>
        /// Gets or sets the prefix for the given implementation.
        /// <remarks>
        /// This value is used as a prefix for any image requests that should use this service.
        /// </remarks>
        /// </summary>
        public string Prefix { get; set; } = string.Empty;

        /// <summary>
        /// Gets a value indicating whether the image service requests files from
        /// the locally based file system.
        /// </summary>
        public bool IsFileLocalService => true;

        /// <summary>
        /// Gets or sets any additional settings required by the service.
        /// </summary>
        public Dictionary<string, string> Settings { get; set; }

        /// <summary>
        /// Gets or sets the white list of <see cref="System.Uri"/>.
        /// </summary>
        public Uri[] WhiteList { get; set; }

        /// <summary>
        /// Gets a value indicating whether the current request passes sanitizing rules.
        /// </summary>
        /// <param name="path">
        /// The image path.
        /// </param>
        /// <returns>
        /// <c>True</c> if the request is valid; otherwise, <c>False</c>.
        /// </returns>
        public bool IsValidRequest(string path)
        {
            return ImageHelpers.IsValidImageExtension(path);
        }

        /// <summary>
        /// Gets the image using the given identifier.
        /// </summary>
        /// <param name="id">
        /// The value identifying the image to fetch.
        /// </param>
        /// <returns>
        /// The <see cref="System.Byte"/> array containing the image data.
        /// </returns>
        public async Task<byte[]> GetImage(object id)
        {
            string path = id.ToString();
            byte[] buffer;

            // Check to see if the file exists.
            if (!File.Exists(path))
            {

                path = System.Web.Hosting.HostingEnvironment.MapPath("~/images/NemaSlike.png"); 
                //throw new HttpException((int)HttpStatusCode.NotFound, $"No image exists at {path}");
            }

            using (FileStream file = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, 4096, true))
            {
                buffer = new byte[file.Length];
                await file.ReadAsync(buffer, 0, (int)file.Length);
            }

            return buffer;
        }
    }
}`

What might be a problem ?


Source: (StackOverflow)

ImageProcessor ERROR with existing content uploaded to Azure Blob Storage

I came here to see if this issue can be fixed. I had all my images stored in my /media/ folder but I put it on an Azure Blob Storage and it works fine.

Actually when I try to delete one of my old custom media content with images I get this error and I can't delete any of the medias uploaded before change it to Azure Blob Storage:

ERROR ImageProcessor.Web.HttpModules.ImageProcessingModule - 
ImageProcessor.Common.Exceptions.ImageProcessingException: ProcessImageAsync 597 : No image exists at D:\home\site\wwwroot\media\1034\case-659x420.jpg

Can somebody tell me what 's happening? Thank you

EDIT1 This is the image on my blob. Umbraco Stores the image full path somewhere?

EDIT 2 This is the error on BO.


Source: (StackOverflow)

Image processor Error with umbraco and Azure blob

I have a serious issue with my site after change our image storage to Azure blob, when I tried to delete it I get this error list

2017-05-11 17:10:05,271 [P1012/D3/T40] ERROR ImageProcessor.Web.HttpModules.ImageProcessingModule - 
ImageProcessor.Common.Exceptions.ImageProcessingException: ProcessImageAsync 597 : No image exists at D:\home\site\wwwroot\media\126812\bob400x600.jpg
 2017-05-11 17:12:17,573 [P1012/D3/T23] ERROR ImageProcessor.Web.HttpModules.ImageProcessingModule - 
ImageProcessor.Common.Exceptions.ImageProcessingException: ProcessImageAsync 597 : No image exists at D:\home\site\wwwroot\media\126803\constance-659x420.jpg
 2017-05-11 17:14:25,462 [P1012/D3/T14] ERROR ImageProcessor.Web.HttpModules.ImageProcessingModule - 
ImageProcessor.Common.Exceptions.ImageProcessingException: ProcessImageAsync 597 : No image exists at D:\home\site\wwwroot\media\126805\vietna.jpg
 2017-05-11 17:14:52,993 [P1012/D3/T39] ERROR ImageProcessor.Web.HttpModules.ImageProcessingModule - 
ImageProcessor.Common.Exceptions.ImageProcessingException: ProcessImageAsync 597 : No image exists at D:\home\site\wwwroot\media\126811\cuda-659x420.jpg
 2017-05-11 17:15:19,981 [P1012/D3/T8] ERROR ImageProcessor.Web.HttpModules.ImageProcessingModule - ImageProcessor.Common.Exceptions.ImageProcessingException: ProcessImageAsync 597 : No image exists at D:\home\site\wwwroot\media\126810\where.jpg

This images are inside a Custom mediatype but it was working untill I move it to another folder in the website structure. Now i can do anything with it, I can't delete it, change or move it.

Could be some config errors? I really don't know why the image processor are looking into local media, because it is all on the blob.

Any help would be appreciated.


Source: (StackOverflow)

CKFinder 3 MVC:An unknown error has occured during execution of FileUpload command

Fatal | CKSource.CKFinder.Connector.Core.CommandHandler | 2017-05-12 09:08:46.5431 | An unknown error has occured during execution of FileUpload command.| System.MissingMethodException: 找不到方法:“Void ImageProcessor.Imaging.ResizeLayer..ctor(System.Drawing.Size, ImageProcessor.Imaging.ResizeMode, ImageProcessor.Imaging.AnchorPosition, Boolean, Single[], System.Nullable`1<System.Drawing.Size>, System.Collections.Generic.List`1<System.Drawing.Size>)”。
   在 CKSource.CKFinder.Connector.Core.Commands.FileUpload.FileUploadCommandExecutor.<ExecuteAsync>d__9.MoveNext()
   在 System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   在 CKSource.CKFinder.Connector.Core.Commands.FileUpload.FileUploadCommandExecutor.ExecuteAsync(FileUploadParameters commandParameters, CancellationToken cancellationToken)
   在 CKSource.CKFinder.Connector.Core.Commands.FileUpload.FileUploadCommandImpl.<ExecuteAsync>d__6.MoveNext()
--- 引发异常的上一位置中堆栈跟踪的末尾 ---
   在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   在 System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   在 CKSource.CKFinder.Connector.Core.CommandHandler.<ExecuteAsync>d__12.MoveNext()    在 CKSource.CKFinder.Connector.Core.Commands.FileUpload.FileUploadCommandExecutor.<ExecuteAsync>d__9.MoveNext()
   在 System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   在 CKSource.CKFinder.Connector.Core.Commands.FileUpload.FileUploadCommandExecutor.ExecuteAsync(FileUploadParameters commandParameters, CancellationToken cancellationToken)
   在 CKSource.CKFinder.Connector.Core.Commands.FileUpload.FileUploadCommandImpl.<ExecuteAsync>d__6.MoveNext()
--- 引发异常的上一位置中堆栈跟踪的末尾 ---
   在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   在 System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   在 CKSource.CKFinder.Connector.Core.CommandHandler.<ExecuteAsync>d__12.MoveNext()

Source: (StackOverflow)

ASP MVC Input stream is not a supported format

I use ImageProccessor to apply some changes on uploaded image and I want to check if width of image has been uploaded less than 150px change it to 200px. For this purpose I make instance of Image class like this:

Image image = Image.FromStream(inStream); 

When I add this I get this error:

Input stream is not a supported format

Here is my code:

    public ActionResult SaveFileToTemporaryFodler()
    {

        HttpPostedFileBase file = Request.Files[0];
        string directoryPath = ImageService.GetImageTempDirectoryRelativePath();

        byte[] photoBytes = file.InputStream.StreamToByteArray();
        int quality = 70;


        using (var inStream = new MemoryStream(photoBytes))
        {
            Image image = Image.FromStream(inStream);

            using (var outStream = new MemoryStream())
            {
                Size size = new Size(500, 500);
                using (var imageFactory = new ImageFactory(preserveExifData: true))
                {    
                     if (image.Width < 150)
                    {
                        size = new Size(200, 200);
                    }
                    // I get error here :
                    imageFactory.Load(inStream)

                        .RoundedCorners(new RoundedCornerLayer(190, true, true, true, true))
                        .Watermark(new TextLayer()
                        {
                            DropShadow = true,
                            Text = "Watermark",
                            Style = FontStyle.Bold,
                        })
                        .Resize(size)     
                        .Quality(quality)
                        .Save(Server.MapPath(directoryPath + fileName));    
                }
            }
        }



        return Json(new { message = Request.Files.Count, picName = fileName, fileExtention = fileName });
    }

How can I fix this issue or is there any way to check image dimensions?

UPDATE:

I upload image with Ajax and here is StreamToByteArray function:

 public static byte[] StreamToByteArray(this Stream input)
    {
        input.Position = 0;
        using (var ms = new MemoryStream())
        {
            int length = System.Convert.ToInt32(input.Length);
            input.CopyTo(ms, length);
            return ms.ToArray();
        }
    }

Source: (StackOverflow)

Does ImageProcessor ImageFactory Load System.Drawing.Image modify by reference argument

ImageProcessor ImageFactory supports Load method with argument System.Drawing.Image. But Save method does not support similar argument. Is there a way with ImageProcessor ImageFactory to Load a System.Drawing.Image, manipulate the image, e.g., Brightness, then Save the modified image to System.Drawing.Image?


Source: (StackOverflow)

ImageProcessor seems to rotate image 90 degrees after resizing

I downloaded the ImageProcessor library using nuget for c#. I am using it to upload and resize image for a website. The upload process works fine except, when I try to view the uploaded image it appears backward rotated 90 from the original image. Here is the code that I am using:

        ISupportedImageFormat format = new JpegFormat { Quality = 70 };

        using (MemoryStream inStream = new MemoryStream(_img))
        {
            using (MemoryStream outStream = new MemoryStream())
            {
                // Initialize the ImageFactory using the overload to preserve EXIF metadata.
                using (ImageFactory imageFactory = new ImageFactory(preserveExifData: false))
                {
                    // Load, resize, set the format and quality and save an image.
                    imageFactory.Load(inStream)
                        .Resize(new ResizeLayer(new Size(width, height), resizeMode: resizeMode))
                                .Format(format)
                                .Save(outStream);
                }

                return outStream.ToArray();
            }
        }

Source: (StackOverflow)

Zoom in and crop using ImageProcessor.Web

Using ImageProcessor.Web (http://imageprocessor.org/imageprocessor-web/imageprocessingmodule/resize/) resize module, I'm able to get the image cropped to a defined size, like:

<img src="~/Content/img/fiji-01.jpg?width=500&height=500&mode=crop&center=0.1,0.1"/>

But how do I zoom in the picture twice the size and the crop?

Tried something like:

<img src="~/Content/img/fiji-01.jpg?mode=crop&center=0.9,0.9&heightratio=3&widthratio=3&height=500" />

It didn't help.


Source: (StackOverflow)

ImageProcessor.Web custom IImageService causes NullReferenceException

I've tried implementing a custom IImageService both in Umbraco and in a vanilla MVC app following the advice here:

https://github.com/JimBobSquarePants/ImageProcessor/issues/105

But I think I might be missing a step as I only get this error:

[NullReferenceException: Object reference not set to an instance of an object.]
   ImageProcessor.Web.HttpModules.<ProcessImageAsync>d__b.MoveNext() +755
   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92
   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
   System.Web.TaskAsyncHelper.EndTask(IAsyncResult ar) +71
   System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +380
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

The DatabaseImageService below gets called on the Prefix property and IsFileLocalSevice but then I get the error above. IsValidRequest() and GetImage() never get called.

The code is a copy of LocalFileImageService.cs

I have also tried specifying this ImageService in the security.config file that comes with ImageProcessor.Web.Config but the same error occurs.

namespace ImageProcessorTest
{
    public class DatabaseImageService : IImageService
    {
        private string prefix = "database.axd";

        public string Prefix
        {
            get
            {
                return this.prefix;
            }

            set
            {
                this.prefix = value;
            }
        }

        public bool IsFileLocalService
        {
            get
            {
                return true;
            }
        }

        public Dictionary<string, string> Settings { get; set; }

        public Uri[] WhiteList { get; set; }

        public bool IsValidRequest(string path)
        {
            return ImageHelpers.IsValidImageExtension(path);
        }

        public async Task<byte[]> GetImage(object id)
        {
            string path = id.ToString();
            byte[] buffer;

            FileInfo fileInfo = new FileInfo(path);

            if (!fileInfo.Exists)
            {
                throw new HttpException((int)HttpStatusCode.NotFound, "No image exists at " + path);
            }

            using (FileStream file = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, 4096, true))
            {
                buffer = new byte[file.Length];
                await file.ReadAsync(buffer, 0, (int)file.Length);
            }

            return buffer;
        }
    }
}

Update 1

The code example above is in a vanilla MVC App. The configuration is as follows:

<?xml version="1.0" encoding="utf-8"?>
<security>
  <services>
    <service name="LocalFileImageService" type="ImageProcessor.Web.Services.LocalFileImageService, ImageProcessor.Web" />
    <!--Disable the LocalFileImageService and enable this one when using virtual paths. -->
    <!--<service name="CloudImageService" type="ImageProcessor.Web.Services.CloudImageService, ImageProcessor.Web">
      <settings>
        <setting key="Container" value=""/>
        <setting key="MaxBytes" value="8194304"/>
        <setting key="Timeout" value="30000"/>
        <setting key="Host" value="http://yourhost.com/"/>
      </settings>
    </service>-->
    <service prefix="remote.axd" name="RemoteImageService" type="ImageProcessor.Web.Services.RemoteImageService, ImageProcessor.Web">
      <settings>
        <setting key="MaxBytes" value="4194304" />
        <setting key="Timeout" value="3000" />
        <setting key="Protocol" value="http" />
      </settings>
      <whitelist>
      </whitelist>
    </service>
    **<service prefix="database.axd" name="DatabaseImageService" type="ImageProcessorTest.DatabaseImageService, ImageProcessorTest" />**
  </services>
</security>

To be clear I have done the following steps to get to this point:

  • Vanilla MVC App
  • Installed: ImageProcessor ImageProcessor.Web and ImageProcessor.Web.Config via NuGet
  • Created the DatabaseImageService class above
  • Edited the security.config as shown

I have an image in the root of the site "hami-1.jpg". I can manipulate it correctly with the default LocalFileImageService http://localhost:11832/hami-1.jpg?width=200 .

The prefix I have specified for my custom IImageService is "database.axd" so the url should be either: ?

  • http://localhost:11832/database.axd/hami-1.jpg?width=200
  • http://localhost:11832/database.axd?hami-1.jpg?width=200

? I'm not sure at this point because I have seen examples of both. ?

In any case when I am debugging I do not hit any breakpoints in the IsValidRequest or GetImage methods. I do hit a breakpoint in IsFileLocalService.

It is a really basic setup so I'm sure it's something I'm missing.

Ultimately I want to replace the GetImage method with my own that will retrieve images from a database using something like:

private AppContext _db = new AppContext();

private MembershipService MembershipService
{
    get
    {
        if (ms == null)
        {
            ms = new MembershipService(_db, UmbracoContext.Current);
        }
        return ms;
    }
}

public async Task<byte[]> GetImage(object id = null)
{
    var image = await _db.Images.FindAsync(id);
    var currentMember = MembershipService.GetCurrentMember();
    if (image != null)
    {
        var content = image.Content;
        _db.Dispose();
        switch (image.Privacy)
        {
            case Models.Base.Privacy.Private:
                if (image.Owner.Id == currentMember.Id ||MembershipService.FindMembersInRole(currentMember.UmbracoMember.Username, "Judges").Any())
                    return content;
                break;
            case Models.Base.Privacy.Unlisted:
                return content;
            case Models.Base.Privacy.Public:
                return content;
        }
    }
    throw new HttpException(404, "Image not found for id: " + id);
}

Source: (StackOverflow)

ImageProcessor - Resize to a specified width (automatic height)

I'm using the ImageProcessor library in my App.

I'm using this code in order to resize to a given specific dimensions ( width+height) :

 public static byte[] ResizeImage(byte[] inputFileBytes, int w, int h, ResizeMode resizeMode)
        {
            byte[] photoBytes = inputFileBytes; 

            ISupportedImageFormat format = new JpegFormat { Quality = 70, IsIndexed = false };
            Size size = new Size(w, h);
            using (MemoryStream inStream = new MemoryStream(photoBytes))
            using (MemoryStream outStream = new MemoryStream())
            {

                using (ImageFactory imageFactory = new ImageFactory(preserveExifData: false))
                {
                    var r = new ResizeLayer(size, resizeMode);

                    imageFactory.Load(inStream)
                        .Resize(r)
                        .Format(format)
                        .Save(outStream);
                }


                return outStream.ToArray();
            }
        }

I invoke it via (This is a crop example ):

   byte[] servedImage =  ResizeImage(byteArray,[...imgWidth...],
                       [...imgHeight...],ResizeMode.Crop);

This all works good.

But now I need to resize the image to a specific width — And I want the height to be proportional.

I already know that the Resize method has an overload :

public ImageFactory Resize(Size size)

But I only have the Width in the size param ( I want the height to be calculated automatically)

Question

How can I resize an Image (byte[])to a specific Width , maintaining the aspect ration using ImageProcessor ?


Source: (StackOverflow)

Super slow performance between Umbraco and AWS S3 bucket for images and cached images (ImageProcessor)

So I've been having really slow performance site when it comes to image loading, resizing and the lot using the ImageProcessor within Umbraco.

Currently using:

  • Umbraco 7.4.3
  • AWSSDK.Core 3.3.11
  • AWSSDK.S3 3.3.5.11
  • ImageProcessor 2.5.3
  • ImageProcessor.Web 4.8.3
  • Umbraco.Storage.S3 1.0.23 (not maintained anymore?)

CloudFront doesn't cache the images either (custom origin doesn't get cached from what I understand?), so to avoid the site falling over, I have an NGINX server between CloudFront and the Umbraco servers (which are behind a standard AWS load balancer).

It's hard to think that 2 x c4.xlarge instances can't cope with processing the images instantly.

One thing I noticed that happens sometimes is the following: Log snippet

I just put new pair of AWS access keys to see if it will make any difference, but sadly, still slow. Even the backoffice takes ages to load up previews of the images in both the content tab and media tab.

Configuration wise, I've triple checked against what I've found on the internet (for FileSystemProviders and ImageProcessor configs).

Imageprocessor cache config:

    <?xml version="1.0" encoding="utf-8" ?>
<!-- For more information on using transformations 
     see the web.config examples at http://go.microsoft.com/fwlink/?LinkId=214134. -->
<caching xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform" currentCache="AmazonS3Cache" xdt:Transform="Replace">
  <caches>
    <cache name="AmazonS3Cache" type="formula_e.web.cms.Core.ImageProcessor.AmazonS3Cache, formula-e.web.cms" maxDays="365" xdt:Locator="Match(name)" xdt:Transform="Replace">
      <settings>
        <setting key="AwsAccessKey" value="XXXXXXX" />
        <setting key="AwsSecretKey" value="XXXXXXX" />
        <setting key="AwsBucketName" value="XXXXXXX" />
        <setting key="AwsEndpoint" value="http://XXXXXXX.s3.amazonaws.com/" />
        <setting key="AwsBucketFolder" value="cache-live" />
        <setting key="CachedCDNRoot" value="http://XXXXXXX.cloudfront.net" />
        <setting key="StreamCachedImage" value="true" />
      </settings>
    </cache>
  </caches>
</caching>

Imageprocessor security config:

    <?xml version="1.0" encoding="utf-8" ?>
<!-- For more information on using transformations 
     see the web.config examples at http://go.microsoft.com/fwlink/?LinkId=214134. -->
<security xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <services xdt:Transform="Replace">
    <service prefix="media/" name="CloudImageService" type="ImageProcessor.Web.Services.CloudImageService, ImageProcessor.Web">
      <settings>
        <setting key="MaxBytes" value="41943040"/>
        <setting key="Timeout" value="30000"/>
        <setting key="Host" value="http://XXXXXXX.s3.amazonaws.com/media/"/>
      </settings>
    </service>
  </services>
</security>

Filesytemproviders config:

    <?xml version="1.0" encoding="utf-8" ?>
<!-- For more information on using transformations 
     see the web.config examples at http://go.microsoft.com/fwlink/?LinkId=214134. -->
<FileSystemProviders xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <Provider alias="media" type="Umbraco.Storage.S3.BucketFileSystem, Umbraco.Storage.S3" xdt:Locator="Match(alias)" xdt:Transform="Replace">
    <Parameters>
      <!-- S3 Bucket Name -->
      <add key="bucketName" value="XXXXXXX" />
      <!-- S3 Bucket Hostname - Used for storage in umbraco's database (Should be blank when using Virtual File Provider) -->
      <add key="bucketHostName" value="" />
      <!-- S3 Object Key Prefix - What should we prefix keys with? -->
      <add key="bucketKeyPrefix" value="media" />
      <!-- AWS Region Endpoint (us-east-1/us-west-1/ap-southeast-2) Important to get right otherwise all API requests will return a 30x response -->
      <add key="region" value="eu-west-1" />
    </Parameters>
  </Provider>
</FileSystemProviders>

How do I go about finding out what the issue is?


Source: (StackOverflow)

Any way to restrict the full resolution image from being served up with Imageprocessor in Umbraco?

I'm working on a photography website in which full resolution photos can be uploaded but full-res should not be able to be displayed/accessed (download of the full res will take place through a token.)

I've tried the "restrictTo" setting but resolutions need to not be reliant on specified dimensions.

Is there a way to have myphoto.jpg by default without a querystring display at for example 700x700 yet still have the full resolution file available through a token download? Pretty much, an image without a querystring is still processed by Imageprocessor but with a default resize rule.


Source: (StackOverflow)

Umbraco Package (ImageProcessor) Crashing site

So I tried to install a package called 'Image Processor' to our Umbraco build which I later found was incompatible. How do I manually remove this package from the build? I've tried removing all mention of 'ImageProcessor' from the Web.config, packages.config etc still no cigar.

This is the error we're getting.

enter image description here


Source: (StackOverflow)

C# Recolored Image Pixelated

I'm attempting to load an image from the filesystem, re-color it, then save it to a Stream. The images in question are fairly simple, single-color, geometric shapes.

I have it working, but the resulting images are heavily pixelated along the edges.

I've tried System.Drawing:

var colorMap = new ColorMap
{
    OldColor = Color.FromArgb(255, 255, 255, 255),
    NewColor = Color.FromArgb(255, 255, 0, 0)
};
var imageAttrs = new ImageAttributes();
imageAttrs.SetRemapTable(new[] {colorMap});

var newImage = new Bitmap(image.Width, image.Height);
var graphics = Graphics.FromImage(newImage);

graphics.SmoothingMode = SmoothingMode.AntiAlias;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;

graphics.DrawImage(image,
    new Rectangle(0, 0, image.Width, image.Height),
    0, 0,
    image.Width,
    image.Height,
    GraphicsUnit.Pixel,
    imageAttrs);

I've also tried the ImageProcessor library, using its ReplaceColor() method, but I get the same results (although not quite as bad).

Any way to do this and preserve the nice smooth edges my original image had?


Source: (StackOverflow)