Page 1 of 1
JPG to PNG with transparent border
Posted: Tue Mar 19, 2013 2:52 pm
by christianjules
Hello,
I would like to convert a JPG to PNG, adding borders at the left and right and making them transparent. I am trying to do that with this command :
nconvert -out png -canvas 300 300 top-center -transpcolor 0 0 0 -merge_alpha 9781895526066.jpg
But I only get two black borders, not transparent. Could someone tell me what is wrong in my commande line, please

?
The original JPG and the PNG I get are attached.
Btw, I use NCONVERT v6.17 for MacOS X (10.8.2)
Regards,
Christian
Re: JPG to PNG with transparent border
Posted: Wed Mar 20, 2013 12:55 pm
by christianjules
Too bad no one seems to have the same need ...
I have also tried to split it in two separate taks : jpg -> png a first, then adding the transparency with -transpcolor, but I obtain the same result : my black borders are not transparent.
Regards,
Christian
Re: JPG to PNG with transparent border
Posted: Wed Mar 20, 2013 3:59 pm
by xnview
Please try
Code: Select all
nconvert -out png -32bits -bgcolor 255 0 0 -canvas 300 300 top-center
Re: JPG to PNG with transparent border
Posted: Wed Mar 20, 2013 6:30 pm
by christianjules
It works, great !
But what was wrong in my commande line ? I thought the -transpcolor parameter was the appropriate one ...
And also, is the color 255 0 0 pre-defined to be the transparent color pour PNG32 ?
Anyway, thanks a lot for your help.
Re: JPG to PNG with transparent border
Posted: Thu Mar 21, 2013 7:57 am
by xnview
christianjules wrote:It works, great !
But what was wrong in my commande line ? I thought the -transpcolor parameter was the appropriate one ...
And also, is the color 255 0 0 pre-defined to be the transparent color pour PNG32 ?
Anyway, thanks a lot for your help.
-bgcolor has a little problem, if you use -bgcolor 0 0 0 it doesnt work...
Re: JPG to PNG with transparent border
Posted: Fri Mar 29, 2013 9:48 am
by DOS386
http://newsgroup.xnview.com/viewtopic.php?t=12247
> But what was wrong in my commandline ?
" -32bits" converts 24 bpp to 32 bpp ... but ...
> I thought the -transpcolor parameter was the appropriate one
It should be sufficient ... but does't work for 24 bpp (PNG can, NC can't ... BUG or missing feature) ?
> And also, is the color 255 0 0 pre-defined to be the transparent color pour PNG32 ?
There is no "transparent color pour PNG32" ... transparent RGB color is used only in 24bpp PNG, and it's NOT set to 255 0 0 by PNG spec:
http://www.libpng.org/pub/png/spec/1.2/ ... tml#C.tRNS
Note that you have to remove any possible (0,0,0) values (replace them by (0,0,1)) before adding transparency based on a transparent color (0,0,0) ... what's the best way with NC ???
> -bgcolor has a little problem, if you use -bgcolor 0 0 0 it doesnt work...
Works for me (NC 6.17)

But shouldn't "-bgcolor" eat 4 instead of 3 numbers for 32bpp images ?
And "-transpcolor" is either broken or I don't know how to use it.