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: 20 Sep 2016 07:13 by ADMIN
Created by: Logo
Comments: 1
Category: BinaryImage
Type: Feature Request
0
All Server applications seeking Windows Server Logo fail the test when using Telerik based binaries. Please use best practices and adopt Authenticode signature and include file information in binaries for security as well as Customer identification of file owners.
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)  

Declined
Last Updated: 20 Jul 2015 14:14 by ADMIN
Completed
Last Updated: 08 Jun 2015 08:45 by ADMIN
ADMIN
Created by: Radoslav
Comments: 3
Category: BinaryImage
Type: Feature Request
6

			
Declined
Last Updated: 20 Oct 2014 06:02 by ADMIN
Unplanned
Last Updated: 20 Nov 2013 15:58 by Keith
I'd like to be able to instantiate and databind a RadBinaryImage, then call a "GetUri" method on the instance to get the WebResource URI that would be generated in markup if the control were added to the page.

In a particular use case, this would allow putting the URI in a meta tag for OpenGraph calls.

An additional API method that would be handy would be a "handler" mode that would allow instantiation of a RadBinaryImage in a custom IHttpHandler implementation, and then serving that request from the final image (after scaling and cropping) generated by the RadBinaryImage control. I could see this taking two forms:

* GetMimeType and GetBytes methods, which could be used to manually populate the Response.
* a Respond method which would take an HttpContext argument, and would set appropriate headers, stream the image, and end the request itself.