Wish: extract mask channel of PNG
Moderators: XnTriq, helmut, xnview
-
- Posts: 134
- Joined: Thu Feb 08, 2007 12:51 pm
Wish: extract mask channel of PNG
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
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
-
- Moderator & Librarian
- Posts: 6451
- Joined: Sun Sep 25, 2005 3:00 am
- Location: Ref Desk
Re: Wish: extract mask channel of PNG
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
xnview ([url=http://newsgroup.xnview.com/viewtopic.php?p=64244#p64244]XnView 1.94[/url]) wrote:Added:
* Extract channel in batch processing - http://newsgroup.xnview.com/viewtopic.php?p=62085
- Humanbalance: GraphicsGale (Image » Duplicate Alpha Channel)
- MeeSoft: Image Analyzer
-
- Posts: 134
- Joined: Thu Feb 08, 2007 12:51 pm
Re: Wish: extract mask channel of PNG
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

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
-
- Moderator & Librarian
- Posts: 6451
- Joined: Sun Sep 25, 2005 3:00 am
- Location: Ref Desk
Re: Wish: extract mask channel of PNG
I believe there are three options:

We'll need some help from marsh or oops66 for this.
Gentlemen?
- XnView + .XBS script
- XnConvert + .XBS script
- NConvert + .BAT/.CMD file

We'll need some help from marsh or oops66 for this.

- FAQ: How to Batch convert several images at once
- Sticky: XnConvert v1.20
- Sticky: How to use nconvert
- Sticky: Command line options of nconvert 5.30
- extract alpha
- make a convert script work in right mouse button...
- 1.94.2: last used settings of batch processing not stored
- XnView crashes when loading script
-
- XnThusiast
- Posts: 2005
- Joined: Tue Jul 17, 2007 1:17 am
- Location: France
Re: Wish: extract mask channel of PNG
Hello,XnTriq wrote:I believe there are three options:
...
- XnView + .XBS script
- XnConvert + .XBS script
- NConvert + .BAT/.CMD file
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.
XnViewMP Linux X64 - Debian - X64
-
- Moderator & Librarian
- Posts: 6451
- Joined: Sun Sep 25, 2005 3:00 am
- Location: Ref Desk
Re: Wish: extract mask channel of PNG
Merci, oops66 
I had tried that solution, but both XnView and XnConvert are crashing when I start the script:
NCONVERT 5.30 gives me an error message:
Do we really need the npcd, size & corder switches for extracting a channel?

I had tried that solution, but both XnView and XnConvert are crashing when I start the script:
Exporting the script to extract_alpha_channel.bat produces this: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 )
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"
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>
-
- XnThusiast
- Posts: 2005
- Joined: Tue Jul 17, 2007 1:17 am
- Location: France
Re: Wish: extract mask channel of PNG
Right XnTriq, I have a crash too with this script (extract channel) under V1.96 and Wine, probably a bug.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 )
(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
XnViewMP Linux X64 - Debian - X64
-
- Posts: 134
- Joined: Thu Feb 08, 2007 12:51 pm
Re: Wish: extract mask channel of PNG
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? 

-
- Moderator & Librarian
- Posts: 6451
- Joined: Sun Sep 25, 2005 3:00 am
- Location: Ref Desk
Re: Wish: extract mask channel of PNG
Good news 

xnview ([url=http://newsgroup.xnview.com/viewtopic.php?p=74048#p74048]Batch-extraction of alpha channel[/url]) wrote:Currently no way, but i'll add itXnTriq wrote:What is the syntax for extracting the alpha channel from a 32-bit PNG image and saving the mask as a greyscale PNG?
-
- Posts: 884
- Joined: Sun Apr 10, 2005 4:29 pm
Re: Wish: extract mask channel of PNG
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.
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.
Oh the feuhrer, oh the feuhrer, oh the feuhrer's nipples bonk!
-
- XnThusiast
- Posts: 2005
- Joined: Tue Jul 17, 2007 1:17 am
- Location: France
Re: Wish: extract mask channel of PNG
The extract_alpha_channel.xbs script works now for me under this new 1.96.1 version.
Thanks Pierre.
Thanks Pierre.
XnViewMP Linux X64 - Debian - X64
-
- Posts: 3
- Joined: Tue Sep 15, 2009 7:43 pm
- Location: Lille, France
Re: Wish: extract mask channel of PNG
For me, this script produce a gray version of my image, not the mask.
i use the latest vesion.
désolé
i use the latest vesion.
désolé

-
- XnThusiast
- Posts: 2005
- Joined: Tue Jul 17, 2007 1:17 am
- Location: France
Re: Wish: extract alpha channel of PNG
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%Bitben wrote:For me, this script produce a gray version of my image, not the mask.
i use the latest vesion.
désolé
XnViewMP Linux X64 - Debian - X64
-
- Posts: 3
- Joined: Tue Sep 15, 2009 7:43 pm
- Location: Lille, France
Re: Wish: extract mask channel of PNG
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.
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.
-
- Posts: 3
- Joined: Tue Sep 15, 2009 7:43 pm
- Location: Lille, France
Re: Wish: extract mask channel of PNG
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...
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...