GridBinaryImage creates huge bmp files

4 posts, 0 answers
  1. Chanan Zass
    Chanan Zass avatar
    50 posts
    Member since:
    Aug 2012

    Posted 14 Mar 2011 Link to this post

    Greetings,

    We're using GridBinaryImageColum to upload jpg images whose size is about 100KB.
    These images are saved in a varbinary columns in a database.
    When calling these images on the front-end, we get bmp images that exceed 1.1MB.

    It that normal?
    Is there a way to avoid the size jump, or is it simply better not to use the BinaryImage for such scenarios?

    Thanks in advance.

     

  2. Daniel
    Admin
    Daniel avatar
    4945 posts

    Posted 17 Mar 2011 Link to this post

    Hello Chanan,

    What do you mean by "calling these images on the front-end"? Do you use the GridBinaryImageColumn to display the images? If so, could you please help us to reproduce the problem on our end by providing additional information or sample project?
    Please note that we do not convert the images in our code.

    Best regards,
    Daniel
    the Telerik team
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Chanan Zass
    Chanan Zass avatar
    50 posts
    Member since:
    Aug 2012

    Posted 17 Mar 2011 Link to this post

    Sorry for not updating this post earlier, as we've resolved this issue a bit later.

    We use RadGrid with GridBinaryImageColumn to upload JPG images (back-end).
    We show these images (front-end) using a repeater and RadBinaryImage.

    Displaying these as they are fed directly from the database results in huge BMP images.
    Problem was resolved by processing the images before displaying them:
    <telerik:RadBinaryImage ID="bimgArt" Height="301px" Width="931"
    DataValue='<%# FormatImage(Eval("ArtImage")) %>' ResizeMode="None"
    AlternateText='<%# Eval("ArtTitle") %>' ToolTip='<%# Eval("ArtTitle") %>' runat="server" />

    And in the codeBehind (VB.NET):
    Public Function FormatImage(ByVal img As Byte()) As Byte()
            Dim stream As New MemoryStream(img)
            Dim streamOut As New MemoryStream
      
            Dim myImage As Image = Image.FromStream(stream)
            myImage.Save(streamOut, ImageFormat.Jpeg)
            Return streamOut.ToArray()     
        End Function

    This displays as a JPG image (with reduced weight).

  5. Daniel
    Admin
    Daniel avatar
    4945 posts

    Posted 22 Mar 2011 Link to this post

    Hello Chanan,

    Thank you for sharing your code with our community.
    Under normal circumstances you won't have to use such approach as we don't make any conversions to the image.

    Regards,
    Daniel
    the Telerik team
Back to Top