Multiple bgcolor

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

Moderators: XnTriq, helmut, xnview

kosho
Posts: 3
Joined: Thu Oct 29, 2009 2:26 pm

Multiple bgcolor

Post by kosho »

Hello,

I want create border with different color.
I use 2 canvas with 2 bgcolor.
But the border is only white.

Can I use multiple bgcolor? :D

The command line :
-out jpeg -opthuff -q 80 -i -rmeta -rexifthumb -ratio -rtype lanczos -rflag decr -resize 1600 0 -bgcolor 0 0 0 -canvas #20 #20 center -bgcolor 255 255 255 -canvas #30 #30 center
anfvan6
Posts: 10
Joined: Sun Mar 22, 2020 2:11 pm

Re: Multiple bgcolor

Post by anfvan6 »

Double canvas resize doesn`t work.
Does anyone know how to make border (with two colors) in the nconvert?
cday
XnThusiast
Posts: 4183
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Multiple bgcolor

Post by cday »

anfvan6 wrote: Tue Mar 24, 2020 3:03 pm Double canvas resize doesn't work.
Does anyone know how to make border (with two colors) in the nconvert?
Could you explain in more detail what you need and post the code you are using?
anfvan6
Posts: 10
Joined: Sun Mar 22, 2020 2:11 pm

Re: Multiple bgcolor

Post by anfvan6 »

i need to make border (1 px black line + 7 px white line for each side) for resized image.
i try to use this code:

"C:\XnView\nconvert.exe" -quiet -out jpeg -ratio -rflag decr -resize longest 1328 -rtype lanczos -bgcolor 0 0 0 -canvas #2 #2 center -bgcolor 255 255 255 -canvas #14 #14 center -overwrite -q 92 -opthuff -dct 3 -smoothingf 0 -subsampling 0 "%%~fA*"

but this code make one color border (resize canvas #16 #16 with bgcolor 255 255 255).
cday
XnThusiast
Posts: 4183
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Multiple bgcolor

Post by cday »

Have you exported that code from XnConvert, or XnView MP Batch Convert, it looks as if you may have, and if so did you get the desired result in that software?
anfvan6
Posts: 10
Joined: Sun Mar 22, 2020 2:11 pm

Re: Multiple bgcolor

Post by anfvan6 »

In XnView batch converter double canvas resize works properly.
Export to bat contains with code:
nconvert -npcd 2 -size 256x256+0 -ctype rgb -corder inter -out jpeg -bgcolor 0 0 0 -canvas 101%% 101%% center -bgcolor 255 255 255 -canvas 102%% 102%% center
But this code doesn`t work properly in NConvert (it makes one canvas resize with bgcolor 255 255 255).
cday
XnThusiast
Posts: 4183
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Multiple bgcolor

Post by cday »

Thanks, that was a preliminary question mainly out of curiosity...

I am a volunteer with limited experience at the command line, and try to provide some support because no-one else does except Pierre who has very limited time. In addition there is limited documentation of some aspects of NConvert.

I am not sure whether canvas resize can be used twice in the same code line in NConvert but your result seems to suggest that it can't, unless there is a different problem with your code.

My immediate suggestion therefore is to test using two successive resizes in separate code lines in a batch file .bat.
anfvan6
Posts: 10
Joined: Sun Mar 22, 2020 2:11 pm

Re: Multiple bgcolor

Post by anfvan6 »

Thanks.
This method is working.
But it significantly increases the processing time. And most likely double conversion in jpeg reduces image quality.
cday
XnThusiast
Posts: 4183
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Multiple bgcolor

Post by cday »

anfvan6 wrote: Wed Mar 25, 2020 11:14 am This method is working.
Good :D
But it significantly increases the processing time. And most likely double conversion in jpeg reduces image quality.
In principle it could, but Is the image quality actually noticeably reduced the way you use the created images, even if necessary when you use the optimum quality settings?

I'm not sure if NConvert can use multiple cores, I don't see an option in the 7.32 help file, possibly not added yet...
1x1
Posts: 6
Joined: Sat Aug 15, 2020 3:01 am

Re: Multiple bgcolor

Post by 1x1 »

This post is little old but I permit me to give an important hint.

To avoid this quality loss by an double conversion to jpeg, use an intermediate lossless format like png that will do an exact copy of your original image where you will do all your work losslessly, and then only at the end step convert it to jpeg.