Help with CANVAS and RESIZE

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

Moderators: XnTriq, helmut, xnview

kobber
Posts: 1
Joined: Fri Jun 18, 2021 10:34 am

Help with CANVAS and RESIZE

Post by kobber »

Hello.
I want to process a pack of images with different scales - need to crop and resize to 4:3 scale.
For example, on screenshot: red rectangles - source images, green - desired results.
222.jpg
222.jpg (7.98 KiB) Viewed 7301 times


Initialy I used this command:

nconvert -ratio -resize 0 2000 -canvas 1500 2000 center -i -o dest.jpg source.jpg

It was good for one type of images, but for second - it leaves black lines on a sides of image.

Is there solution to use one line command to deal with both types of scales?
May be canvas longest, resize longest
Have no ideas...
cday
XnThusiast
Posts: 3973
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Help with CANVAS and RESIZE

Post by cday »

When resizing an image to a particular ratio requires new canvas to be added, the colour of the canvas added is set by the -background option:

Code: Select all

 -bgcolor red green blue: Background color (for rotate/canvas)
 -bgcolor2 red green blue alpha: Background color (for rotate/canvas)
When no colour is specified the default value may well be black.

I'm not sure looking quickly whether that is your problem, but you might take a look at that...
bll06
Posts: 5
Joined: Wed May 18, 2022 9:27 am
Location: Cannes - France

Re: Help with CANVAS and RESIZE

Post by bll06 »

Hello,

The -bgcolor and -bgcolor2 doesn't work when i use -keepcspace option. My original picture have a 32bit color depth.

For example :
nconvert -q 85 -ratio -rtype lanczos -rflag orient -keepcspace -resize longest 1000 -bgcolor 255 255 255 -canvas 1000 1000 center -out jpeg -o "C:\TEMP\photo1.JPG" "C:\MEDIATHEQUE\photo.EPS"

The added background get a random color.

Any ideas?
Thanks
cday
XnThusiast
Posts: 3973
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Help with CANVAS and RESIZE

Post by cday »

You want to keep 32-bit depth, or output a 24-bit image with a selected background color? In the latter case, you could test including a term to set the bit depth to 24-bit.
bll06
Posts: 5
Joined: Wed May 18, 2022 9:27 am
Location: Cannes - France

Re: Help with CANVAS and RESIZE

Post by bll06 »

cday wrote: Wed May 18, 2022 9:54 am You want to keep 32-bit depth, or output a 24-bit image with a selected background color? In the latter case, you could test including a term to set the bit depth to 24-bit.
I need to keep 32-bits depth.
cday
XnThusiast
Posts: 3973
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Help with CANVAS and RESIZE

Post by cday »

bll06 wrote: Wed May 18, 2022 10:00 am I need to keep 32-bits depth.
You might look at this recent thread for ideas if you haven't already done so.

I don't have much experience with 32-bit, but when I had a quick look at the poster's problem using XnConvert, I also obtained an output file with a green background.

Otherwise you will have to wait for Pierre the developer of NConvert.
User avatar
xnview
Author of XnView
Posts: 43326
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Help with CANVAS and RESIZE

Post by xnview »

and if you use

Code: Select all

nconvert -q 85 -ratio -rtype lanczos -rflag orient -resize longest 1000 -bgcolor 255 255 255 -canvas 1000 1000 center -out jpeg -o "C:\TEMP\photo1.JPG" "C:\MEDIATHEQUE\photo.EPS"
why do you want -bgcolor?
Pierre.
bll06
Posts: 5
Joined: Wed May 18, 2022 9:27 am
Location: Cannes - France

Re: Help with CANVAS and RESIZE

Post by bll06 »

xnview wrote: Thu May 19, 2022 11:07 am and if you use

Code: Select all

nconvert -q 85 -ratio -rtype lanczos -rflag orient -resize longest 1000 -bgcolor 255 255 255 -canvas 1000 1000 center -out jpeg -o "C:\TEMP\photo1.JPG" "C:\MEDIATHEQUE\photo.EPS"
why do you want -bgcolor?
With -keepcspace option i got black (or random color) stripes
Attachments
photo1_1.JPG
User avatar
xnview
Author of XnView
Posts: 43326
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Help with CANVAS and RESIZE

Post by xnview »

could you send me the original file?
Pierre.
bll06
Posts: 5
Joined: Wed May 18, 2022 9:27 am
Location: Cannes - France

Re: Help with CANVAS and RESIZE

Post by bll06 »

xnview wrote: Mon May 23, 2022 11:57 am could you send me the original file?
The original file
Attachments
photo1_original.JPG
User avatar
xnview
Author of XnView
Posts: 43326
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Help with CANVAS and RESIZE

Post by xnview »

ok, the original image is in CMYK, you would like to keep it in CMYK?
Pierre.
bll06
Posts: 5
Joined: Wed May 18, 2022 9:27 am
Location: Cannes - France

Re: Help with CANVAS and RESIZE

Post by bll06 »

xnview wrote: Mon May 23, 2022 2:16 pm ok, the original image is in CMYK, you would like to keep it in CMYK?
Yes, I need to keep the originals colors
User avatar
xnview
Author of XnView
Posts: 43326
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Help with CANVAS and RESIZE

Post by xnview »

ok, i'll fix it....
Pierre.
RENEDANSET
Posts: 2
Joined: Tue Oct 17, 2023 9:56 pm

Re: Help with CANVAS and RESIZE

Post by RENEDANSET »

j'ai le même problème,
nconvert -ratio -rtype lanczos -rflag orient -resize 600 600 -canvas 600 600 center -bgcolor 255 255 255 "C:/PHOTOS/AL23512-PD01.jpg"
le fond est noir
User avatar
xnview
Author of XnView
Posts: 43326
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Help with CANVAS and RESIZE

Post by xnview »

RENEDANSET wrote: Tue Oct 17, 2023 10:06 pm j'ai le même problème,
nconvert -ratio -rtype lanczos -rflag orient -resize 600 600 -canvas 600 600 center -bgcolor 255 255 255 "C:/PHOTOS/AL23512-PD01.jpg"
le fond est noir
il me faudrait votre image
Pierre.
Post Reply