一,安装工具:
1,安装backgroundremover: 参考:https://www.cnblogs.com/architectforest/p/16790772.html2,安装imageMagick: 参考:
https://www.cnblogs.com/architectforest/p/12807514.html
说明:刘宏缔的架构森林是一个专注架构的博客,地址:https://www.cnblogs.com/architectforest
对应的源码可以访问这里获取: https://github.com/liuhongdi/
或: https://gitee.com/liuhongdi
说明:作者:刘宏缔 邮箱: [email protected]
二,更换背景色:
1,第一步:抠图,生成透明背景的png图片[lhdop@blog img2]$ backgroundremover -i "/home/lhdop/img2/a.jpeg" -o "/home/lhdop/img2/b.png" /home/lhdop/img2/b.png2,第二步:更换背景
[lhdop@blog img2]$ convert b.png -background "#ff0000" -flatten red.png3,查看效果: 原图: 抠图为透明背景后: 改为红色背景后:
三,查看backgroundremover和imagemagick的版本:
查看backgroundremover的版本:[lhdop@blog ~]$ pip3 show backgroundremover Name: backgroundremover Version: 0.1.9 Summary: Background remover from image and video Home-page: https://github.com/nadermx/backgroundremover Author: Johnathan Nader Author-email: [email protected] License: UNKNOWN Location: /home/lhdop/.local/lib/python3.6/site-packages Requires: certifi, charset-normalizer, ffmpeg-python, filelock, filetype, gdown, hsh, idna, more-itertools, moviepy, numpy, Pillow, pymatting, PySocks, requests, scikit-image, scipy, six, torch, torchvision, tqdm, urllib3, waitress Required-by:查看ImageMagick的版本
[lhdop@blog img]$ convert -version Version: ImageMagick 6.9.10-86 Q16 x86_64 2020-01-13 https://imagemagick.org Copyright: © 1999-2020 ImageMagick Studio LLC License: https://imagemagick.org/script/license.php Features: Cipher DPC Modules OpenMP(4.5) Delegates (built-in): bzlib cairo fftw fontconfig freetype gslib gvc jbig jng jp2 jpeg lcms ltdl lzma openexr pangocairo png ps raqm raw rsvg tiff webp wmf x xml zlib
标签:imageMagick,python,backgroundRemover,https,backgroundremover,lhdop,img2,com,png From: https://www.cnblogs.com/architectforest/p/16791891.html