Unplanned
Last Updated: 07 Apr 2020 16:26 by ADMIN

The same is observed with the Thumbnail images in the RadImageGallery, which actually use such BinaryImages.

Reproduction

Note: The attached image should be the only file in a "Images" in the root of the application

protected void Page_Load(object sender, EventArgs e)
{
    var binary = new RadBinaryImage();
    binary.AutoAdjustImageControlSize = false;
    binary.ResizeMode = BinaryImageResizeMode.Crop;

    binary.ID = "BinaryImage";
    binary.Width = Unit.Pixel(100);
    binary.Height = Unit.Pixel(100);

    var path = Directory.EnumerateFiles(Server.MapPath("~/Images")).First();
        
    binary.DataValue = File.ReadAllBytes(path);
    Form.Controls.Add(binary);
}

 

Why this is happening

This seems to be a known issue with some images and their EXIF information regarding the rotation. Detailed information on this matter and a solution could be found in the following forum thread:

Workaround

protected void Page_Load(object sender, EventArgs e)
{
    var binary = new RadBinaryImage();
    binary.ID = "BinaryImage1";
    binary.ResizeMode = BinaryImageResizeMode.Crop;

    binary.Width = Unit.Pixel(100);
    binary.Height = Unit.Pixel(100);

    var path = Directory.EnumerateFiles(Server.MapPath("~/Images")).First();
        
    binary.DataValue = ImagePathToByteArray(path);
    //binary.DataValue = File.ReadAllBytes(path);
    Form.Controls.Add(binary);
}
public byte[] ImagePathToByteArray(string path)
{
    System.Drawing.Image img = Bitmap.FromFile(path);
    if (Array.IndexOf(img.PropertyIdList, 274) > -1)
    {
        var orientation = (int)img.GetPropertyItem(274).Value[0];
        switch (orientation)
        {
            case 1:
                // No rotation required.
                break;
            case 2:
                img.RotateFlip(RotateFlipType.RotateNoneFlipX);
                break;
            case 3:
                img.RotateFlip(RotateFlipType.Rotate180FlipNone);
                break;
            case 4:
                img.RotateFlip(RotateFlipType.Rotate180FlipX);
                break;
            case 5:
                img.RotateFlip(RotateFlipType.Rotate90FlipX);
                break;
            case 6:
                img.RotateFlip(RotateFlipType.Rotate90FlipNone);
                break;
            case 7:
                img.RotateFlip(RotateFlipType.Rotate270FlipX);
                break;
            case 8:
                img.RotateFlip(RotateFlipType.Rotate270FlipNone);
                break;
        }
        // This EXIF data is now invalid and should be removed.
        img.RemovePropertyItem(274);
    }

    return ImageToByte(img);
}

public static byte[] ImageToByte(System.Drawing.Image img)
{
    System.Drawing.ImageConverter converter = new System.Drawing.ImageConverter();
    return (byte[])converter.ConvertTo(img, typeof(byte[]));
}

 

 

Declined
Last Updated: 03 Aug 2016 13:33 by ADMIN
Created by: Legis
Comments: 1
Category: BinaryImage
Type: Bug Report
1
System.Threading.ThreadAbortException    2    Thread was being aborted.    System.Threading.Thread.AbortInternal() 
   System.Threading.Thread.Abort(System.Object) 
   System.Web.HttpResponse.AbortCurrentThread() 
   Telerik.Web.UI.RadBinaryImageHandler.ProcessRequestInternal() 
   Telerik.Web.UI.HandlerRouter.ProcessHandler(System.String, System.Web.HttpContext) 
   Telerik.Web.UI.WebResource.ProcessRequest(System.Web.HttpContext) 
   System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 
   System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef) 
    
System.Exception    1    <none>    System.Threading.Thread.AbortInternal() 
   System.Threading.Thread.Abort(System.Object) 
   System.Web.HttpResponse.AbortCurrentThread() 
   Telerik.Web.UI.RadBinaryImageHandler.ProcessRequestInternal() 
   Telerik.Web.UI.HandlerRouter.ProcessHandler(System.String, System.Web.HttpContext) 
   Telerik.Web.UI.WebResource.ProcessRequest(System.Web.HttpContext) 
   System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 
   System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef) 
    
System.OutOfMemoryException    1    <none>    System.Threading.Thread.AbortInternal() 
   System.Threading.Thread.Abort(System.Object) 
   System.Web.HttpResponse.AbortCurrentThread() 
   Telerik.Web.UI.RadBinaryImageHandler.ProcessRequestInternal() 
   Telerik.Web.UI.HandlerRouter.ProcessHandler(System.String, System.Web.HttpContext) 
   Telerik.Web.UI.WebResource.ProcessRequest(System.Web.HttpContext) 
   System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 
   System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef) 
    
System.StackOverflowException    1    <none>    System.Threading.Thread.AbortInternal() 
   System.Threading.Thread.Abort(System.Object) 
   System.Web.HttpResponse.AbortCurrentThread() 
   Telerik.Web.UI.RadBinaryImageHandler.ProcessRequestInternal() 
   Telerik.Web.UI.HandlerRouter.ProcessHandler(System.String, System.Web.HttpContext) 
   Telerik.Web.UI.WebResource.ProcessRequest(System.Web.HttpContext) 
   System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 
   System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef) 
    
System.ExecutionEngineException    1    <none>    System.Threading.Thread.AbortInternal() 
   System.Threading.Thread.Abort(System.Object) 
   System.Web.HttpResponse.AbortCurrentThread() 
   Telerik.Web.UI.RadBinaryImageHandler.ProcessRequestInternal() 
   Telerik.Web.UI.HandlerRouter.ProcessHandler(System.String, System.Web.HttpContext) 
   Telerik.Web.UI.WebResource.ProcessRequest(System.Web.HttpContext) 
   System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 
   System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef) 
    
System.Threading.ThreadAbortException    2    <none>    System.Threading.Thread.AbortInternal() 
   System.Threading.Thread.Abort(System.Object) 
   System.Web.HttpResponse.AbortCurrentThread() 
   Telerik.Web.UI.RadBinaryImageHandler.ProcessRequestInternal() 
   Telerik.Web.UI.HandlerRouter.ProcessHandler(System.String, System.Web.HttpContext) 
   Telerik.Web.UI.WebResource.ProcessRequest(System.Web.HttpContext) 
   System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 
   System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef)