ImageMagick.sh 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://linuxeye.com
  4. #
  5. # Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
  6. #
  7. # Project home page:
  8. # https://oneinstack.com
  9. # https://github.com/oneinstack/oneinstack
  10. Install_ImageMagick() {
  11. if [ -d "${imagick_install_dir}" ]; then
  12. echo "${CWARNING}ImageMagick already installed! ${CEND}"
  13. else
  14. pushd ${oneinstack_dir}/src > /dev/null
  15. tar xzf ImageMagick-${imagemagick_ver}.tar.gz
  16. #if [ "${PM}" == 'yum' ]; then
  17. # yum -y install libwebp-devel
  18. #elif [ "${PM}" == 'apt-get' ]; then
  19. # yum -y install libwebp-dev
  20. #fi
  21. pushd ImageMagick-${imagemagick_ver} > /dev/null
  22. ./configure --prefix=${imagick_install_dir} --enable-shared --enable-static
  23. make -j ${THREAD} && make install
  24. popd > /dev/null
  25. rm -rf ImageMagick-${imagemagick_ver}
  26. popd > /dev/null
  27. fi
  28. }
  29. Uninstall_ImageMagick() {
  30. if [ -d "${imagick_install_dir}" ]; then
  31. rm -rf ${imagick_install_dir}
  32. echo; echo "${CMSG}ImageMagick uninstall completed${CEND}"
  33. fi
  34. }
  35. Install_pecl_imagick() {
  36. if [ -e "${php_install_dir}/bin/phpize" ]; then
  37. pushd ${oneinstack_dir}/src > /dev/null
  38. PHP_detail_ver=$(${php_install_dir}/bin/php-config --version)
  39. PHP_main_ver=${PHP_detail_ver%.*}
  40. phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
  41. if [[ "${PHP_main_ver}" =~ ^5.3$ ]]; then
  42. tar xzf imagick-${imagick_oldver}.tgz
  43. pushd imagick-${imagick_oldver} > /dev/null
  44. else
  45. tar xzf imagick-${imagick_ver}.tgz
  46. pushd imagick-${imagick_ver} > /dev/null
  47. fi
  48. export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
  49. ${php_install_dir}/bin/phpize
  50. ./configure --with-php-config=${php_install_dir}/bin/php-config --with-imagick=${imagick_install_dir}
  51. make -j ${THREAD} && make install
  52. popd > /dev/null
  53. if [ -f "${phpExtensionDir}/imagick.so" ]; then
  54. echo 'extension=imagick.so' > ${php_install_dir}/etc/php.d/03-imagick.ini
  55. echo "${CSUCCESS}PHP imagick module installed successfully! ${CEND}"
  56. rm -rf imagick-${imagick_ver} imagick-${imagick_oldver}
  57. else
  58. echo "${CFAILURE}PHP imagick module install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
  59. fi
  60. popd > /dev/null
  61. fi
  62. }
  63. Uninstall_pecl_imagick() {
  64. if [ -e "${php_install_dir}/etc/php.d/03-imagick.ini" ]; then
  65. rm -f ${php_install_dir}/etc/php.d/03-imagick.ini
  66. echo; echo "${CMSG}PHP imagick module uninstall completed${CEND}"
  67. else
  68. echo; echo "${CWARNING}PHP imagick module does not exist! ${CEND}"
  69. fi
  70. }