JPG to PNG with transparent border

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

Moderators: XnTriq, helmut, xnview

christianjules
Posts: 3
Joined: Tue Mar 19, 2013 2:40 pm
Location: Gradignan, Aquitaine - France

JPG to PNG with transparent border

Post 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 :shock: ?
The original JPG and the PNG I get are attached.

Btw, I use NCONVERT v6.17 for MacOS X (10.8.2)

Regards,
Christian
You do not have the required permissions to view the files attached to this post.
christianjules
Posts: 3
Joined: Tue Mar 19, 2013 2:40 pm
Location: Gradignan, Aquitaine - France

Re: JPG to PNG with transparent border

Post by christianjules »

Too bad no one seems to have the same need ... :shock:
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
User avatar
xnview
Author of XnView
Posts: 45553
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: JPG to PNG with transparent border

Post by xnview »

Please try

Code: Select all

nconvert -out png -32bits -bgcolor 255 0 0 -canvas 300 300 top-center
Pierre.
christianjules
Posts: 3
Joined: Tue Mar 19, 2013 2:40 pm
Location: Gradignan, Aquitaine - France

Re: JPG to PNG with transparent border

Post 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.
User avatar
xnview
Author of XnView
Posts: 45553
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: JPG to PNG with transparent border

Post 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...
Pierre.
User avatar
DOS386
Posts: 291
Joined: Sun Jun 11, 2006 2:43 pm

Re: JPG to PNG with transparent border

Post 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) :shock: 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.
There is indeed no WinZIP under my rock.