ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Saving as webp using ImageMagick is causing low quality/artifacting
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

EricNat

USA
34 Posts

Posted - Oct 19 2022 :  23:07:52  Show Profile  Reply
When I save an image using ImageMagick from ImageEnView, I am getting a very low quality image with lots of artifacting.

For example:

Image->IO->SaveToStream(s,iomscWEBP);

I am loading ImageMagick with the plugin:

IEGlobalSettings()->RegisterPlugIns();

The image seems to load into ImageEnView ok, but when saving it is using very low quality.

Any ideas?

Thanks,
Eric

xequte

7376 Posts

Posted - Oct 20 2022 :  04:20:34  Show Profile  Reply
Hi Eric

Try specifying the WebP properties

// Save a PNG file as a lossless WebP with maximum compression
ImageEnView1.IO.SaveToFile('D:\Image.png');
ImageEnView1.IO.Params.Dict.Insert( 'ImageMagick', TIEDictionary.Create() );
ImageEnView1.IO.Params.Dict.GetDictionary('ImageMagick').Insert( 'webp:lossless', True );
ImageEnView1.IO.Params.Dict.GetDictionary('ImageMagick').Insert( 'webp:method', 6 );
ImageEnView1.IO.SaveToFile('D:\Image_out.webp');


They are defined at:
- http://imagemagick.org/script/webp.php
- http://imagemagick.org/script/defines.php



Nigel
Xequte Software
www.imageen.com
Go to Top of Page

EricNat

USA
34 Posts

Posted - Nov 01 2022 :  17:32:08  Show Profile  Reply
Unfortunately, I am still not having any progress with this after trying many different things.

One thing that is confusing is exactly how the dictionary entries are supposed to be defined. In a few places, they are defined like you have above. But in the Help files, it shows:

// Save a JPEG as WebP at 95% quality (using ImageMagick plug-in)
ImageEnView1.IO.LoadFromFile( 'D:\Image.jpg' );
ImageEnView1.IO.Params.Dict.Clear();
ImageEnView1.IO.Params.Dict.Insert( 'ImageMagick:Quality', 95 );
ImageEnView1.IO.SaveToFile( 'D:\Image_out.WebP' );


I have tried both ways, and neither seems to change the quality. Also, when I use the ImageMagick command line, the image looks good with the defaults (no parameters specified about quality, lossless, etc.). Shouldn't the plug in be using the same defaults?

Whenever I save from ImageEn as WEBP, it is degrading the quality substantially. Attached is an example. The first is the input and the second is what I'm getting on the save.

Any help would be greatly appreciated.

Thanks!
Eric

Go to Top of Page

EricNat

USA
34 Posts

Posted - Nov 01 2022 :  17:38:58  Show Profile  Reply
Here is the original webp file, if that is helpful at all.

attach/EricNat/2022111173848_wepbtest.zip
5.48 KB
Go to Top of Page

xequte

7376 Posts

Posted - Nov 01 2022 :  21:16:43  Show Profile  Reply
Hi Eric

We are only passing the specified params to ImageMagick, so we cannot be sure what effect they have other than by testing it.

From my testing setting 'ImageMagick:Quality' does not have any discernible effect with WebP (I will update the documentation)

You are better to use the WebP parameters:

    ImageEnView1.IO.LoadFromFile('D:\Alpha_2.png');
    ImageEnView1.IO.Params.SetDefaultParams();
    ImageEnView1.IO.Params.Dict.Insert( 'ImageMagick', TIEDictionary.Create() );
    ImageEnView1.IO.Params.Dict.GetDictionary('ImageMagick').Insert( 'webp:lossless', Lossless );
    ImageEnView1.IO.Params.Dict.GetDictionary('ImageMagick').Insert( 'webp:method', Method );
    ImageEnView1.IO.SaveToFile('D:\'+outFN+'.webp');


Lossless=False, Method=6:



Lossless=False, Method=1:



Lossless=True:




It seems that Lossless gives worse quality than lossy here because the source contains anti-aliased (partially transparent) pixels.

I'm not seeing the low quality result that you are. Ensure that you do not have an old version of the ImageEn ImageMagick plug-in and/or ImageEn library.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

xequte

7376 Posts

Posted - Nov 02 2022 :  20:18:00  Show Profile  Reply
Sorry, working with your original image (the source WebP) it looks like when loading the alpha channel is not supported for gray-scale WebP images like this. We will investigate.



Nigel
Xequte Software
www.imageen.com

Go to Top of Page

EricNat

USA
34 Posts

Posted - Nov 11 2022 :  13:06:49  Show Profile  Reply
Thanks Nigel. Yes, I realized that I thought it was happening when it was being saved but it turns out the issue is happening when the webp file is being opened in ImageEnView. Sorry I didn't realize that earlier. Please let me know what you find out. Thank you!
Go to Top of Page

EricNat

USA
34 Posts

Posted - Nov 21 2022 :  16:53:59  Show Profile  Reply
Hi, any update on this issue? Thanks!
Go to Top of Page

xequte

7376 Posts

Posted - Nov 21 2022 :  22:31:40  Show Profile  Reply
Hi Eric

Yes, this will be fixed in our upcoming v11.4.5 (released in the next week or so).

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

EricNat

USA
34 Posts

Posted - Nov 21 2022 :  22:34:19  Show Profile  Reply
Wonderful. Thank you!
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: