This is a migrated thread and some comments may be shown as answers.

GridBinaryImage creates huge bmp files

3 Answers 49 Views
BinaryImage
This is a migrated thread and some comments may be shown as answers.
Chanan Zass
Top achievements
Rank 1
Chanan Zass asked on 14 Mar 2011, 01:28 PM
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.

 

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 17 Mar 2011, 02:24 PM
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
0
Chanan Zass
Top achievements
Rank 1
answered on 17 Mar 2011, 03:47 PM
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).

0
Daniel
Telerik team
answered on 22 Mar 2011, 05:59 PM
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
Tags
BinaryImage
Asked by
Chanan Zass
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Chanan Zass
Top achievements
Rank 1
Share this question
or