RichTextbox Insert image. Image size and saved document size is more than actual inserted image size

1 Answer 692 Views
ImageEditor RichTextBox
Kamran
Top achievements
Rank 3
Iron
Iron
Veteran
Kamran asked on 13 Nov 2022, 08:16 AM

When inserting image to Richtextbox editor (UI for wpf demo application) through insert image command from Ribbon menu and save document as .rtf. Generated document size is more than (almost twice) of inserted image.

To reproduce this issue, insert any image (sample attached) and save as .rtf. When comparing document size with image size.

Image size is 2.94 MB

.rtf document size is 5.89 MB.

When I open image editor to resize image, I noticed that current image size is 51.5 MB (screenshot attached). Is this correct image size?

 

Another issue I found in Richtextbox editor is that pasting image from clipboard is not working. Same can be reproduced in demo app.

Is there work around to reduce the image size when inserting image from clipboard or inserting image. Also how I can enable paste image from clipboard.

Current behavior generates large .rtf document, which If import to wpf richtextbox editor or MS word then application hangs.

 

 

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 15 Nov 2022, 12:31 PM

Hi Kamran,

I have tested this with MS Word and the behavior is similar, leading to an even bigger file. The reason for this is that inside the RTF markup the image data in hexadecimal values are passed as plain text. If for example, you have the hexadecimal value of "F0" (this is one byte of data), when this is exported as text it will be two bytes - one for each letter/number. You can check this on the attached screenshot. As for the image size shown inside the Image Editor Dialog - this is the size of the uncompressed image. Every pixel consists of four bytes - one for the red channel, one for green, one for blue, and one for the transparency. That said, the size is calculated like this: 4000 (width in pixels) x 3376 (height in pixels) x 4 (bytes per pixel) = 54016000 bytes. The size in MegaBytes is calculated by dividing by 1024 two times (one for KiloBytes and the second one for MegaBytes) -  54016000 / 1024 / 1024 = 51.513671875 MB.

As to the image pasting at hand, I was not able to reproduce this and it is working on my side as expected. We do not have other reports of similar issues as well. I would suggest opening a new ticket for this where you can attach your project and a video that shows how this is reproduced. This will allow us to properly investigate the case. 

Do not hesitate to contact us if you have other questions.

Regards,
Dimitar
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Kamran
Top achievements
Rank 3
Iron
Iron
Veteran
commented on 16 Nov 2022, 04:58 AM

Hi Dimitar,

Thanks for explaining image size issue.

Regarding copy/paste in Richtext box can be produced, if you copy image from file explorer and try to paste in Richtext box.

Other way if you copy image from any editor like Ms Word, Richtext box, then paste is working.

 

Client usually uploads images having document, letters or some reference (scanned images).  Such images are not supposed to be inserted in full resolution.

I am searching for event to handle such situation, where I can handle imported image size, so that overall document size can be reduced.

 

For this I found one thread RichTextBox: Pasting an image should resize it to fit on the page (telerik.com).

Can you please guide me which suitable event is better to handle such situation.

Dimitar
Telerik team
commented on 16 Nov 2022, 07:41 AM

Hi Kamran, 

The approach that you have found with the CommandExecuting event is the correct one. Have you tested this with it? Is there something that prevents you from using it? 

I am looking forward to your reply.

Regards,

Dimitar

Tags
ImageEditor RichTextBox
Asked by
Kamran
Top achievements
Rank 3
Iron
Iron
Veteran
Answers by
Dimitar
Telerik team
Share this question
or