Remove green background

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
sooN
Posts: 13
Joined: 2019-04-29T04:35:12-07:00
Authentication code: 1152

Re: Remove green background

Post by sooN »

I used the -b white and the commands shown in your example, I actually believe it doesn't work properly on my side.

There's an example photo : http://image.noelshack.com/fichiers/201 ... cn1299.jpg ( too large for this website )
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Remove green background

Post by fmw42 »

I want your input, so I can try to process it. This forum does not permit image upload. You have to upload elsewhere and put the URL here as you have done.
sooN
Posts: 13
Joined: 2019-04-29T04:35:12-07:00
Authentication code: 1152

Re: Remove green background

Post by sooN »

Yeah, I don't know what happened with my brain, I wanted to give you the original but... :D

There it is : http://image.noelshack.com/fichiers/201 ... cn1299.jpg
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Remove green background

Post by fmw42 »

What you saw as gray was the transparent regions.

Here is what I get:

Input:
Image

White background:

Code: Select all

greenscreen -b white 1556907464-dscn1299.jpg 1556907464-dscn1299_result.jpg
Image


Default Transparent background (which looks gray if viewed by itself):

Code: Select all

greenscreen 1556907464-dscn1299.jpg 1556907464-dscn1299_result.png

or

greenscreen -b none 1556907464-dscn1299.jpg 1556907464-dscn1299_result.png
Image
sooN
Posts: 13
Joined: 2019-04-29T04:35:12-07:00
Authentication code: 1152

Re: Remove green background

Post by sooN »

Yeah, so it doesn't work on my server, I can't tell why, I either have a fully white picture or this if I switch << -b white >> to << -b none >> :

Image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Remove green background

Post by fmw42 »

What is your Imagemagick version and date of the version and platform/OS?

If on IM 6, then

Code: Select all

convert -version 
or if IM 7, then

Code: Select all

magick -version
A guess is that your server is too old for the connected components processing. I can make a version that does not use that, if we find that is the case.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Remove green background

Post by fmw42 »

Download the script again. I made a change and use -a 0. That will disable the connected components part of the script.

Code: Select all

greenscreen -a 0 -b none 1556907464-dscn1299.jpg 1556907464-dscn1299_result.png

or

greenscreen -a 0 -b white 1556907464-dscn1299.jpg 1556907464-dscn1299_result.jpg
sooN
Posts: 13
Joined: 2019-04-29T04:35:12-07:00
Authentication code: 1152

Re: Remove green background

Post by sooN »

I can't tell which version is installed on my server but I updated your script and did that << greenscreen -a 0 -b white >> and there's no change on the image.

Edit: It works now with << greenscreen -t 22 -a 0 -b white >>. I need to try this more but it looks fine for at least one image.

https://paste2.org/ULmNC4Kh
Attachments
sdfsdfsdfs.png
sdfsdfsdfs.png (49.84 KiB) Viewed 116648 times
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Remove green background

Post by fmw42 »

Your version 6.8.9.9 is prior to -connected-components. I would suggest that you upgrade if possible. That version is about 140 versions old.
sooN
Posts: 13
Joined: 2019-04-29T04:35:12-07:00
Authentication code: 1152

Post by sooN »

Sadly I can't upgrade it, I have like the a very basic hosting, i'm glad ImageMagick is even installed.
Post Reply