Watermarked images lack full transparency

Discussions on NConvert - the command line tool for image conversion and manipulation

Moderators: XnTriq, xnview

Post Reply
pdnavistar
Posts: 7
Joined: Mon Apr 06, 2020 12:40 pm

Watermarked images lack full transparency

Post by pdnavistar » Mon Apr 06, 2020 12:51 pm

I have written a utility that calls Nconvert in shell commands. It works, however the images white space causes the converted WATERMARK'ed images to be partially invisible. That is the watermark partially is hidden by the white space.

When I use the UI of XnConvert on the same, I see that immediately upon opening the original image has a checkerboard background on the image. The watermark images appear correctly on these. I looked in XNconvert fpr options and I can't find how it does this.

Is there are a way to put the checked background or (something else ) on the COMMAND line options.
I tried "-back g" but it had no effect.

I need to find this soon......
Thanks for any help.
Phil

cday
XnThusiast
Posts: 2401
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Watermarked images lack full transparency

Post by cday » Mon Apr 06, 2020 1:33 pm

I am not very familiar with transparency, unfortunately, but looking quickly at the NConvert help file I see the following options which you have probably already found, there may possibly be more:

Code: Select all

-add_alpha value : Add alpha channel (24bits)
-merge_alpha : Merge alpha by using 'transparent color' (32bits)
-set_alpha : Add alpha by using 'transparent color' (32bits)
-transparent value: Transparency index (GIF/PNG)
-transpcolor red green blue: Transparency color (GIF/PNG

Have you used the XnConvert option on the 'Actions' tab (bottom left) to export the code for NConvert, to examine?

I would suggest that, if possible, you post an example image to be watermarked, the watermark file, your code, and the resulting watermarked image.

I don't know whether you may have found a bug, or whether your code need to be modified.

The forum transparency expert rarely posts on NConvert topics, but maybe Pierre can comment?

pdnavistar
Posts: 7
Joined: Mon Apr 06, 2020 12:40 pm

Re: Watermarked images lack full transparency

Post by pdnavistar » Mon Apr 06, 2020 2:04 pm

Hello, thanks for your response.

My question is more about Background. When I see a raw image, the back ground is white. Now, when I open that image with Xnconvert (the UI) it does this:
(See the image attached.)

XnConvert places a pattern on the white space. Is there a way to do that with the command line utility NCONVERT?
Attachments
test.PNG
test.PNG (15.35 KiB) Viewed 294 times

cday
XnThusiast
Posts: 2401
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Watermarked images lack full transparency

Post by cday » Mon Apr 06, 2020 3:04 pm

The checkerboard pattern in the image you posted above indicates transparency, do I understand that you are trying to apply a watermark file (also with transparency) to that file?

When loaded in XnConvert the image displays as above in the preview, but have you tried watermarking the image in that program?

pdnavistar
Posts: 7
Joined: Mon Apr 06, 2020 12:40 pm

Re: Watermarked images lack full transparency

Post by pdnavistar » Mon Apr 06, 2020 3:18 pm

Yes, I have watermarked that image you in my example, and the watermark appears. Seems like transparency is what I am looking to implement.

When you say Transparency, what can I use on the command line?
I see this, but what values do you use?

-add_alpha value : Add alpha channel (24bits)
-merge_alpha : Merge alpha by using 'transparent color' (32bits)
-set_alpha : Add alpha by using 'transparent color' (32bits)
-transparent value: Transparency index (GIF/PNG)
-transpcolor red green blue: Transparency color (GIF/PNG)

My command:

"C:\Program Files\XnView\nconvert.exe" -o 1236_FLZ.png -out png -ratio -rtype lanczos -resize 1024 1024 -wmopacity 40 -wmflag center -wmfile FLZ_LOGO.png FLZ123.PNG



Thanks

cday
XnThusiast
Posts: 2401
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Watermarked images lack full transparency

Post by cday » Mon Apr 06, 2020 3:38 pm

So XnConvert produces the result you need? Have you exported the code as suggested above, and if so could you post it?

I'm afraid I don't know enough about transparency to help, maybe XnTriq or Pierre can comment :?:

pdnavistar
Posts: 7
Joined: Mon Apr 06, 2020 12:40 pm

Re: Watermarked images lack full transparency

Post by pdnavistar » Mon Apr 06, 2020 3:56 pm

HI, thanks again.
I don't know what you mean "Exported". That is Windows shell command I am using as a test.

Maybe it is the image viewer I am using. Do you see how that corner of the watermark is "gone"?

Still, if someone knows how to use the TRANSparency commands on the command line, that would be very helpful.

Thanks again.
PD
Attachments
testzz.PNG
testzz.PNG (61.94 KiB) Viewed 271 times

cday
XnThusiast
Posts: 2401
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Watermarked images lack full transparency

Post by cday » Mon Apr 06, 2020 4:23 pm

The problem is that the top-left part of the small image on the right is white rather than clear, presumably?

It looks as it the 'watermark' image is behind the main image, possibly you need to reverse the images so that the watermark is in front, if that makes any sense? You could possibly try reversing the 'watermark' and 'main' files in your script and see the effect.

So you could try replacing your existing code:

"C:\Program Files\XnView\nconvert.exe" -o 1236_FLZ.png -out png -ratio -rtype lanczos -resize 1024 1024 -wmopacity 40 -wmflag center -wmfile FLZ_LOGO.png FLZ123.PNG

With this code:

"C:\Program Files\XnView\nconvert.exe" -o 1236_FLZ.png -out png -ratio -rtype lanczos -resize 1024 1024 -wmopacity 40 -wmflag center -wmfile FLZ123.PNG FLZ_LOGO.png

pdnavistar
Posts: 7
Joined: Mon Apr 06, 2020 12:40 pm

Re: Watermarked images lack full transparency

Post by pdnavistar » Mon Apr 06, 2020 8:41 pm

That is a good idea, but it causes a very strange effect.
From my experience with this tool, -wm commands must be followed with the watermarked file. Otherwise it uses the main image as the watermark.

cday
XnThusiast
Posts: 2401
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Watermarked images lack full transparency

Post by cday » Mon Apr 06, 2020 8:52 pm

pdnavistar wrote:
Mon Apr 06, 2020 8:41 pm
That is a good idea, but it causes a very strange effect.
From my experience with this tool, -wm commands must be followed with the watermarked file. Otherwise it uses the main image as the watermark.
The question is which file with transparency should be in the front, a 'watermark' is normally placed in front of an image, which normally doesn't have transparency...

So this case, if I understand it correctly, is unusual as both files have transparency.

But reversing the files as above doesn't produce the desired result?

pdnavistar
Posts: 7
Joined: Mon Apr 06, 2020 12:40 pm

Re: Watermarked images lack full transparency

Post by pdnavistar » Mon Apr 06, 2020 9:00 pm

No switching the files does not work. The entire image is cropped to the size of the watermark. No not right.

Yes, the watermark is placed in front and is transparent. That seems to work.
But some of the watermark is become lost (covered??) in the white space, as I showed in the image. The left corner of the transparent watermark was missing.

cday
XnThusiast
Posts: 2401
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Watermarked images lack full transparency

Post by cday » Mon Apr 06, 2020 9:22 pm

I'm sorry, but as I said I'm not very knowledgeable on transparency, and I think you are trying to do something rather unusual.

You have now posted your code, but the only chance I can see to possibly make progress would be if you can upload example test images, not necessarily the actual images you are working with, but files with which the problem can be reproduced. Then, maybe, someone will be able identify the problem...

pdnavistar
Posts: 7
Joined: Mon Apr 06, 2020 12:40 pm

Re: Watermarked images lack full transparency

Post by pdnavistar » Mon Apr 06, 2020 9:37 pm

Right, well I thank you for your many answers and ideas. You have have helped me.
You know, I think it may be working as expected now.

But, there is a real problem in what image viewer is used. The new Windows 10 image viewers are worse than the old Paint program.
(how does Microsoft constantly makes things worse?)

It is the new Win 10 viewer that shows the watermark partially missing (in my attached image). In the old Paint program and the Xnviewer, the converted image looks pretty good. Although. I need more transparency for the watermark, that watermark is completely visible.

Man, this is complicated.

User avatar
xnview
Author of XnView
Posts: 33169
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Watermarked images lack full transparency

Post by xnview » Tue Apr 07, 2020 8:51 am

pdnavistar wrote:
Mon Apr 06, 2020 9:37 pm
It is the new Win 10 viewer that shows the watermark partially missing (in my attached image). In the old Paint program and the Xnviewer, the converted image looks pretty good. Although. I need more transparency for the watermark, that watermark is completely visible.
could you post original image and what you would like to obtain?
Pierre.

Post Reply