Reputation: 67
I have about 2700 images that I want to:
To do this, I downloaded ImageMagick using Homebrew and ran the below command in the relevant directory:
find . -type f -name "*.jpg" -print0 | while IFS= read -r -d $'\0' file; do convert -verbose "$file" -transparent white "$file.png"; done
This worked, however the images still have a few white specks around them as per the below image. With off-white bottles, it's even harder because it makes some of the bottle transparent too!
In photoshop, you can adjust the "tolerance" of "MagicWand" to ensure that this doesn't happen but I'm not sure how you can do this using ImageMagick and can't find anything on Google.
Example of Image with white crust around outside
Can anyone help? Is there a way of doing this with ImageMagick? Is there a better way of processing these 2700 images to remove the white background?
Thanks A
Upvotes: 4
Views: 1959
Reputation: 2617
Use -fuzz
option in ImageMagick
$ convert img.jpg -fuzz 32% -transparent #ffffff out.png
This will allow you to adjust the tolerance value. Hope this helped.
Upvotes: 2