Page 1 of 1

Set background color without changing image color

Posted: 2013-08-25T11:26:22-07:00
by hknight
I want my image to be 111x111 and I want the background to be red however I do not want the image to be too red. This code makes the part of the images that are not covered with the image red, which is good, however it also makes the image too red.

Code: Select all

convert -size 111x111 -crop 111x111+0+0 -background "red" rose: -unsharp 0x.5 \( +clone -shave 10x10 -fill gray50 -colorize 50% -mattecolor gray40 -frame 10x10+3+4 -blur 0x2 \) -compose HardLight -composite -gravity center -extent 111x111 -strip -quality 80 xyz.png

Re: Set background color without changing image color

Posted: 2013-08-25T11:45:53-07:00
by fmw42
Your command seems to have unnecessary and misplaced elements, in my opinion.

-size and -crop do nothing at the beginning of your command.

You have nothing to -strip with rose: image. Furthermore -quality 80 may not be a correct expression for -quality when using PNG output, it is certainly not a percent as with jpg. see http://www.imagemagick.org/script/comma ... hp#quality

Here is you command

convert -size 111x111 -crop 111x111+0+0 -background "red" rose: -unsharp 0x.5 -write 1tmp1.png \
\( +clone -shave 10x10 -fill gray50 -colorize 50% -mattecolor gray40 -frame 10x10+3+4 -blur 0x2 \) \
-compose HardLight -composite -gravity center -extent 111x111 -strip -quality 80 xyz.png


Here is how I would write it.

convert rose: -unsharp 0x.5 \
\( +clone -shave 10x10 -fill gray50 -colorize 50% -mattecolor gray40 -frame 10x10+3+4 -blur 0x2 \) \
-compose HardLight -composite -gravity center -background red -extent 111x111 xyz.png


There is an issue with either. The -extent is affected by the -compose hardlight. So you should reset the -compose to over afterwards. You get a totally different result.


convert rose: -unsharp 0x.5 \
\( +clone -shave 10x10 -fill gray50 -colorize 50% -mattecolor gray40 -frame 10x10+3+4 -blur 0x2 \) \
-compose HardLight -composite -compose over -gravity center -background red -extent 111x111 xyz.png


But if that is not what you want, then you need to clarify further. The use of hardlight may not be what you want here.

Re: Set background color without changing image color

Posted: 2013-08-26T05:14:12-07:00
by hknight
Perfect, thank you.