Page 1 of 1

Resizing cielab image - don't understand background color

Posted: 2014-06-18T09:06:10-07:00
by olafkarsten
Hello, after messing around ...
in short: I need some help.
Goal: Resize input image, after that put it centered on a white canvas. Outputimage have to be in cielab colorspace and tif format, 8bit. Code of choice:

Code: Select all

convert -verbose rose: -colorspace lab -filter quadratic -resize 500x500\! -gravity center -crop 2200x1800+0+0\! -layers flatten -depth 8 -compress LZW rose.tif
Don't work. Background is something in the redish area. Whereas:

Code: Select all

convert -verbose rose: -filter quadratic -resize 500x500\! -gravity center -crop 2200x1800+0+0\! -layers flatten -colorspace lab -depth 8 -compress LZW rose.tif
works (note: colorspace conversion at the end). BUT we have found in our tests, that colorspace conversion to cielab before the resize operation gives us better results.

If you don't have an tif-viewer, use rose.JPG instead. Works, too.

Any help is really appreciated.

Thanx.

Re: Resizing cielab image - don't understand background colo

Posted: 2014-06-18T10:02:20-07:00
by fmw42
IM does not process background colors, except in sRGB, as far as I know. Even if you specify HSL or other acceptable colors, they get converted to sRGB values.

Does this do what you want?

Code: Select all

convert -verbose rose: -colorspace lab -filter quadratic -resize 500x500\! \
-set colorspace LAB -colorspace sRGB \
-gravity center -background white -extent 2200x1800 -colorspace lab\
-depth 8 -compress LZW rose.tif

Re: Resizing cielab image - don't understand background colo

Posted: 2014-06-18T10:36:08-07:00
by olafkarsten
Ah, I see. That information in the morning would have saved me a few grey hairs. :D

Thanks for the fast help. I think that works for a starting point. In our case (a script) it is possible, that the input image is bigger in size than the target canvas - therefore the variant with the crop. But i will play around a bit with your variant and hopefully find a way. In any case - as usual - i have learned something from your post. Thanks very much!!!

Re: Resizing cielab image - don't understand background colo

Posted: 2014-06-18T13:33:27-07:00
by fmw42
Not really sure what you are trying to do. So hard to say. It looks like you just want to enlarge rose to 500x500 and then put in inside a (white) background of 2200x1800. -extent will do that for you. See slight reordering of my command above.

Re: Resizing cielab image - don't understand background colo

Posted: 2014-06-22T14:58:57-07:00
by olafkarsten
It perfect fits the bill. I didn't now, that extend actually 'crops'. Works perfect in all test cases. Thanx again.

Re: Resizing cielab image - don't understand background colo

Posted: 2014-06-24T00:56:52-07:00
by olafkarsten
For reference I link to another thread, where we did solve a similiar problem with colorspace and background setting:
- Note: the cielab notation with percent sign (%).