Page 1 of 2

Wish: extract mask channel of PNG

Posted: Wed Apr 29, 2009 5:48 pm
by Micha
Hello,

it could be nice if XnView would allow to extract the alpha channel from a PNG. I don't know any software that allow to get access to the PNG alpha channel and to save it to a separate file.

Regards,
Micha

Re: Wish: extract mask channel of PNG

Posted: Wed Apr 29, 2009 9:45 pm
by XnTriq
Hi Micha :)
XnTriq ([url=http://newsgroup.xnview.com/viewtopic.php?p=65288#p65288]Channel displays[/url]) wrote:View mode: Image » Extract channel » Red / Green / Blue / Alpha

Re: Wish: extract mask channel of PNG

Posted: Thu Apr 30, 2009 8:56 am
by Micha
Great - thank you for the hints. :)

An other request - often I need the same batch conversation several times a day (convert to RGB or now extract alpha) and switch it on again and again. It could be nice to get a general batch option like "use options next time again".

-Micha

Re: Wish: extract mask channel of PNG

Posted: Thu Apr 30, 2009 10:30 pm
by XnTriq
I believe there are three options:
  1. XnView + .XBS script
  2. XnConvert + .XBS script
  3. NConvert + .BAT/.CMD file
Unfortunately XnView and XnConvert are crashing on me when I try to run this task, and I don't know the correct command-line options for NConvert. :?

We'll need some help from marsh or oops66 for this.
:mrgreen: Gentlemen?

Re: Wish: extract mask channel of PNG

Posted: Fri May 01, 2009 2:39 pm
by oops66
XnTriq wrote:I believe there are three options:
  1. XnView + .XBS script
  2. XnConvert + .XBS script
  3. NConvert + .BAT/.CMD file
...
Hello,
about the first solution: XnView + .XBS script
Under Xnview v1.96, you can create your own .xbf batch processing files by doing this:

1-) Select or tag your desired images
2-) ( Ctrl+U ) keys to open the batch processing menu
3-) -> into general tab, you can customize the output directory, format, options... ( for example, output directory=test, format=jpg with customized options quality=75%, keep exif=yes, ovewride=rename, keep subfolder structure=yes,... ...and so...)
-> into Transformations tab: \images\extract channel for example\ Add> and select your desired channel to extract (Alpha,or red,or green,or blue), -> then clique "Save" and give a name to your custom .xbf file (example extract_alpha.xbf).
Do the same steeps for extracting the others channels (if desired), and give an other name extract_blue.xbf, ...

The next time, you just should have to select the right .xbf script (mouse select or load...) to do automatically the appropriate job.

Re: Wish: extract mask channel of PNG

Posted: Fri May 01, 2009 4:05 pm
by XnTriq
Merci, oops66 :D

I had tried that solution, but both XnView and XnConvert are crashing when I start the script:
extract_alpha_channel.xbs wrote:

Code: Select all

extract( 3 )
settings( 3 0 0 0 0 0 )
output_path( X:\Test\Processed\ )
output( png 0 9 )
Exporting the script to extract_alpha_channel.bat produces this:

Code: Select all

nconvert -npcd 2 -size 256x256+0 -ctype grey -corder inter -out png -o X:\Test\Processed\%%.png -extract "X:\Test\Original\rgba.png"
NCONVERT 5.30 gives me an error message:

Code: Select all

C:\PROGRA~1\XnView\1960>nconvert -npcd 2 -size 256x256+0 -ctype grey -corder inter -out png -o X:\Test\Processed\%%.png -extract "X:\Test\Original\rgba.png"

Bad argument -'extract'


C:\PROGRA~1\XnView\1960>
Do we really need the npcd, size & corder switches for extracting a channel?

Re: Wish: extract mask channel of PNG

Posted: Fri May 01, 2009 4:53 pm
by oops66
XnTriq wrote:...
I had tried that solution, but both XnView and XnConvert are crashing when I start the script:
extract_alpha_channel.xbs wrote:

Code: Select all

extract( 3 )
settings( 3 0 0 0 0 0 )
output_path( X:\Test\Processed\ )
output( png 0 9 )
Right XnTriq, I have a crash too with this script (extract channel) under V1.96 and Wine, probably a bug.
(But I don't know if this bug is present under Windows XP or Vista ? )

I have this message:
wine: Unhandled page fault on write access to 0x00000020 at address 0x6b2d20 (thread 003b), starting debugger...
...And into nconvert 5.30: Bad argument -'extract' too here.

FI, this argument is missing into the nconvert v5.30 help version too:
nconvert.exe -help > nconvert-help.txt

Re: Wish: extract mask channel of PNG

Posted: Mon May 04, 2009 5:45 am
by Micha
Thank you for all the hints, especially the detailed descriptions. The script solutions are a workaround, but it could be nice to get a easier solution. Why not do it like at Photoshop - additional pressing the ALT-Key makes that the last used settings are used. In this case it would be ALT+Ctrl+U and anything would be fine. Could it be possible to get this feature please? :wink:

Re: Wish: extract mask channel of PNG

Posted: Mon May 04, 2009 4:30 pm
by XnTriq
Good news 8)
xnview ([url=http://newsgroup.xnview.com/viewtopic.php?p=74048#p74048]Batch-extraction of alpha channel[/url]) wrote:
XnTriq wrote:What is the syntax for extracting the alpha channel from a 32-bit PNG image and saving the mask as a greyscale PNG?
Currently no way, but i'll add it

Re: Wish: extract mask channel of PNG

Posted: Sat May 09, 2009 4:24 am
by Drahken
Xnview can extract the alpha channel/mask, huh? I never knew.
I use image analyzer to extract the masks. When you open a png with alpha transparency in imageanalyzer, it asks if you want to merge the mask. If you choose not to, then it open the image (minus the mask) and the mask as 2 seperate images.

Re: Wish: extract mask channel of PNG

Posted: Wed May 13, 2009 5:13 pm
by oops66
The extract_alpha_channel.xbs script works now for me under this new 1.96.1 version.
Thanks Pierre.

Re: Wish: extract mask channel of PNG

Posted: Thu Sep 17, 2009 9:35 am
by Bitben
For me, this script produce a gray version of my image, not the mask.
i use the latest vesion.
désolé :?

Re: Wish: extract alpha channel of PNG

Posted: Thu Sep 17, 2009 10:52 am
by oops66
Bitben wrote:For me, this script produce a gray version of my image, not the mask.
i use the latest vesion.
désolé :?
It's normal for the alpha channel into a .png file: black is 100% transparent, white is 0% transparent (opacity=100%), gray is between 0% and 100%

Re: Wish: extract mask channel of PNG

Posted: Thu Sep 17, 2009 12:43 pm
by Bitben
yes, i know, but my image come from 3DS and the Alpha cannel is the outline of this object (a mask). and my result image is like a RGB to grayscale transformation in photoshop.

en français, c'est bien aussi, si je ne me fait pas remonter les bretelles par l'e modérateur :
je sais bien ce qu'est un canal alpha mais mon jpeg résultant n'est pas le masque attendu mais une version en niveau de gris de mon image.

Re: Wish: extract mask channel of PNG

Posted: Tue Sep 22, 2009 8:28 pm
by Bitben
am i the only one with this problem?
i tried png converted by xnview (in case of 3DS implementation of PNG were non standard), i see the mask (Preview/ShowMask) but i cant extract it!
i have a grayscale image, ok, but this is not the mask, it's the source image...without colors...