Duplicated
Last Updated: 30 Nov 2020 14:53 by ADMIN
Mihajlo
Created on: 30 Oct 2020 12:48
Category: ImageEditor
Type: Bug Report
0
Images are always saved in PNG format
Create a new blank Telerik project. Add RadImageEditor control to the form. Start the app. Open some jpg image. Try to save this image in various formats. No matter what format you select, from BMP to TIFF, the image will be saved in PNG format. The file extension will be .bmp or .tiff, but the file contents is PNG.
Duplicated
This item is a duplicate of an already existing item. You can find the original item here:
3 comments
ADMIN
Dess | Tech Support Engineer, Sr.
Posted on: 10 Nov 2020 10:56
Hello, Mihajlo,  

After further investigation, I can confirm that the save button uses the Image.Save(String) overload. However, as it is stated in MSDN, "If no encoder exists for the file format of the image, the Portable Network Graphics (PNG) encoder is used.".

We should improve the save button's functionality in RadImageEditor and consider the selected format as well. 

I have logged it in our feedback portal by creating a public thread on your behalf. You can track its progress, subscribe for status changes and add your comments on the following link - feedback item.

I have also updated your Telerik points.

Currently, the possible solution that I can suggest is to replace the button and execute the Save method overload with passed ImageFormat:  

        private void RadForm1_Load(object sender, EventArgs e)
        {
            this.radImageEditor1.ImageEditorElement.CommandsElement.SaveButton.Visibility = ElementVisibility.Collapsed;
            RadButtonElement saveButton = new RadButtonElement();
            saveButton.Image = this.radImageEditor1.ImageEditorElement.CommandsElement.SaveButton.Image;
            saveButton.Click += saveButton_Click;
            this.radImageEditor1.ImageEditorElement.CommandsElement.TopCommandsStackElement.Children.Insert(1, saveButton);
        }

        private void saveButton_Click(object sender, EventArgs e)
        {
            string destinationFilePath = @"..\..\exported.jpg";
            this.radImageEditor1.SaveImage(destinationFilePath, ImageFormat.Jpeg);
        }

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Mihajlo
Posted on: 09 Nov 2020 16:30

When I execute the line below then the image is saved as JPEG. But when I click the Save Image button, and enter filename with .jpg extension, the image is saved as PNG:

 

            this.radImageEditor1.ImageEditorElement.CurrentBitmap.Save(@"<some file path.jpg>", ImageFormat.Jpeg);
ADMIN
Dess | Tech Support Engineer, Sr.
Posted on: 03 Nov 2020 09:39

Hello, Mihajlo, 

RadImageEditor internally uses the Image.Save(string filename, ImageFormat format) method provided by Microsoft for storing an image into different ImageFormats: https://docs.microsoft.com/en-us/dotnet/api/system.drawing.image.save?view=dotnet-plat-ext-3.1#System_Drawing_Image_Save_System_String_System_Drawing_Imaging_ImageFormat_ 

Hence, in case you are not obtaining the desired Image output, it seems that you are not getting the desired result from the MS Image.Save(string filename, ImageFormat format) method. Would it be possible to test this method outside RadImageEditor and see how it would save a random image file? Is the produced result good for you?

If the stored images are not as good as you wish, I would highly encourage you to have a look at general programming forums like MSDN and StakcOverflow on this topic.

I hope this information helps. If you need any further assistance please don't hesitate to contact me.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.