我读了这个帖子: Does TideSDK have any image manipulation capabilities?
我尝试过使用gd函数并在我的TideSDK应用程序中失败,然后我运行了get_extension_funcs("gd");
来找出可用的gd函数,并且我得到了一个' null'响应。我还检查了一下加载了什么ini文件(也返回null)。看来php模块运行得很薄(可以理解)。以下是我尝试过的事情:
我的经验是编写php应用程序代码,而不是环境配置。你有什么想法?您是否能够成功使用带有TideSDK的gd库?
我正在探索使用TideKit保留座位的可能性,但我正在进行探索性构建,以确保它能够完成我首先需要的所有工作。谢谢你的帮助!
答案 0 :(得分:1)
识别可移植的CLI(命令行)图像库,在我的例子中,这是ImageMagick。我能够通过Bash通过Ruby实现这一点。 “便携式”图像库将是: 一个。可以在没有安装在服务器上的情况下运行,即不需要名称路径才能正常运行 - 所以只要你知道“在哪里”,你就可以cd到那个目录,并让它工作 湾一个具有可接受的足迹。它不能太大,否则会导致您的应用程序大量下载。
示例代码:
### Bash installer for portable build of ImageMagick
#!/bin/bash
# change to scripts directory in Snicket application Contents path
echo "Installing ImageMagick…"
_APPDIR=$1
# _SCRIPTDIR=${1:-.}
_SCRIPTDIR="${_APPDIR}/Resources/scripts"
_HOME=${2:-${HOME}}
echo "Home -> ${_HOME}"
# Figure out directory absolute path
_TODIR=$_HOME/SnicketTools
mkdir $_TODIR
# remove previous installation
_MAGICK_DIR=$_TODIR/ImageMagick-6.8.9
echo "Removing existing directory -> ${_MAGICK_DIR}"
rm -r $_MAGICK_DIR
cd $_TODIR
tar xzvf "${_APPDIR}/Resources/tools/ImageMagick-x86_64-apple-darwin13.2.0.tar.gz"
#if [[ "$3" ]]; then
# #statements
# cp -r ./ImageMagick-6.8.9 $3/
#fi
# delete temporary copy of magic directory
## echo "Deleting temporary files from ${PWD}/ImageMagick-6.8.9 -> "
# rm -r ./ImageMagick-6.8.9
# open $_TODIR
echo "Magic directory (before export): ${_MAGICK_DIR}"
export MAGICK_HOME=$_MAGICK_DIR
echo "Magic directory: ${_MAGICK_DIR}"
echo "Magic home: ${MAGICK_HOME}"
## Clean profile file
_PROFILE=`cat ~/.bash_profile`
echo "Profile information -> ${_PROFILE}"
## You need to add export statements to ~/.bash_profile or ~/.profile
## or /etc/profile file. This will export variables permanently:
echo "# Snicket Magick Config" >> ~/.bash_profile
echo "export MAGICK_HOME=${_MAGICK_DIR}" >> ~/.bash_profile
echo "export PATH=$PATH:${MAGICK_HOME}/bin" >> ~/.bash_profile
echo "export DYLD_LIBRARY_PATH=${MAGICK_HOME}/lib/" >> ~/.bash_profile
echo "# End Snicket Magick Config" >> ~/.bash_profile
# Reload bash parameters
source ~/.bash_profile
## >> appends to an existing file
# source ~/.bash_profile
# check bash profile # open ~/.bash_profile
接下来,使用库运行基本图像转换的Bash脚本:
#!/bin/bash
## You MUST change to the magick directory before running in portable mode
# Use from within Ruby
# cmd = "bash #{$BASHDIR}/make_thumbnail.sh \"#{$MAGICK_HOME}#{$DS}bin\" \"#{img}\" \"#{tfile}\""
# cmd = "#{MAGICK_HOME}#{DS}bin#{DS}compress \"#{img}\" -resize 240x240\\> \"#{tfile}\""
_MAGICK_DIR=$1
_SRC=$2
_THUMB=$3
echo "Changing directory to -> ${_MAGICK_DIR}"
cd $_MAGICK_DIR
echo "Converting from ${_SRC} to ${_THUMB}"
source ~/.bash_profile
./convert "${_SRC}" -resize 240x240\> "${_THUMB}"