Page 1 of 1

Change white background

Posted: 2013-12-17T00:34:25-07:00
by kxc
Hello, i'm trying to change image background from #FFFFFF to #F2F2F2, without damaging image. I try to make image transparent (delete all background along the counter and then set my new color bg, but it damage pixels). Then i try to replace all white pixels and replace it with needed color, but it also damage image cause visualy all bg white, but somewhere color like more or less darken. I have image with hard counter, there is example of original image http://rghost.ru/51020287.view020287.view.
With photoshop i create second layer with #F2F2F2 background and use "Multiply" effect for my image, and it's work perfect, but how i can do something like this with ImageMagick. If anybody know, help please :(

There is example like it correctly looks after photoshop http://rghost.ru/51020415.view
I trying to do something like this, dissolve 2 images, by this composite -dissolve 30x70 -gravity South \test.jpg bg.jpg -alpha Set result.jpg but i get this http://rghost.ru/51020432.view :(

Re: Change white background

Posted: 2013-12-17T00:44:56-07:00
by snibgo
Multiplying by #f2f2f2 will darken all the pixels. You can easily do this with IM. #f2 = 242. 242/255 = 0.949.

Code: Select all

convert test.jpg -evaluate Multiply 0.949 out.png

Re: Change white background

Posted: 2013-12-17T00:49:15-07:00
by kxc
snibgo wrote:Multiplying by #f2f2f2 will darken all the pixels. You can easily do this with IM. #f2 = 242. 242/255 = 0.949.

Code: Select all

convert test.jpg -evaluate Multiply 0.949 out.png
Wooow... It's very nice, many thanks to you :) And thank for this very quickly reply. :D

Re: Change white background

Posted: 2013-12-17T02:58:27-07:00
by kxc
Sorry, mby somebody know the best way to do this using PHP ?
I make this with following code

Code: Select all

for ($i = 0; $i < 4; $i++) {
    echo "<pre>";
    exec("convert ".$i.".jpg -evaluate Multiply 0.949 ".$i."_result.jpg");
    echo "</pre>";
}
But mby there is other way, by using Imagick for PHP ?

Re: Change white background

Posted: 2013-12-17T10:37:26-07:00
by fmw42
see http://us3.php.net/manual/en/imagick.evaluateimage.php

but note that Imagick is not very well supported any longer and generally does not speed things up. See
viewtopic.php?f=4&t=16779