├── .devcontainer ├── Dockerfile ├── base.Dockerfile ├── devcontainer.json └── library-scripts │ ├── README.md │ ├── common-debian.sh │ └── node-debian.sh ├── .travis.yml ├── CONTRIBUTORS.md ├── LICENSE ├── README.md ├── config.m4 ├── config.w32 ├── gmagick.c ├── gmagick.stub.php ├── gmagick_arginfo.h ├── gmagick_helpers.c ├── gmagick_methods.c ├── gmagickdraw_methods.c ├── gmagickpixel_methods.c ├── package.xml ├── php_gmagick.h ├── php_gmagick_helpers.h ├── php_gmagick_macros.h ├── tests ├── Vera.ttf ├── bug63677.phpt ├── bug71626.phpt ├── bug_71742.phpt ├── gmagick-001-read_and_write.phpt ├── gmagick-002-crop_variations.phpt ├── gmagick-003-resize_variations.phpt ├── gmagick-004-composite_variations.phpt ├── gmagick-005-draw.phpt ├── gmagick-006-annotateimage.phpt ├── gmagick-007-blurimage.phpt ├── gmagick-008-addimage.phpt ├── gmagick-009-addimagenoise.phpt ├── gmagick-010-borderimage.phpt ├── gmagick-011-charcoalimage.phpt ├── gmagick-012-chopimage.phpt ├── gmagick-013-commentimage.phpt ├── gmagick-014-current.phpt ├── gmagick-015-cyclecolormapimage.phpt ├── gmagick-016-despeckleimage.phpt ├── gmagick-017-destroy.phpt ├── gmagick-018-edgeimage.phpt ├── gmagick-019-embossimage.phpt ├── gmagick-020-enhanceimage.phpt ├── gmagick-021-equalizeimage.phpt ├── gmagick-022-flip_and_flop_image.phpt ├── gmagick-023-gammaimage.phpt ├── gmagick-024-getcopyright_getfilename.phpt ├── gmagick-025-set_and_getimageckgroundcolor.phpt ├── gmagick-025-set_and_getimageckgroundcolor_q16.phpt ├── gmagick-026-set_getimageblueprimary.phpt ├── gmagick-027-set_getimagebordercolor.phpt ├── gmagick-027-set_getimagebordercolor_q16.phpt ├── gmagick-028-set_getimagechanneldepth.phpt ├── gmagick-029-set_getimagecolorspace.phpt ├── gmagick-030-getimagecolors.phpt ├── gmagick-031-set_getimagecompose.phpt ├── gmagick-032-set_getimagedelay.phpt ├── gmagick-033-set_getimagedepth.phpt ├── gmagick-034-set_getimagedispose.phpt ├── gmagick-035-set_getfilename.phpt ├── gmagick-036-set_getimagefilename.phpt ├── gmagick-037-set_getimagegamma.phpt ├── gmagick-038-setimagegreenprimary.phpt ├── gmagick-039-getimageheight.phpt ├── gmagick-040-getimagehistogram.phpt ├── gmagick-041-set_getimageinterlacescheme.phpt ├── gmagick-042-set_getimageiterations.phpt ├── gmagick-043-set_getimageprofile.phpt ├── gmagick-044-set_getimageredprimary.phpt ├── gmagick-045-set_getimagerenderingintent.phpt ├── gmagick-046-set_getimagerresolution.phpt ├── gmagick-047-set_getimagescene.phpt ├── gmagick-048-getimagesignature.phpt ├── gmagick-049-set_getimagetype.phpt ├── gmagick-050-set_getimageunits.phpt ├── gmagick-051-set_getimagewhitepoint.phpt ├── gmagick-052-getimagewidth.phpt ├── gmagick-053-getpackagename.phpt ├── gmagick-054-getquantumdepth.phpt ├── gmagick-055-getreleasedate.phpt ├── gmagick-056-set_getsamplingfactors.phpt ├── gmagick-057-set_getsize.phpt ├── gmagick-058-getversion.phpt ├── gmagick-059-hasnextimage.phpt ├── gmagick-060-haspreviousimage.phpt ├── gmagick-061-implodeimage.phpt ├── gmagick-062-labelimage.phpt ├── gmagick-063-levelimage.phpt ├── gmagick-064-magnifyimage.phpt ├── gmagick-065-mapimage.phpt ├── gmagick-066-medianfilterimage.phpt ├── gmagick-067-minifyimage.phpt ├── gmagick-068-modulateimage.phpt ├── gmagick-069-trimimage.phpt ├── gmagick-070-motionblurimage.phpt ├── gmagick-071-next_previousimage.phpt ├── gmagick-072-oilpaintimage.phpt ├── gmagick-073-profileimage.phpt ├── gmagick-074-quantizeimage.phpt ├── gmagick-075-quantizeimages.phpt ├── gmagick-076-queryfonts.phpt ├── gmagick-077-cropthumbnail.phpt ├── gmagick-078-rollimage.phpt ├── gmagick-079-rotateimage.phpt ├── gmagick-080-scaleimage.phpt ├── gmagick-081-separateimagechannel.phpt ├── gmagick-082-shearimage.phpt ├── gmagick-083-solarizeimage.phpt ├── gmagick-084-spreadimage.phpt ├── gmagick-085-stripimage.phpt ├── gmagick-086-swirlimage.phpt ├── gmagick-087-setcompressionquality.phpt ├── gmagick-088-getimageblob.phpt ├── gmagick-089-getnumberimages.phpt ├── gmagick-090-setimage.phpt ├── gmagick-091-getimage.phpt ├── gmagick-092-getimagegeometry.phpt ├── gmagick-093-flattenimages.phpt ├── gmagick-094-thresholdimage.phpt ├── gmagick-095-negateimage.phpt ├── gmagick-096-setinterlacescheme.phpt ├── gmagick-097-sampleimage.phpt ├── gmagick-098-cloneimage.phpt ├── gmagick-099-appendimages.phpt ├── gmagick-100-coalesceimages.phpt ├── gmagick-101-sharpenimage.phpt ├── gmagick-102-unsharpenmaskimage.phpt ├── gmagick-103-setgetimagecompression.phpt ├── gmagick-104-setgetimagepage.phpt ├── gmagick-105-readimageblob.phpt ├── gmagick-106-testConstants.phpt ├── gmagick-107_setimagevirtualpixelmethod.phpt ├── gmagick-108_adaptiveThresholdImage_basic.phpt ├── gmagick-109_affineTransformImage_basic.phpt ├── gmagick-110_blackThresholdImage_basic.phpt ├── gmagick-111_whiteThresholdImage_basic.phpt ├── gmagick-112_colorizeImage_basic.phpt ├── gmagick-113_compareImages.phpt ├── gmagick-114_convolveImage_6.phpt ├── gmagick-115_equalizeImage_case2.phpt ├── gmagick-116_waveImage_basic.phpt ├── gmagick-117_haldClutImage_basic.phpt ├── gmagick-118_shaveImage_basic.phpt ├── gmagick-119_thumbnail_fill.phpt ├── gmagick-120_writeImageFile.phpt ├── gmagick-121_deconstructGif_basic.phpt ├── gmagick-122_unsharpMaskImage_basic.phpt ├── gmagick-123_sharpenImage_basic.phpt ├── gmagick-124__reduceNoiseImage_basic.phpt ├── gmagick-125_radialBlurImage_basic.phpt ├── gmagick-126_negateImage_basic.phpt ├── gmagick-127_contrastImage_basic.phpt ├── gmagick-128_staticMethods.phpt ├── gmagick-129_gettersAndSetters.phpt ├── gmagick-130-reflection.phpt ├── gmagickdraw-001-setstrokecolor_setstrokewidth.phpt ├── gmagickdraw-002-ellipse.phpt ├── gmagickdraw-003-annotate.phpt ├── gmagickdraw-004-arc.phpt ├── gmagickdraw-005-bezier.phpt ├── gmagickdraw-006-setfillcolor_getfillcolor.phpt ├── gmagickdraw-006-setfillcolor_getfillcolor_q16.phpt ├── gmagickdraw-007-setfillopacity_getfillopacity.phpt ├── gmagickdraw-008-setfont_getfont.phpt ├── gmagickdraw-009-setfontsize_getfontsize.phpt ├── gmagickdraw-010-setfontstyle_getfontstyle.phpt ├── gmagickdraw-011-setfontweight_getfontweight.phpt ├── gmagickdraw-012-setstrokeopacity_getstrokeopacity.phpt ├── gmagickdraw-013-setstrokecolor_getstrokecolor.phpt ├── gmagickdraw-013-setstrokecolor_getstrokecolor_q16.phpt ├── gmagickdraw-014-setstrokewidth_getstrokewidth.phpt ├── gmagickdraw-015-settextdecoration_gettextdecoration.phpt ├── gmagickdraw-016-settextencoding_gettextencoding.phpt ├── gmagickdraw-017-line.phpt ├── gmagickdraw-018-point.phpt ├── gmagickdraw-019-polygon.phpt ├── gmagickdraw-020-polyline.phpt ├── gmagickdraw-021-rectangle.phpt ├── gmagickdraw-022-rotate.phpt ├── gmagickdraw-023-roundrectangle.phpt ├── gmagickdraw-024-scale.phpt ├── gmagickdraw-025-affine.phpt ├── gmagickdraw-026-setgravity_getgravity.phpt ├── gmagickdraw-027-setantialias_getantialias.phpt ├── gmagickdraw-028-setlinecap_getlinecap.phpt ├── gmagickdraw-029-setlinejoin_getlinejoin.phpt ├── gmagickdraw-030-setmiterlimit_getmiterlimit.phpt ├── gmagickdraw-031-setdashstrokearray_getdashstrokearray.phpt ├── gmagickdraw-032_circle_basic.phpt ├── gmagickdraw-033_setClipPath_basic.phpt ├── gmagickdraw_034_setClipRule_basic.phpt ├── gmagickdraw_035_setClipUnits_basic.phpt ├── gmagickdraw_036_pushPattern_basic.phpt ├── gmagickdraw_037_setFillRule_basic.phpt ├── gmagickdraw_038_setFontStretch_basic.phpt ├── gmagickdraw_039_pathStart_basic.phpt ├── gmagickdraw_040_pathCurveToQuadraticBezierAbsolute_basic.phpt ├── gmagickdraw_041_popDefs_basic.phpt ├── gmagickdraw_042_setTextAntialias_basic.phpt ├── gmagickdraw_043_setViewBox_basic.phpt ├── gmagickdraw_044_setTextUnderColor_basic.phpt ├── gmagickdraw_045_setFontFamily_basic.phpt ├── gmagickpixel-001-setcolor_getcolor.phpt ├── gmagickpixel-002-setcolorvalue_getcolorvalue.phpt ├── gmagickpixel-003-getcolorcount.phpt ├── gmagickpixel-004-clone.phpt ├── gmagickpixel-005-setcolorvaluequantum_getcolorvaluequantum.phpt ├── gmagickpixel-006-setcolorcount.phpt ├── hald_8.png └── skipif.inc └── util ├── configure_cflags.sh ├── gmagick-check-loaded.phpt ├── graphicsmagick_dependency.sh └── scanHeaders.php /.devcontainer/Dockerfile: -------------------------------------------------------------------------------- 1 | # [Choice] PHP version: 8, 8.0, 7, 7.4, 7.3 2 | ARG VARIANT=7 3 | FROM mcr.microsoft.com/vscode/devcontainers/php:${VARIANT} 4 | 5 | # [Option] Install Node.js 6 | ARG INSTALL_NODE="true" 7 | ARG NODE_VERSION="lts/*" 8 | RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi 9 | 10 | # [Optional] Uncomment this section to install additional OS packages. 11 | # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ 12 | # && apt-get -y install --no-install-recommends 13 | 14 | # [Optional] Uncomment this line to install global node packages. 15 | # RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g " 2>&1 16 | 17 | ARG GM_VERSION='1.3.36' 18 | 19 | WORKDIR /tmp 20 | RUN wget https://sourceforge.net/projects/graphicsmagick/files/graphicsmagick/${GM_VERSION}/GraphicsMagick-${GM_VERSION}.tar.gz/download && \ 21 | tar -xvzf download && \ 22 | cd GraphicsMagick-${GM_VERSION} && \ 23 | ./configure --enable-shared --disable-dependency-tracking && \ 24 | make && \ 25 | make install && \ 26 | pwd 27 | #RUN cd GraphicsMagick-${GM_VERSION} 28 | #RUN ./configure --enable-shared --disable-dependency-tracking 29 | #RUN make 30 | #RUN make install -------------------------------------------------------------------------------- /.devcontainer/base.Dockerfile: -------------------------------------------------------------------------------- 1 | # [Choice] PHP version: 8, 8.0, 7, 7.4, 7.3 2 | ARG VARIANT=7 3 | FROM php:${VARIANT}-apache 4 | 5 | # [Option] Install zsh 6 | ARG INSTALL_ZSH="true" 7 | # [Option] Upgrade OS packages to their latest versions 8 | ARG UPGRADE_PACKAGES="true" 9 | 10 | # Install needed packages and setup non-root user. Use a separate RUN statement to add your own dependencies. 11 | ARG USERNAME=vscode 12 | ARG USER_UID=1000 13 | ARG USER_GID=$USER_UID 14 | COPY library-scripts/common-debian.sh /tmp/library-scripts/ 15 | RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ 16 | && bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" \ 17 | && apt-get -y install --no-install-recommends lynx \ 18 | && usermod -aG www-data ${USERNAME} \ 19 | && sed -i -e "s/Listen 80/Listen 80\\nListen 8080/g" /etc/apache2/ports.conf \ 20 | && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts 21 | 22 | # Install xdebug 23 | RUN yes | pecl install xdebug \ 24 | && echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \ 25 | && echo "xdebug.mode = debug" >> /usr/local/etc/php/conf.d/xdebug.ini \ 26 | && echo "xdebug.start_with_request = yes" >> /usr/local/etc/php/conf.d/xdebug.ini \ 27 | && echo "xdebug.client_port = 9000" >> /usr/local/etc/php/conf.d/xdebug.ini \ 28 | && rm -rf /tmp/pear 29 | 30 | # Install composer 31 | RUN curl -sSL https://getcomposer.org/installer | php \ 32 | && chmod +x composer.phar \ 33 | && mv composer.phar /usr/local/bin/composer 34 | 35 | # [Option] Install Node.js 36 | ARG INSTALL_NODE="true" 37 | ARG NODE_VERSION="none" 38 | ENV NVM_DIR=/usr/local/share/nvm 39 | ENV NVM_SYMLINK_CURRENT=true \ 40 | PATH=${NVM_DIR}/current/bin:${PATH} 41 | COPY library-scripts/node-debian.sh /tmp/library-scripts/ 42 | RUN if [ "$INSTALL_NODE" = "true" ]; then /bin/bash /tmp/library-scripts/node-debian.sh "${NVM_DIR}" "${NODE_VERSION}" "${USERNAME}"; fi \ 43 | && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts 44 | 45 | # [Optional] Uncomment this section to install additional packages. 46 | # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ 47 | # && apt-get -y install --no-install-recommends 48 | 49 | -------------------------------------------------------------------------------- /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "PHP", 3 | "build": { 4 | "dockerfile": "Dockerfile", 5 | "args": { 6 | // Update VARIANT to pick a PHP version: 8, 8.0, 7, 7.4, 7.3 7 | "VARIANT": "8", 8 | "INSTALL_NODE": "true", 9 | "NODE_VERSION": "lts/*" 10 | } 11 | }, 12 | 13 | // Set *default* container specific settings.json values on container create. 14 | "settings": { 15 | "terminal.integrated.shell.linux": "/bin/bash", 16 | "php.validate.executablePath": "/usr/local/bin/php" 17 | }, 18 | 19 | // Add the IDs of extensions you want installed when the container is created. 20 | "extensions": [ 21 | "felixfbecker.php-debug", 22 | "bmewburn.vscode-intelephense-client", 23 | "mrmlnc.vscode-apache" 24 | ], 25 | 26 | // Use 'forwardPorts' to make a list of ports inside the container available locally. 27 | "forwardPorts": [8080], 28 | 29 | // Use 'postCreateCommand' to run commands after the container is created. 30 | // "postCreateCommand": "sudo chmod a+x \"$(pwd)\" && sudo rm -rf /var/www/html && sudo ln -s \"$(pwd)\" /var/www/html" 31 | 32 | // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. 33 | "remoteUser": "vscode" 34 | } 35 | -------------------------------------------------------------------------------- /.devcontainer/library-scripts/README.md: -------------------------------------------------------------------------------- 1 | # Warning: Folder contents may be replaced 2 | 3 | The contents of this folder will be automatically replaced with a file of the same name in the [vscode-dev-containers](https://github.com/microsoft/vscode-dev-containers) repository's [script-library folder](https://github.com/microsoft/vscode-dev-containers/tree/master/script-library) whenever the repository is packaged. 4 | 5 | To retain your edits, move the file to a different location. You may also delete the files if they are not needed. -------------------------------------------------------------------------------- /.devcontainer/library-scripts/common-debian.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #------------------------------------------------------------------------------------------------------------- 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. 5 | #------------------------------------------------------------------------------------------------------------- 6 | # 7 | # Docs: https://github.com/microsoft/vscode-dev-containers/blob/master/script-library/docs/common.md 8 | # 9 | # Syntax: ./common-debian.sh [install zsh flag] [username] [user UID] [user GID] [upgrade packages flag] [install Oh My *! flag] 10 | 11 | INSTALL_ZSH=${1:-"true"} 12 | USERNAME=${2:-"automatic"} 13 | USER_UID=${3:-"automatic"} 14 | USER_GID=${4:-"automatic"} 15 | UPGRADE_PACKAGES=${5:-"true"} 16 | INSTALL_OH_MYS=${6:-"true"} 17 | 18 | set -e 19 | 20 | if [ "$(id -u)" -ne 0 ]; then 21 | echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' 22 | exit 1 23 | fi 24 | 25 | # Ensure that login shells get the correct path if the user updated the PATH using ENV. 26 | rm -f /etc/profile.d/00-restore-env.sh 27 | echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\$PATH}" > /etc/profile.d/00-restore-env.sh 28 | chmod +x /etc/profile.d/00-restore-env.sh 29 | 30 | # If in automatic mode, determine if a user already exists, if not use vscode 31 | if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then 32 | USERNAME="" 33 | POSSIBLE_USERS=("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)") 34 | for CURRENT_USER in ${POSSIBLE_USERS[@]}; do 35 | if id -u ${CURRENT_USER} > /dev/null 2>&1; then 36 | USERNAME=${CURRENT_USER} 37 | break 38 | fi 39 | done 40 | if [ "${USERNAME}" = "" ]; then 41 | USERNAME=vscode 42 | fi 43 | elif [ "${USERNAME}" = "none" ]; then 44 | USERNAME=root 45 | USER_UID=0 46 | USER_GID=0 47 | fi 48 | 49 | # Load markers to see which steps have already run 50 | MARKER_FILE="/usr/local/etc/vscode-dev-containers/common" 51 | if [ -f "${MARKER_FILE}" ]; then 52 | echo "Marker file found:" 53 | cat "${MARKER_FILE}" 54 | source "${MARKER_FILE}" 55 | fi 56 | 57 | # Ensure apt is in non-interactive to avoid prompts 58 | export DEBIAN_FRONTEND=noninteractive 59 | 60 | # Function to call apt-get if needed 61 | apt-get-update-if-needed() 62 | { 63 | if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then 64 | echo "Running apt-get update..." 65 | apt-get update 66 | else 67 | echo "Skipping apt-get update." 68 | fi 69 | } 70 | 71 | # Run install apt-utils to avoid debconf warning then verify presence of other common developer tools and dependencies 72 | if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then 73 | apt-get-update-if-needed 74 | 75 | PACKAGE_LIST="apt-utils \ 76 | git \ 77 | openssh-client \ 78 | gnupg2 \ 79 | iproute2 \ 80 | procps \ 81 | lsof \ 82 | htop \ 83 | net-tools \ 84 | psmisc \ 85 | curl \ 86 | wget \ 87 | rsync \ 88 | ca-certificates \ 89 | unzip \ 90 | zip \ 91 | nano \ 92 | vim-tiny \ 93 | less \ 94 | jq \ 95 | lsb-release \ 96 | apt-transport-https \ 97 | dialog \ 98 | libc6 \ 99 | libgcc1 \ 100 | libkrb5-3 \ 101 | libgssapi-krb5-2 \ 102 | libicu[0-9][0-9] \ 103 | liblttng-ust0 \ 104 | libstdc++6 \ 105 | zlib1g \ 106 | locales \ 107 | sudo \ 108 | ncdu \ 109 | man-db \ 110 | strace" 111 | 112 | # Install libssl1.1 if available 113 | if [[ ! -z $(apt-cache --names-only search ^libssl1.1$) ]]; then 114 | PACKAGE_LIST="${PACKAGE_LIST} libssl1.1" 115 | fi 116 | 117 | # Install appropriate version of libssl1.0.x if available 118 | LIBSSL=$(dpkg-query -f '${db:Status-Abbrev}\t${binary:Package}\n' -W 'libssl1\.0\.?' 2>&1 || echo '') 119 | if [ "$(echo "$LIBSSL" | grep -o 'libssl1\.0\.[0-9]:' | uniq | sort | wc -l)" -eq 0 ]; then 120 | if [[ ! -z $(apt-cache --names-only search ^libssl1.0.2$) ]]; then 121 | # Debian 9 122 | PACKAGE_LIST="${PACKAGE_LIST} libssl1.0.2" 123 | elif [[ ! -z $(apt-cache --names-only search ^libssl1.0.0$) ]]; then 124 | # Ubuntu 18.04, 16.04, earlier 125 | PACKAGE_LIST="${PACKAGE_LIST} libssl1.0.0" 126 | fi 127 | fi 128 | 129 | echo "Packages to verify are installed: ${PACKAGE_LIST}" 130 | apt-get -y install --no-install-recommends ${PACKAGE_LIST} 2> >( grep -v 'debconf: delaying package configuration, since apt-utils is not installed' >&2 ) 131 | 132 | PACKAGES_ALREADY_INSTALLED="true" 133 | fi 134 | 135 | # Get to latest versions of all packages 136 | if [ "${UPGRADE_PACKAGES}" = "true" ]; then 137 | apt-get-update-if-needed 138 | apt-get -y upgrade --no-install-recommends 139 | apt-get autoremove -y 140 | fi 141 | 142 | # Ensure at least the en_US.UTF-8 UTF-8 locale is available. 143 | # Common need for both applications and things like the agnoster ZSH theme. 144 | if [ "${LOCALE_ALREADY_SET}" != "true" ] && ! grep -o -E '^\s*en_US.UTF-8\s+UTF-8' /etc/locale.gen > /dev/null; then 145 | echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen 146 | locale-gen 147 | LOCALE_ALREADY_SET="true" 148 | fi 149 | 150 | # Create or update a non-root user to match UID/GID. 151 | if id -u ${USERNAME} > /dev/null 2>&1; then 152 | # User exists, update if needed 153 | if [ "${USER_GID}" != "automatic" ] && [ "$USER_GID" != "$(id -G $USERNAME)" ]; then 154 | groupmod --gid $USER_GID $USERNAME 155 | usermod --gid $USER_GID $USERNAME 156 | fi 157 | if [ "${USER_UID}" != "automatic" ] && [ "$USER_UID" != "$(id -u $USERNAME)" ]; then 158 | usermod --uid $USER_UID $USERNAME 159 | fi 160 | else 161 | # Create user 162 | if [ "${USER_GID}" = "automatic" ]; then 163 | groupadd $USERNAME 164 | else 165 | groupadd --gid $USER_GID $USERNAME 166 | fi 167 | if [ "${USER_UID}" = "automatic" ]; then 168 | useradd -s /bin/bash --gid $USERNAME -m $USERNAME 169 | else 170 | useradd -s /bin/bash --uid $USER_UID --gid $USERNAME -m $USERNAME 171 | fi 172 | fi 173 | 174 | # Add add sudo support for non-root user 175 | if [ "${USERNAME}" != "root" ] && [ "${EXISTING_NON_ROOT_USER}" != "${USERNAME}" ]; then 176 | echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME 177 | chmod 0440 /etc/sudoers.d/$USERNAME 178 | EXISTING_NON_ROOT_USER="${USERNAME}" 179 | fi 180 | 181 | # ** Shell customization section ** 182 | if [ "${USERNAME}" = "root" ]; then 183 | USER_RC_PATH="/root" 184 | else 185 | USER_RC_PATH="/home/${USERNAME}" 186 | fi 187 | 188 | # .bashrc/.zshrc snippet 189 | RC_SNIPPET="$(cat << EOF 190 | export USER=\$(whoami) 191 | if [[ "\${PATH}" != *"\$HOME/.local/bin"* ]]; then export PATH="\${PATH}:\$HOME/.local/bin"; fi 192 | EOF 193 | )" 194 | 195 | # code shim, it fallbacks to code-insiders if code is not available 196 | cat << 'EOF' > /usr/local/bin/code 197 | #!/bin/sh 198 | 199 | get_in_path_except_current() { 200 | which -a "$1" | grep -A1 "$0" | grep -v "$0" 201 | } 202 | 203 | code="$(get_in_path_except_current code)" 204 | 205 | if [ -n "$code" ]; then 206 | exec "$code" "$@" 207 | elif [ "$(command -v code-insiders)" ]; then 208 | exec code-insiders "$@" 209 | else 210 | echo "code or code-insiders is not installed" >&2 211 | exit 127 212 | fi 213 | EOF 214 | chmod +x /usr/local/bin/code 215 | 216 | # Codespaces themes - partly inspired by https://github.com/ohmyzsh/ohmyzsh/blob/master/themes/robbyrussell.zsh-theme 217 | CODESPACES_BASH="$(cat \ 218 | <&1 292 | echo -e "$(cat "${TEMPLATE}")\nDISABLE_AUTO_UPDATE=true\nDISABLE_UPDATE_PROMPT=true" > ${USER_RC_FILE} 293 | if [ "${OH_MY}" = "bash" ]; then 294 | sed -i -e 's/OSH_THEME=.*/OSH_THEME="codespaces"/g' ${USER_RC_FILE} 295 | mkdir -p ${OH_MY_INSTALL_DIR}/custom/themes/codespaces 296 | echo "${CODESPACES_BASH}" > ${OH_MY_INSTALL_DIR}/custom/themes/codespaces/codespaces.theme.sh 297 | else 298 | sed -i -e 's/ZSH_THEME=.*/ZSH_THEME="codespaces"/g' ${USER_RC_FILE} 299 | mkdir -p ${OH_MY_INSTALL_DIR}/custom/themes 300 | echo "${CODESPACES_ZSH}" > ${OH_MY_INSTALL_DIR}/custom/themes/codespaces.zsh-theme 301 | fi 302 | # Shrink git while still enabling updates 303 | cd ${OH_MY_INSTALL_DIR} 304 | git repack -a -d -f --depth=1 --window=1 305 | 306 | if [ "${USERNAME}" != "root" ]; then 307 | cp -rf ${USER_RC_FILE} ${OH_MY_INSTALL_DIR} /root 308 | chown -R ${USERNAME}:${USERNAME} ${USER_RC_PATH} 309 | fi 310 | } 311 | 312 | if [ "${RC_SNIPPET_ALREADY_ADDED}" != "true" ]; then 313 | echo "${RC_SNIPPET}" >> /etc/bash.bashrc 314 | RC_SNIPPET_ALREADY_ADDED="true" 315 | fi 316 | install-oh-my bash bashrc.osh-template https://github.com/ohmybash/oh-my-bash 317 | 318 | # Optionally install and configure zsh and Oh My Zsh! 319 | if [ "${INSTALL_ZSH}" = "true" ]; then 320 | if ! type zsh > /dev/null 2>&1; then 321 | apt-get-update-if-needed 322 | apt-get install -y zsh 323 | fi 324 | if [ "${ZSH_ALREADY_INSTALLED}" != "true" ]; then 325 | echo "${RC_SNIPPET}" >> /etc/zsh/zshrc 326 | ZSH_ALREADY_INSTALLED="true" 327 | fi 328 | install-oh-my zsh zshrc.zsh-template https://github.com/ohmyzsh/ohmyzsh 329 | fi 330 | 331 | # Write marker file 332 | mkdir -p "$(dirname "${MARKER_FILE}")" 333 | echo -e "\ 334 | PACKAGES_ALREADY_INSTALLED=${PACKAGES_ALREADY_INSTALLED}\n\ 335 | LOCALE_ALREADY_SET=${LOCALE_ALREADY_SET}\n\ 336 | EXISTING_NON_ROOT_USER=${EXISTING_NON_ROOT_USER}\n\ 337 | RC_SNIPPET_ALREADY_ADDED=${RC_SNIPPET_ALREADY_ADDED}\n\ 338 | ZSH_ALREADY_INSTALLED=${ZSH_ALREADY_INSTALLED}" > "${MARKER_FILE}" 339 | 340 | echo "Done!" 341 | -------------------------------------------------------------------------------- /.devcontainer/library-scripts/node-debian.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #------------------------------------------------------------------------------------------------------------- 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. 5 | #------------------------------------------------------------------------------------------------------------- 6 | # 7 | # Docs: https://github.com/microsoft/vscode-dev-containers/blob/master/script-library/docs/node.md 8 | # 9 | # Syntax: ./node-debian.sh [directory to install nvm] [node version to install (use "none" to skip)] [non-root user] [Update rc files flag] 10 | 11 | export NVM_DIR=${1:-"/usr/local/share/nvm"} 12 | export NODE_VERSION=${2:-"lts/*"} 13 | USERNAME=${3:-"automatic"} 14 | UPDATE_RC=${4:-"true"} 15 | 16 | set -e 17 | 18 | if [ "$(id -u)" -ne 0 ]; then 19 | echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' 20 | exit 1 21 | fi 22 | 23 | # Ensure that login shells get the correct path if the user updated the PATH using ENV. 24 | rm -f /etc/profile.d/00-restore-env.sh 25 | echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\$PATH}" > /etc/profile.d/00-restore-env.sh 26 | chmod +x /etc/profile.d/00-restore-env.sh 27 | 28 | # Determine the appropriate non-root user 29 | if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then 30 | USERNAME="" 31 | POSSIBLE_USERS=("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)") 32 | for CURRENT_USER in ${POSSIBLE_USERS[@]}; do 33 | if id -u ${CURRENT_USER} > /dev/null 2>&1; then 34 | USERNAME=${CURRENT_USER} 35 | break 36 | fi 37 | done 38 | if [ "${USERNAME}" = "" ]; then 39 | USERNAME=root 40 | fi 41 | elif [ "${USERNAME}" = "none" ] || ! id -u ${USERNAME} > /dev/null 2>&1; then 42 | USERNAME=root 43 | fi 44 | 45 | if [ "${NODE_VERSION}" = "none" ]; then 46 | export NODE_VERSION= 47 | fi 48 | 49 | # Ensure apt is in non-interactive to avoid prompts 50 | export DEBIAN_FRONTEND=noninteractive 51 | 52 | # Install curl, apt-transport-https, tar, or gpg if missing 53 | if ! dpkg -s apt-transport-https curl ca-certificates tar > /dev/null 2>&1 || ! type gpg > /dev/null 2>&1; then 54 | if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then 55 | apt-get update 56 | fi 57 | apt-get -y install --no-install-recommends apt-transport-https curl ca-certificates tar gnupg2 58 | fi 59 | 60 | # Install yarn 61 | if type yarn > /dev/null 2>&1; then 62 | echo "Yarn already installed." 63 | else 64 | curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | (OUT=$(apt-key add - 2>&1) || echo $OUT) 65 | echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list 66 | apt-get update 67 | apt-get -y install --no-install-recommends yarn 68 | fi 69 | 70 | # Install the specified node version if NVM directory already exists, then exit 71 | if [ -d "${NVM_DIR}" ]; then 72 | echo "NVM already installed." 73 | if [ "${NODE_VERSION}" != "" ]; then 74 | su ${USERNAME} -c ". $NVM_DIR/nvm.sh && nvm install ${NODE_VERSION} && nvm clear-cache" 75 | fi 76 | exit 0 77 | fi 78 | 79 | # Create nvm group, nvm dir, and set sticky bit 80 | if ! cat /etc/group | grep -e "^nvm:" > /dev/null 2>&1; then 81 | groupadd -r nvm 82 | fi 83 | umask 0002 84 | usermod -a -G nvm ${USERNAME} 85 | mkdir -p ${NVM_DIR} 86 | chown :nvm ${NVM_DIR} 87 | chmod g+s ${NVM_DIR} 88 | su ${USERNAME} -c "$(cat << EOF 89 | set -e 90 | umask 0002 91 | # Do not update profile - we'll do this manually 92 | export PROFILE=/dev/null 93 | curl -so- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash 94 | source ${NVM_DIR}/nvm.sh 95 | if [ "${NODE_VERSION}" != "" ]; then 96 | nvm alias default ${NODE_VERSION} 97 | fi 98 | nvm clear-cache 99 | EOF 100 | )" 2>&1 101 | # Update rc files 102 | if [ "${UPDATE_RC}" = "true" ]; then 103 | echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc with NVM scripts..." 104 | (cat <> /etc/zsh/zshrc 110 | fi 111 | 112 | echo "Done!" -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | 3 | sudo: false 4 | 5 | cache: 6 | directories: 7 | - $HOME/gm 8 | 9 | php: 10 | - 7.0 11 | # - 5.6 12 | 13 | 14 | env: 15 | - GRAPHICSMAGICK_VERSION=dev QUANTUM=8 16 | - GRAPHICSMAGICK_VERSION=1.3.23 QUANTUM=8 17 | - GRAPHICSMAGICK_VERSION=1.3.22 QUANTUM=8 18 | - GRAPHICSMAGICK_VERSION=1.3.20 QUANTUM=8 19 | - GRAPHICSMAGICK_VERSION=1.3.17 QUANTUM=8 20 | - GRAPHICSMAGICK_VERSION=dev QUANTUM=16 21 | - GRAPHICSMAGICK_VERSION=1.3.23 QUANTUM=16 22 | - GRAPHICSMAGICK_VERSION=1.3.22 QUANTUM=16 23 | - GRAPHICSMAGICK_VERSION=1.3.20 QUANTUM=16 24 | - GRAPHICSMAGICK_VERSION=1.3.17 QUANTUM=16 25 | # For Github, you can include individual commits like this: 26 | # - GRAPHICSMAGICK_VERSION=commit_25553302a6d5f736b55e60109600dfbce5fbea48 27 | # not implemented for mercurial yet. 28 | 29 | 30 | 31 | # If known versions are bad, don't build them. 32 | #matrix: 33 | # exclude: 34 | # - php: 5.3 35 | # env: GRAPHICSMAGICK_VERSION=6.8.7-0 36 | 37 | 38 | before_script: 39 | - for file in tests/*.phpt; do grep $(basename $file) package.xml >/dev/null || (echo "Missing $file from package.xml" ; exit 1); done 40 | - bash ./util/graphicsmagick_dependency.sh "${GRAPHICSMAGICK_VERSION}" "${QUANTUM}" 41 | 42 | script: 43 | - export NO_INTERACTION=1 44 | - export REPORT_EXIT_STATUS=1 45 | - export SKIP_SLOW_TESTS=1 46 | - export TEST_PHP_EXECUTABLE=`which php` 47 | - export PHP_GMAGICK_VERSION=$(php -r '$sxe = simplexml_load_file ("package.xml"); echo (string) $sxe->version->release;') 48 | - . ./util/configure_cflags.sh 49 | - phpize 50 | - ./configure --with-gmagick="${HOME}/gm/graphicsmagick_${GRAPHICSMAGICK_VERSION}_${QUANTUM}" 51 | - make 52 | - php run-tests.php -d extension=gmagick.so -d extension_dir=modules -n ./util/gmagick-check-loaded.phpt 53 | - php run-tests.php -d extension=gmagick.so -d extension_dir=modules -n ./tests/*.phpt 54 | - for i in `ls tests/*.out 2>/dev/null`; do echo "-- START ${i}"; cat $i; echo "-- END"; done 55 | 56 | # 57 | #matrix: 58 | # allow_failures: 59 | # - env: GRAPHICSMAGICK_VERSION=git6 60 | # - env: GRAPHICSMAGICK_VERSION=git7 61 | -------------------------------------------------------------------------------- /CONTRIBUTORS.md: -------------------------------------------------------------------------------- 1 | Contributors 2 | ============ 3 | 4 | These people have contributed to Gmagick's code: 5 | 6 | * Anatol Belski (weltling) 7 | * Dan Ackroyd (danack) 8 | * Will Gallego (wcgallego) 9 | * jecknig 10 | * Kenton Jacobsen (brokentone) 11 | * Vito Chin (vitoc) 12 | * Mikko Koppanen (mkoppanen) 13 | * Remi Collet (remicollet) 14 | * Rasmus Lerdorf (rlerdorf) 15 | 16 | Please create a pull request on this file if there is anyone missed. -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------- 2 | The PHP License, version 3.01 3 | Copyright (c) 1999 - 2009 The PHP Group. All rights reserved. 4 | -------------------------------------------------------------------- 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, is permitted provided that the following conditions 8 | are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in 15 | the documentation and/or other materials provided with the 16 | distribution. 17 | 18 | 3. The name "PHP" must not be used to endorse or promote products 19 | derived from this software without prior written permission. For 20 | written permission, please contact group@php.net. 21 | 22 | 4. Products derived from this software may not be called "PHP", nor 23 | may "PHP" appear in their name, without prior written permission 24 | from group@php.net. You may indicate that your software works in 25 | conjunction with PHP by saying "Foo for PHP" instead of calling 26 | it "PHP Foo" or "phpfoo" 27 | 28 | 5. The PHP Group may publish revised and/or new versions of the 29 | license from time to time. Each version will be given a 30 | distinguishing version number. 31 | Once covered code has been published under a particular version 32 | of the license, you may always continue to use it under the terms 33 | of that version. You may also choose to use such covered code 34 | under the terms of any subsequent version of the license 35 | published by the PHP Group. No one other than the PHP Group has 36 | the right to modify the terms applicable to covered code created 37 | under this License. 38 | 39 | 6. Redistributions of any form whatsoever must retain the following 40 | acknowledgment: 41 | "This product includes PHP software, freely available from 42 | ". 43 | 44 | THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND 45 | ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 46 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 47 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP 48 | DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 49 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 50 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 51 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 52 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 53 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 54 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 55 | OF THE POSSIBILITY OF SUCH DAMAGE. 56 | 57 | -------------------------------------------------------------------- 58 | 59 | This software consists of voluntary contributions made by many 60 | individuals on behalf of the PHP Group. 61 | 62 | The PHP Group can be contacted via Email at group@php.net. 63 | 64 | For more information on the PHP Group and the PHP project, 65 | please see . 66 | 67 | PHP includes the Zend Engine, freely available at 68 | . 69 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Gmagick 2 | ======= 3 | Copyright (c) 2009 Vito Chin, Mikko Koppanen 4 | 5 | PHP extension that wraps the GraphicsMagick library. Access GraphicsMagick's capabilities via PHP. 6 | 7 | [![Build Status](https://travis-ci.org/vitoc/gmagick.svg?branch=master)](https://travis-ci.org/vitoc/gmagick) 8 | 9 | Getting Started 10 | =============== 11 | 12 | 1. Install GraphicsMagick 13 | 14 | Download the stable from from http://www.graphicsmagick.org and build with --enable-shared option. If you do not need to work with perl, --without-perl. 15 | 16 | Remember to run ldconfig after building GraphicsMagick to update shared library cache for immediate use. 17 | 18 | 2. Install Gmagick 19 | 20 | Typically, as with most extensions: 21 | 22 | $ phpize 23 | $ ./configure 24 | $ make 25 | $ make install 26 | 27 | Functions not supported 28 | ======================= 29 | 30 | The functions listed below are deliberately not part of the Gmagick extension. Other functions that are present in the GraphicsMagick library but not exposed by Gmagick are likely to be added in the future. 31 | 32 | MagickAnimateImages - only useful with X terminals. 33 | MagickDisplayImage - only useful with X terminals. 34 | MagickDisplayImages - only useful with X terminals. 35 | MagickGetConfigureInfo - not implemented in GraphicsMagick 36 | MagickFxImage - not implemented in GraphicsMagick 37 | MagickFxImageChannel - not implemented in GraphicsMagick 38 | MagickGetImageSize - just get the image a string and do strlen 39 | MagickPreviewImages - not implemented in GraphicsMagick 40 | MagickSetPassphrase - use real encryption if you need to protect data 41 | MagickTintImage - not implemented in GraphicsMagick 42 | MagickTransformImage - this is a 'helper' function which duplicates other easier to use functions. 43 | -------------------------------------------------------------------------------- /config.m4: -------------------------------------------------------------------------------- 1 | PHP_ARG_WITH(gmagick, whether to enable the gmagick extension, 2 | [ --with-gmagick[=DIR] Enables the gmagick extension. DIR is the prefix to GraphicsMagick installation directory.], no) 3 | 4 | if test $PHP_GMAGICK != "no"; then 5 | 6 | AC_MSG_CHECKING(GraphicsMagick configuration program) 7 | 8 | for i in $PHP_GMAGICK /usr/local /usr; 9 | do 10 | test -r $i/bin/GraphicsMagick-config && WAND_BINARY=$i/bin/GraphicsMagick-config && break 11 | done 12 | 13 | if test -z "$WAND_BINARY"; then 14 | AC_MSG_ERROR(not found. Please provide a path to GraphicsMagick-config program.) 15 | fi 16 | 17 | AC_MSG_RESULT(found in $WAND_BINARY) 18 | 19 | AC_MSG_CHECKING(GraphicsMagick version) 20 | WAND_DIR=`$WAND_BINARY --prefix` 21 | 22 | GRAPHICSMAGICK_VERSION_ORIG=`$WAND_BINARY --version` 23 | GRAPHICSMAGICK_VERSION_MASK=`echo ${GRAPHICSMAGICK_VERSION_ORIG} | awk 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'` 24 | 25 | if test "$GRAPHICSMAGICK_VERSION_MASK" -ge 1001000; then 26 | AC_MSG_RESULT(found version $GRAPHICSMAGICK_VERSION_ORIG) 27 | else 28 | AC_MSG_ERROR(no. You need at least GraphicsMagick version 1.1.0 to use Gmagick.) 29 | fi 30 | AC_MSG_CHECKING(GraphicsMagick version mask) 31 | AC_MSG_RESULT(found version $GRAPHICSMAGICK_VERSION_MASK) 32 | 33 | AC_MSG_CHECKING(omp_pause_resource_all usability) 34 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 35 | #include 36 | ]],[[ 37 | omp_pause_resource_all(omp_pause_hard); 38 | ]])],[ 39 | AC_MSG_RESULT(yes) 40 | PHP_CHECK_FUNC(omp_pause_resource_all, gomp) 41 | PHP_ADD_LIBRARY(gomp,, GMAGICK_SHARED_LIBADD) 42 | ],[ 43 | AC_MSG_RESULT(no) 44 | ]) 45 | 46 | LIB_DIR=$WAND_DIR/lib 47 | # If "$LIB_DIR" == "/usr/lib" or possible /usr/$PHP_LIBDIR" then you're probably 48 | # going to have a bad time. PHP m4 files seem to be hard-coded to not link properly against 49 | # those directories. See PHP_ADD_LIBPATH for the weirdness. 50 | 51 | PHP_ADD_LIBRARY_WITH_PATH(GraphicsMagick, $LIB_DIR, GMAGICK_SHARED_LIBADD) 52 | PHP_ADD_LIBRARY_WITH_PATH(GraphicsMagickWand, $LIB_DIR, GMAGICK_SHARED_LIBADD) 53 | PHP_ADD_INCLUDE($WAND_DIR/include/GraphicsMagick) 54 | 55 | PHP_NEW_EXTENSION(gmagick, gmagick_helpers.c gmagick_methods.c gmagick.c gmagickdraw_methods.c gmagickpixel_methods.c, $ext_shared) 56 | 57 | PHP_SUBST(GMAGICK_SHARED_LIBADD) 58 | AC_DEFINE(HAVE_GMAGICK,1,[ ]) 59 | AC_DEFINE_UNQUOTED(GMAGICK_LIB_MASK,$GRAPHICSMAGICK_VERSION_MASK,[Version mask for comparisons]) 60 | fi 61 | -------------------------------------------------------------------------------- /config.w32: -------------------------------------------------------------------------------- 1 | ARG_WITH("gmagick", "GraphicsMagick support", "no"); 2 | 3 | if (PHP_GMAGICK != "no") { 4 | 5 | if (CHECK_HEADER_ADD_INCLUDE("wand/wand_api.h", "CFLAGS_GMAGICK", PHP_PHP_BUILD + "\\include\\graphicsmagick;" + PHP_GMAGICK) 6 | && CHECK_LIB("CORE_RL_wand_.lib", "gmagick", PHP_PHP_BUILD + "\\lib\\graphicsmagick;" + PHP_GMAGICK) 7 | && CHECK_LIB("CORE_RL_magick_.lib", "gmagick", PHP_PHP_BUILD + "\\lib\\graphicsmagick;" + PHP_GMAGICK) 8 | ) 9 | { 10 | ADD_FLAG("CFLAGS_GMAGICK", "/D NDEBUG /D _WINDOWS /D WIN32 /D _VISUALC_ /D NeedFunctionPrototypes /D _DLL /D _MAGICKMOD_ /D _WANDLIB_"); 11 | EXTENSION('gmagick', 'gmagick_helpers.c gmagick_methods.c gmagick.c gmagickdraw_methods.c gmagickpixel_methods.c'); 12 | AC_DEFINE('HAVE_GMAGICK', 1); 13 | } else { 14 | WARNING("gmagick not enabled; libraries and headers not found"); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /gmagick.c: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | PHP Version 5 / Gmagick | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 2009 Vito Chin, Mikko Koppanen | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Author: Mikko Kopppanen | 16 | | Vito Chin | 17 | +----------------------------------------------------------------------+ 18 | */ 19 | 20 | #include "php_gmagick.h" 21 | #include "php_gmagick_macros.h" 22 | #include "php_gmagick_helpers.h" 23 | #include "gmagick_arginfo.h" 24 | 25 | ZEND_DECLARE_MODULE_GLOBALS(gmagick) 26 | 27 | /* handlers */ 28 | static zend_object_handlers gmagick_object_handlers; 29 | static zend_object_handlers gmagickdraw_object_handlers; 30 | static zend_object_handlers gmagickpixel_object_handlers; 31 | 32 | zend_class_entry *php_gmagick_sc_entry; 33 | zend_class_entry *php_gmagickdraw_sc_entry; 34 | zend_class_entry *php_gmagickpixel_sc_entry; 35 | zend_class_entry *php_gmagick_exception_class_entry; 36 | zend_class_entry *php_gmagickdraw_exception_class_entry; 37 | zend_class_entry *php_gmagickpixel_exception_class_entry; 38 | 39 | /* {{{ static void php_gmagick_object_free_storage(void *object TSRMLS_DC) 40 | */ 41 | static void php_gmagick_object_free_storage(zend_object *object TSRMLS_DC) 42 | { 43 | php_gmagick_object *intern = GMAGICK_FETCH_OBJECT(object); 44 | 45 | if (!intern) { 46 | return; 47 | } 48 | 49 | if (intern->magick_wand) { 50 | DestroyMagickWand(intern->magick_wand); 51 | } 52 | 53 | zend_object_std_dtor(&intern->zo TSRMLS_CC); 54 | } 55 | /* }}} */ 56 | 57 | 58 | /* {{{ static zend_object *php_gmagick_object_new_ex(zend_class_entry *class_type, zend_bool init_wand) 59 | */ 60 | static zend_object *php_gmagick_object_new_ex(zend_class_entry *class_type, zend_bool init_wand) 61 | { 62 | /* Allocate memory for it */ 63 | php_gmagick_object *intern = ecalloc(1, sizeof(php_gmagick_object) + zend_object_properties_size(class_type)); 64 | 65 | /* Set the magickwand */ 66 | if (init_wand) { 67 | intern->magick_wand = NewMagickWand(); 68 | } else { 69 | intern->magick_wand = NULL; 70 | } 71 | 72 | zend_object_std_init(&(intern->zo), class_type); 73 | object_properties_init(&intern->zo, class_type); 74 | 75 | intern->zo.handlers = &gmagick_object_handlers; 76 | 77 | return &intern->zo; 78 | } 79 | /* }}} */ 80 | 81 | /* {{{ static zend_object *php_gmagick_object_new(zend_class_entry *class_type) 82 | */ 83 | static zend_object *php_gmagick_object_new(zend_class_entry *class_type) 84 | { 85 | return php_gmagick_object_new_ex(class_type, 1); 86 | } 87 | /* }}} */ 88 | 89 | /* {{{ static zend_object *php_gmagick_clone_gmagick_object(zval *this_ptr TSRMLS_DC) 90 | */ 91 | #if PHP_MAJOR_VERSION < 8 92 | static zend_object *php_gmagick_clone_gmagick_object(zval *this_ptr TSRMLS_DC) 93 | { 94 | php_gmagick_object *old_obj = Z_GMAGICK_OBJ_P(this_ptr); 95 | php_gmagick_object *new_obj = GMAGICK_FETCH_OBJECT(php_gmagick_object_new_ex(old_obj->zo.ce, 0)); 96 | 97 | zend_objects_clone_members(&new_obj->zo, &old_obj->zo); 98 | 99 | if (new_obj->magick_wand) { 100 | DestroyMagickWand(new_obj->magick_wand); 101 | } 102 | 103 | new_obj->magick_wand = CloneMagickWand(old_obj->magick_wand); 104 | return &new_obj->zo; 105 | } 106 | #else 107 | static zend_object *php_gmagick_clone_gmagick_object(zend_object *this_ptr) 108 | { 109 | php_gmagick_object *old_obj = GMAGICK_FETCH_OBJECT(this_ptr); 110 | php_gmagick_object *new_obj = GMAGICK_FETCH_OBJECT(php_gmagick_object_new_ex(this_ptr->ce, 0)); 111 | 112 | zend_objects_clone_members(&new_obj->zo, &old_obj->zo); 113 | 114 | if (new_obj->magick_wand) { 115 | DestroyMagickWand(new_obj->magick_wand); 116 | } 117 | 118 | new_obj->magick_wand = CloneMagickWand(old_obj->magick_wand); 119 | return &new_obj->zo; 120 | } 121 | #endif 122 | /* }}} */ 123 | 124 | /* {{{ static void php_gmagickdraw_object_free_storage(zend_object *object) 125 | */ 126 | static void php_gmagickdraw_object_free_storage(zend_object *object) 127 | { 128 | php_gmagickdraw_object *intern = GMAGICKDRAW_FETCH_OBJECT(object); 129 | 130 | if (!intern) { 131 | return; 132 | } 133 | 134 | if (intern->drawing_wand) { 135 | DestroyDrawingWand(intern->drawing_wand); 136 | } 137 | 138 | zend_object_std_dtor(&intern->zo); 139 | } 140 | /* }}} */ 141 | 142 | /* {{{ static zend_object *php_gmagickdraw_object_new_ex(zend_class_entry *class_type, zend_bool init_wand) 143 | */ 144 | static zend_object *php_gmagickdraw_object_new_ex(zend_class_entry *class_type, zend_bool init_wand) 145 | { 146 | /* Allocate memory for it */ 147 | php_gmagickdraw_object *intern = ecalloc(1, sizeof(php_gmagickdraw_object) + zend_object_properties_size(class_type)); 148 | 149 | /* Set the DrawingWand */ 150 | if (init_wand) { 151 | intern->drawing_wand = NewDrawingWand(); 152 | } else { 153 | intern->drawing_wand = NULL; 154 | } 155 | 156 | zend_object_std_init(&intern->zo, class_type); 157 | object_properties_init(&intern->zo, class_type ); 158 | 159 | intern->zo.handlers = &gmagickdraw_object_handlers; 160 | 161 | return &intern->zo; 162 | } 163 | /* }}} */ 164 | 165 | /* {{{ static zend_object *php_gmagickdraw_object_new(zend_class_entry *class_type) 166 | */ 167 | static zend_object *php_gmagickdraw_object_new(zend_class_entry *class_type) 168 | { 169 | return php_gmagickdraw_object_new_ex(class_type, 1); 170 | } 171 | /* }}} */ 172 | 173 | /* {{{ static void php_gmagickpixel_object_free_storage(zend_object *object TSRMLS_DC) 174 | */ 175 | static void php_gmagickpixel_object_free_storage(zend_object *object) 176 | { 177 | php_gmagickpixel_object *intern = GMAGICKPIXEL_FETCH_OBJECT(object); 178 | 179 | if (!intern) { 180 | return; 181 | } 182 | 183 | if(intern->pixel_wand) { 184 | DestroyPixelWand(intern->pixel_wand); 185 | } 186 | 187 | zend_object_std_dtor(&intern->zo); 188 | } 189 | /* }}} */ 190 | 191 | /* {{{ static zend_object *php_gmagickpixel_object_new_ex(zend_class_entry *class_type, zend_bool init_wand) 192 | */ 193 | static zend_object *php_gmagickpixel_object_new_ex(zend_class_entry *class_type, zend_bool init_wand) 194 | { 195 | /* Allocate memory for it */ 196 | php_gmagickpixel_object *intern = ecalloc(1, sizeof(php_gmagickpixel_object) + zend_object_properties_size(class_type)); 197 | 198 | /* Set the pixelwand if requested */ 199 | if (init_wand) { 200 | intern->pixel_wand = (PixelWand *)NewPixelWand(); 201 | } else { 202 | intern->pixel_wand = NULL; 203 | } 204 | 205 | /* ALLOC_HASHTABLE(intern->zo.properties); */ 206 | 207 | zend_object_std_init(&intern->zo, class_type TSRMLS_CC); 208 | object_properties_init(&intern->zo, class_type ); 209 | 210 | intern->zo.handlers = &gmagickpixel_object_handlers; 211 | 212 | return &intern->zo; 213 | } 214 | /* }}} */ 215 | 216 | /* {{{ static zend_object *php_gmagickpixel_object_new(zend_class_entry *class_type) 217 | */ 218 | static zend_object *php_gmagickpixel_object_new(zend_class_entry *class_type TSRMLS_DC) 219 | { 220 | return php_gmagickpixel_object_new_ex(class_type, 1); 221 | } 222 | /* }}} */ 223 | 224 | /* {{{ static zend_object *php_gmagick_clone_gmagickpixel_object(zval *this_ptr) 225 | */ 226 | #if PHP_MAJOR_VERSION < 8 227 | static zend_object *php_gmagick_clone_gmagickpixel_object(zval *this_ptr) 228 | { 229 | php_gmagickpixel_object *old_obj = Z_GMAGICKPIXEL_OBJ_P(this_ptr); 230 | php_gmagickpixel_object *new_obj = GMAGICKPIXEL_FETCH_OBJECT(php_gmagickpixel_object_new_ex(old_obj->zo.ce, 0)); 231 | 232 | zend_objects_clone_members(&new_obj->zo, &old_obj->zo); 233 | GMAGICK_CLONE_PIXELWAND(old_obj->pixel_wand, new_obj->pixel_wand); 234 | 235 | return &new_obj->zo; 236 | } 237 | #else 238 | static zend_object *php_gmagick_clone_gmagickpixel_object(zend_object *this_ptr) 239 | { 240 | php_gmagickpixel_object *old_obj = GMAGICKPIXEL_FETCH_OBJECT(this_ptr); 241 | php_gmagickpixel_object *new_obj = GMAGICKPIXEL_FETCH_OBJECT(php_gmagickpixel_object_new_ex(old_obj->zo.ce, 0)); 242 | 243 | zend_objects_clone_members(&new_obj->zo, &old_obj->zo); 244 | GMAGICK_CLONE_PIXELWAND(old_obj->pixel_wand, new_obj->pixel_wand); 245 | 246 | return &new_obj->zo; 247 | } 248 | 249 | #endif 250 | /* }}} */ 251 | 252 | PHP_INI_BEGIN() 253 | STD_PHP_INI_ENTRY("gmagick.shutdown_sleep_count", "10", PHP_INI_ALL, OnUpdateLong, shutdown_sleep_count, zend_gmagick_globals, gmagick_globals) 254 | PHP_INI_END() 255 | 256 | static void php_gmagick_init_globals(zend_gmagick_globals *gmagick_globals) 257 | { 258 | // 10 is magick number, that seems to be enough. 259 | gmagick_globals->shutdown_sleep_count = 10; 260 | } 261 | 262 | /* {{{ PHP_MINIT_FUNCTION(gmagick) 263 | */ 264 | PHP_MINIT_FUNCTION(gmagick) 265 | { 266 | char *cwd; 267 | size_t cwd_len; 268 | 269 | zend_class_entry ce; 270 | 271 | ZEND_INIT_MODULE_GLOBALS(gmagick, php_gmagick_init_globals, NULL); 272 | 273 | /* Exception */ 274 | INIT_CLASS_ENTRY(ce, "GmagickException", NULL); 275 | php_gmagick_exception_class_entry = zend_register_internal_class_ex(&ce, zend_exception_get_default()); 276 | php_gmagick_exception_class_entry->ce_flags |= ZEND_ACC_FINAL; 277 | 278 | INIT_CLASS_ENTRY(ce, "GmagickPixelException", NULL); 279 | php_gmagickpixel_exception_class_entry = zend_register_internal_class_ex(&ce, zend_exception_get_default()); 280 | php_gmagickpixel_exception_class_entry->ce_flags |= ZEND_ACC_FINAL; 281 | 282 | /* Class entry */ 283 | INIT_CLASS_ENTRY(ce, "Gmagick", class_Gmagick_methods); 284 | php_gmagick_sc_entry = zend_register_internal_class(&ce); 285 | php_gmagick_sc_entry->create_object = php_gmagick_object_new; 286 | memcpy(&gmagick_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); 287 | gmagick_object_handlers.offset = XtOffsetOf(php_gmagick_object, zo); 288 | gmagick_object_handlers.free_obj = php_gmagick_object_free_storage; 289 | gmagick_object_handlers.clone_obj = php_gmagick_clone_gmagick_object; 290 | 291 | INIT_CLASS_ENTRY(ce, "GmagickDraw", class_GmagickDraw_methods); 292 | php_gmagickdraw_sc_entry = zend_register_internal_class(&ce); 293 | php_gmagickdraw_sc_entry->create_object = php_gmagickdraw_object_new; 294 | memcpy(&gmagickdraw_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); 295 | gmagickdraw_object_handlers.offset = XtOffsetOf(php_gmagickdraw_object, zo); 296 | gmagickdraw_object_handlers.free_obj = php_gmagickdraw_object_free_storage; 297 | gmagickdraw_object_handlers.clone_obj = NULL; 298 | 299 | INIT_CLASS_ENTRY(ce, "GmagickPixel", class_GmagickPixel_methods); 300 | php_gmagickpixel_sc_entry = zend_register_internal_class(&ce); 301 | php_gmagickpixel_sc_entry->create_object = php_gmagickpixel_object_new; 302 | memcpy(&gmagickpixel_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); 303 | gmagickpixel_object_handlers.offset = XtOffsetOf(php_gmagickpixel_object, zo); 304 | gmagickpixel_object_handlers.free_obj = php_gmagickpixel_object_free_storage; 305 | gmagickpixel_object_handlers.clone_obj = php_gmagick_clone_gmagickpixel_object; 306 | 307 | /* Initialize GraphicsMagick environment */ 308 | cwd = virtual_getcwd_ex(&cwd_len); 309 | 310 | if (!cwd) 311 | return FAILURE; 312 | 313 | 314 | InitializeMagick(cwd); 315 | efree(cwd); 316 | 317 | /* init constants */ 318 | php_gmagick_initialize_constants(); 319 | 320 | REGISTER_INI_ENTRIES(); 321 | 322 | return SUCCESS; 323 | } 324 | /* }}} */ 325 | 326 | /* {{{ PHP_MSHUTDOWN_FUNCTION(gmagick) 327 | */ 328 | PHP_MSHUTDOWN_FUNCTION(gmagick) 329 | { 330 | #ifndef HAVE_OMP_PAUSE_RESOURCE_ALL 331 | int i; 332 | #endif 333 | 334 | DestroyMagick(); 335 | #if HAVE_OMP_PAUSE_RESOURCE_ALL 336 | // Note there is a patch to add omp_pause_resource_all to DestroyMagick() 337 | // https://sourceforge.net/p/graphicsmagick/patches/63/ 338 | // But it hasn't been accepted 339 | omp_pause_resource_all(omp_pause_hard); 340 | #else 341 | for (i = 0; i < 100 && i < GMAGICK_G(shutdown_sleep_count); i += 1) { 342 | usleep(1000); 343 | } 344 | #endif 345 | return SUCCESS; 346 | } 347 | /* }}} */ 348 | 349 | /* {{{ PHP_MINFO_FUNCTION(gmagick) 350 | */ 351 | PHP_MINFO_FUNCTION(gmagick) 352 | { 353 | const char *version; 354 | unsigned long version_number; 355 | 356 | version = MagickGetVersion(&version_number); 357 | 358 | php_info_print_table_start(); 359 | php_info_print_table_header(2, "gmagick module", "enabled"); 360 | php_info_print_table_row(2, "gmagick version", PHP_GMAGICK_VERSION); 361 | php_info_print_table_row(2, "GraphicsMagick version", version); 362 | php_info_print_table_end(); 363 | 364 | DISPLAY_INI_ENTRIES(); 365 | } 366 | 367 | /* {{{ zend_module_entry gmagick_module_entry 368 | */ 369 | zend_module_entry gmagick_module_entry = 370 | { 371 | STANDARD_MODULE_HEADER, /* Standard module header */ 372 | "gmagick", /* Extension name */ 373 | NULL, /* Functions */ 374 | PHP_MINIT(gmagick), /* MINIT */ 375 | PHP_MSHUTDOWN(gmagick), /* MSHUTDOWN */ 376 | NULL, /* RINIT */ 377 | NULL, /* RSHUTDOWN */ 378 | PHP_MINFO(gmagick), /* MINFO */ 379 | PHP_GMAGICK_VERSION, /* Version */ 380 | STANDARD_MODULE_PROPERTIES /* Standard properties */ 381 | }; 382 | /* }}} */ 383 | 384 | /* {{{ ZEND_GET_MODULE(gmagick) */ 385 | #ifdef COMPILE_DL_GMAGICK 386 | ZEND_GET_MODULE(gmagick) 387 | #endif 388 | /* }}} */ 389 | -------------------------------------------------------------------------------- /gmagickpixel_methods.c: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | PHP Version 5 / Gmagick | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 2009 Vito Chin, Mikko Koppanen | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Author: Mikko Kopppanen | 16 | | Vito Chin | 17 | +----------------------------------------------------------------------+ 18 | */ 19 | 20 | #include "php_gmagick.h" 21 | #include "php_gmagick_macros.h" 22 | #include "php_gmagick_helpers.h" 23 | 24 | /* {{{ GmagickPixel GmagickPixel::__construct([string color]) 25 | Constructs a new GmagickPixel object 26 | */ 27 | PHP_METHOD(GmagickPixel, __construct) 28 | { 29 | php_gmagickpixel_object *internp; 30 | MagickBool status; // Graphicmagick's boolean type 31 | char *color_name = NULL; 32 | size_t color_name_len = 0; 33 | 34 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!", &color_name, &color_name_len) == FAILURE) { 35 | return; 36 | } 37 | 38 | internp = Z_GMAGICKPIXEL_OBJ_P(getThis()); 39 | 40 | /* If color was given as parameter, set it here.*/ 41 | if (color_name != NULL && internp->pixel_wand != NULL) { 42 | status = PixelSetColor(internp->pixel_wand, color_name); 43 | if(status == MagickFalse) { 44 | GMAGICK_THROW_GMAGICKPIXEL_EXCEPTION(internp->pixel_wand, "Unable to construct GmagickPixel"); 45 | } 46 | } 47 | 48 | RETURN_TRUE; 49 | } 50 | /* }}} */ 51 | 52 | /* {{{ proto GmagickPixel GmagickPixel::setColor(string color) 53 | Sets the color of the pixel 54 | */ 55 | PHP_METHOD(GmagickPixel, setcolor) 56 | { 57 | php_gmagickpixel_object *internp; 58 | char *color_name; 59 | size_t color_name_len; 60 | MagickBool status; 61 | 62 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &color_name, &color_name_len) == FAILURE) { 63 | return; 64 | } 65 | 66 | internp = Z_GMAGICKPIXEL_OBJ_P(getThis()); 67 | status = PixelSetColor(internp->pixel_wand, color_name); 68 | 69 | if(status == MagickFalse) { 70 | GMAGICK_THROW_GMAGICKPIXEL_EXCEPTION(internp->pixel_wand, "Unable to set GmagickPixel color"); 71 | } 72 | 73 | GMAGICK_CHAIN_METHOD; 74 | } 75 | /* }}} */ 76 | 77 | /* {{{ proto GmagickPixel GmagickPixel::setColorCount(int colorCount) 78 | Sets the color count associated with this color. 79 | */ 80 | PHP_METHOD(GmagickPixel, setcolorcount) 81 | { 82 | php_gmagickpixel_object *internp; 83 | zend_long color_count; 84 | 85 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &color_count) == FAILURE) { 86 | return; 87 | } 88 | 89 | internp = Z_GMAGICKPIXEL_OBJ_P(getThis()); 90 | 91 | PixelSetColorCount(internp->pixel_wand, color_count); 92 | 93 | GMAGICK_CHAIN_METHOD; 94 | } 95 | /* }}} */ 96 | 97 | /* {{{ proto array|string GmagickPixel::getColor([boolean as_array = false, normalise_array = false]) 98 | Returns the color of the pixel 99 | */ 100 | PHP_METHOD(GmagickPixel, getcolor) 101 | { 102 | php_gmagickpixel_object *internp; 103 | zend_bool as_array = 0, normalise_array = 0; 104 | 105 | /* Parse parameters given to function */ 106 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|bb", &as_array, &normalise_array) == FAILURE) { 107 | return; 108 | } 109 | 110 | internp = Z_GMAGICKPIXEL_OBJ_P(getThis()); 111 | 112 | if (!as_array) { 113 | char *buffer, *color_string; 114 | int len; 115 | 116 | color_string = PixelGetColorAsString(internp->pixel_wand); 117 | 118 | len = spprintf(&buffer, 50, "rgb(%s)", color_string); 119 | GMAGICK_FREE_MEMORY(char *, color_string); 120 | RETVAL_STRINGL(buffer, len); 121 | efree(buffer); 122 | return; 123 | } else { 124 | array_init(return_value); 125 | 126 | if (normalise_array == 1) { 127 | add_assoc_double(return_value, "r", PixelGetRed(internp->pixel_wand)); 128 | add_assoc_double(return_value, "g", PixelGetGreen(internp->pixel_wand)); 129 | add_assoc_double(return_value, "b", PixelGetBlue(internp->pixel_wand)); 130 | } else { 131 | double red, green, blue; 132 | 133 | red = PixelGetRed(internp->pixel_wand ) * 255; 134 | green = PixelGetGreen(internp->pixel_wand ) * 255; 135 | blue = PixelGetBlue(internp->pixel_wand ) * 255; 136 | 137 | add_assoc_long(return_value, "r", (int)(red > 0.0 ? red + 0.5 : red - 0.5)); 138 | add_assoc_long(return_value, "g", (int)(green > 0.0 ? green + 0.5 : green - 0.5)); 139 | add_assoc_long(return_value, "b", (int)(blue > 0.0 ? blue + 0.5 : blue - 0.5)); 140 | } 141 | return; 142 | } 143 | } 144 | /* }}} */ 145 | 146 | /* {{{ proto int GmagickPixel::getColorCount() 147 | Returns the color count associated with this color. 148 | */ 149 | PHP_METHOD(GmagickPixel, getcolorcount) 150 | { 151 | php_gmagickpixel_object *internp; 152 | zend_long color_count; 153 | 154 | ZEND_PARSE_PARAMETERS_NONE(); 155 | 156 | internp = Z_GMAGICKPIXEL_OBJ_P(getThis()); 157 | 158 | color_count = PixelGetColorCount(internp->pixel_wand); 159 | RETVAL_LONG(color_count); 160 | } 161 | /* }}} */ 162 | 163 | /* {{{ proto float GmagickPixel::getColorValue(int color ) 164 | Gets the normalized color of the GmagickPixel. 165 | */ 166 | PHP_METHOD(GmagickPixel, getcolorvalue) 167 | { 168 | php_gmagickpixel_object *internp; 169 | zend_long color; 170 | double color_value = 0; 171 | 172 | /* Parse parameters given to function */ 173 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &color) == FAILURE) { 174 | return; 175 | } 176 | 177 | internp = Z_GMAGICKPIXEL_OBJ_P(getThis()); 178 | 179 | switch (color) { 180 | 181 | case GMAGICK_COLOR_BLACK: 182 | color_value = PixelGetBlack(internp->pixel_wand); 183 | break; 184 | 185 | case GMAGICK_COLOR_BLUE: 186 | color_value = PixelGetBlue(internp->pixel_wand); 187 | break; 188 | 189 | case GMAGICK_COLOR_CYAN: 190 | color_value = PixelGetCyan(internp->pixel_wand); 191 | break; 192 | 193 | case GMAGICK_COLOR_GREEN: 194 | color_value = PixelGetGreen(internp->pixel_wand); 195 | break; 196 | 197 | case GMAGICK_COLOR_RED: 198 | color_value = PixelGetRed(internp->pixel_wand); 199 | break; 200 | 201 | case GMAGICK_COLOR_YELLOW: 202 | color_value = PixelGetYellow(internp->pixel_wand); 203 | break; 204 | 205 | case GMAGICK_COLOR_MAGENTA: 206 | color_value = PixelGetMagenta(internp->pixel_wand); 207 | break; 208 | 209 | case GMAGICK_COLOR_OPACITY: 210 | color_value = PixelGetOpacity(internp->pixel_wand); 211 | break; 212 | 213 | default: 214 | GMAGICK_THROW_GMAGICKPIXEL_EXCEPTION(internp->pixel_wand, "Unknown color type"); 215 | break; 216 | } 217 | RETVAL_DOUBLE(color_value); 218 | } 219 | /* }}} */ 220 | 221 | /* {{{ proto GmagickPixel GmagickPixel::setColorValue(int color, float value ) 222 | Sets the normalized color of the GmagickPixel. 223 | */ 224 | PHP_METHOD(GmagickPixel, setcolorvalue) 225 | { 226 | php_gmagickpixel_object *internp; 227 | zend_long color; 228 | double color_value; 229 | 230 | /* Parse parameters given to function */ 231 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ld", &color, &color_value) == FAILURE) { 232 | return; 233 | } 234 | 235 | internp = Z_GMAGICKPIXEL_OBJ_P(getThis()); 236 | 237 | switch (color) { 238 | 239 | case GMAGICK_COLOR_BLACK: 240 | PixelSetBlack(internp->pixel_wand, color_value); 241 | break; 242 | 243 | case GMAGICK_COLOR_BLUE: 244 | PixelSetBlue(internp->pixel_wand, color_value); 245 | break; 246 | 247 | case GMAGICK_COLOR_CYAN: 248 | PixelSetCyan(internp->pixel_wand, color_value); 249 | break; 250 | 251 | case GMAGICK_COLOR_GREEN: 252 | PixelSetGreen(internp->pixel_wand, color_value); 253 | break; 254 | 255 | case GMAGICK_COLOR_RED: 256 | PixelSetRed(internp->pixel_wand, color_value); 257 | break; 258 | 259 | case GMAGICK_COLOR_YELLOW: 260 | PixelSetYellow(internp->pixel_wand, color_value); 261 | break; 262 | 263 | case GMAGICK_COLOR_MAGENTA: 264 | PixelSetMagenta(internp->pixel_wand, color_value); 265 | break; 266 | 267 | case GMAGICK_COLOR_OPACITY: 268 | PixelSetOpacity(internp->pixel_wand, color_value); 269 | break; 270 | 271 | default: 272 | GMAGICK_THROW_GMAGICKPIXEL_EXCEPTION(internp->pixel_wand, "Unknown color type"); 273 | break; 274 | 275 | } 276 | GMAGICK_CHAIN_METHOD; 277 | } 278 | /* }}} */ 279 | 280 | /* {{{ proto int GmagickPixel::getColorValueQuantum(int color ) 281 | Gets the quantum color of the GmagickPixel. 282 | */ 283 | PHP_METHOD(GmagickPixel, getcolorvaluequantum) 284 | { 285 | php_gmagickpixel_object *internp; 286 | zend_long color_quantum; 287 | Quantum color_value_quantum = 0; 288 | 289 | /* Parse parameters given to function */ 290 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &color_quantum) == FAILURE) { 291 | return; 292 | } 293 | 294 | internp = Z_GMAGICKPIXEL_OBJ_P(getThis()); 295 | 296 | switch (color_quantum) { 297 | 298 | case GMAGICK_COLOR_BLACK: 299 | color_value_quantum = PixelGetBlackQuantum(internp->pixel_wand); 300 | break; 301 | 302 | case GMAGICK_COLOR_BLUE: 303 | color_value_quantum = PixelGetBlueQuantum(internp->pixel_wand); 304 | break; 305 | 306 | case GMAGICK_COLOR_CYAN: 307 | color_value_quantum = PixelGetCyanQuantum(internp->pixel_wand); 308 | break; 309 | 310 | case GMAGICK_COLOR_GREEN: 311 | color_value_quantum = PixelGetGreenQuantum(internp->pixel_wand); 312 | break; 313 | 314 | case GMAGICK_COLOR_RED: 315 | color_value_quantum = PixelGetRedQuantum(internp->pixel_wand); 316 | break; 317 | 318 | case GMAGICK_COLOR_YELLOW: 319 | color_value_quantum = PixelGetYellowQuantum(internp->pixel_wand); 320 | break; 321 | 322 | case GMAGICK_COLOR_MAGENTA: 323 | color_value_quantum = PixelGetMagentaQuantum(internp->pixel_wand); 324 | break; 325 | 326 | case GMAGICK_COLOR_OPACITY: 327 | color_value_quantum = PixelGetOpacityQuantum(internp->pixel_wand); 328 | break; 329 | 330 | default: 331 | zend_throw_exception_ex(php_gmagickpixel_exception_class_entry, 2 TSRMLS_CC, "Unknown color type: " ZEND_LONG_FMT, color_quantum); 332 | RETURN_NULL(); 333 | } 334 | RETVAL_LONG(color_value_quantum); 335 | } 336 | /* }}} */ 337 | 338 | /* {{{ proto GmagickPixel GmagickPixel::setColorValueQuantum(int color, float value) 339 | Sets the normalized color quantum of the GmagickPixel. 340 | */ 341 | PHP_METHOD(GmagickPixel, setcolorvaluequantum) 342 | { 343 | php_gmagickpixel_object *internp; 344 | zend_long color_quantum; 345 | double color_value_quantum_input; 346 | Quantum color_value_quantum; 347 | 348 | /* Parse parameters given to function */ 349 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ld", &color_quantum, &color_value_quantum_input) == FAILURE) { 350 | return; 351 | } 352 | 353 | // Possible truncation? 354 | color_value_quantum = color_value_quantum_input; 355 | 356 | internp = Z_GMAGICKPIXEL_OBJ_P(getThis()); 357 | 358 | switch (color_quantum) { 359 | case GMAGICK_COLOR_BLACK: 360 | PixelSetBlackQuantum(internp->pixel_wand, color_value_quantum); 361 | break; 362 | 363 | case GMAGICK_COLOR_BLUE: 364 | PixelSetBlueQuantum(internp->pixel_wand, color_value_quantum); 365 | break; 366 | 367 | case GMAGICK_COLOR_CYAN: 368 | PixelSetCyanQuantum(internp->pixel_wand, color_value_quantum); 369 | break; 370 | 371 | case GMAGICK_COLOR_GREEN: 372 | PixelSetGreenQuantum(internp->pixel_wand, color_value_quantum); 373 | break; 374 | 375 | case GMAGICK_COLOR_RED: 376 | PixelSetRedQuantum(internp->pixel_wand, color_value_quantum); 377 | break; 378 | 379 | case GMAGICK_COLOR_YELLOW: 380 | PixelSetYellowQuantum(internp->pixel_wand, color_value_quantum); 381 | break; 382 | 383 | case GMAGICK_COLOR_MAGENTA: 384 | PixelSetMagentaQuantum(internp->pixel_wand, color_value_quantum); 385 | break; 386 | 387 | case GMAGICK_COLOR_OPACITY: 388 | PixelSetOpacityQuantum(internp->pixel_wand, color_value_quantum); 389 | break; 390 | 391 | default: 392 | zend_throw_exception_ex(php_gmagickpixel_exception_class_entry, 2 TSRMLS_CC, "Unknown color type: " ZEND_LONG_FMT, color_quantum); 393 | RETURN_NULL(); 394 | } 395 | 396 | GMAGICK_CHAIN_METHOD; 397 | } 398 | /* }}} */ 399 | -------------------------------------------------------------------------------- /php_gmagick_helpers.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | PHP Version 5 / Gmagick | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 2009 Vito Chin, Mikko Koppanen | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Author: Mikko Kopppanen | 16 | | Vito Chin | 17 | +----------------------------------------------------------------------+ 18 | */ 19 | 20 | #ifndef PHP_GMAGICK_FUNCTIONS_H 21 | # define PHP_GMAGICK_FUNCTIONS_H 22 | 23 | typedef enum { 24 | GmagickUndefinedOperation, 25 | GmagickReadImage, 26 | GmagickPingImage, 27 | GmagickWriteImage, 28 | GmagickWriteImages, 29 | GmagickWriteImageFile, 30 | GmagickWriteImagesFile, 31 | GmagickReadImageFile, 32 | } GmagickOperationType; 33 | 34 | #define GMAGICK_INIT_ERROR_HANDLING zend_error_handling error_handling 35 | #define GMAGICK_SET_ERROR_HANDLING_THROW zend_replace_error_handling(EH_THROW, php_gmagick_exception_class_entry, &error_handling TSRMLS_CC) 36 | #define GMAGICK_RESTORE_ERROR_HANDLING zend_restore_error_handling(&error_handling TSRMLS_CC) 37 | 38 | /* {{{ void php_gmagick_initialize_constants() */ 39 | void php_gmagick_initialize_constants(); 40 | /* }}} */ 41 | 42 | /* {{{ get_pointinfo_array(zval *coordinate_array, int *num_elements TSRMLS_DC) */ 43 | void *get_pointinfo_array(zval *coordinate_array, int *num_elements TSRMLS_DC); 44 | /* }}} */ 45 | 46 | /* {{{ check_configured_font(char *font, int font_len TSRMLS_DC ) */ 47 | int check_configured_font(char *font, int font_len TSRMLS_DC ); 48 | 49 | /* {{{ get_double_array_from_zval(zval *param_array, long *num_elements TSRMLS_DC) */ 50 | double *get_double_array_from_zval(zval *param_array, long *num_elements TSRMLS_DC); 51 | 52 | /* {{{ count_occurences_of(char needle, char *haystack TSRMLS_DC) 53 | */ 54 | int count_occurences_of(char needle, char *haystack TSRMLS_DC); 55 | 56 | /* {{{ zend_bool crop_thumbnail_image(MagickWand *magick_wand, long desired_width, long desired_height TSRMLS_DC) 57 | */ 58 | zend_bool crop_thumbnail_image(MagickWand *magick_wand, long desired_width, long desired_height, zend_bool legacy TSRMLS_DC); 59 | 60 | /* {{{ zend_bool php_gmagick_thumbnail_dimensions(MagickWand *magick_wand, zend_bool bestfit, long desired_width, long desired_height, long *new_width, long *new_height) 61 | */ 62 | zend_bool php_gmagick_thumbnail_dimensions(MagickWand *magick_wand, zend_bool bestfit, zend_long desired_width, zend_long desired_height, zend_long *new_width, zend_long *new_height, zend_bool legacy); 63 | 64 | /* {{{ zend_bool php_gmagick_ensure_not_empty (MagickWand *magick_wand) */ 65 | zend_bool php_gmagick_ensure_not_empty (MagickWand *magick_wand); 66 | 67 | /* {{{ double *php_gmagick_zval_to_double_array(zval *param_array, long *num_elements TSRMLS_DC) */ 68 | double *php_gmagick_zval_to_double_array(zval *param_array, long *num_elements TSRMLS_DC); 69 | 70 | 71 | zend_bool php_gmagick_stream_handler(php_gmagick_object *intern, php_stream *stream, GmagickOperationType type TSRMLS_DC); 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /tests/Vera.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vitoc/gmagick/2936e731e964719d84995a1e64722de5c5c0ee48/tests/Vera.ttf -------------------------------------------------------------------------------- /tests/bug63677.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test bug 63677 - getimagehistogram 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | gmagick = $gmagick; 19 | $this->layers = new Layers($this, $this->gmagick); 20 | } 21 | 22 | public function __destruct() 23 | { 24 | if (null !== $this->gmagick && $this->gmagick instanceof \Gmagick) { 25 | $this->gmagick->clear(); 26 | $this->gmagick->destroy(); 27 | } 28 | } 29 | 30 | public function histogram() 31 | { 32 | return array_map( 33 | function(\GmagickPixel $pixel) { 34 | return new \stdClass(); 35 | }, 36 | $this->gmagick->getimagehistogram() 37 | ); 38 | } 39 | } 40 | 41 | class Layers 42 | { 43 | private $image; 44 | private $resource; 45 | 46 | public function __construct(Image $image, \Gmagick $resource) 47 | { 48 | $this->image = $image; 49 | $this->resource = $resource; 50 | } 51 | } 52 | 53 | 54 | for ($i=0; $i<5; $i++) { 55 | $image = new Image(new \Gmagick("magick:logo")); 56 | // the same fixture must beloaded twice to reprodcue the seg fault 57 | $image = new Image(new \Gmagick("magick:logo")); 58 | 59 | $image->histogram(); 60 | } 61 | 62 | echo "ok"; 63 | ?> 64 | --EXPECT-- 65 | ok 66 | -------------------------------------------------------------------------------- /tests/bug71626.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test bug 71626 - multiple calls to queryFontMetrics 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | queryFontMetrics($fontDraw, 'g'); 17 | 18 | if (is_array($fontMetrics) === false || 19 | isset($fontMetrics['textWidth']) === false) { 20 | echo "fontMetrics contains bad data".PHP_EOL; 21 | var_dump($fontMetrics); 22 | } 23 | } 24 | 25 | 26 | for ($i=0; $i<5; $i++) { 27 | $gmagick = new \Gmagick("magick:logo"); 28 | $fontDraw = new GmagickDraw(); 29 | $fontMetrics = $image->queryFontMetrics($fontDraw, 'g'); 30 | 31 | if (is_array($fontMetrics) === false || 32 | isset($fontMetrics['textWidth']) === false) { 33 | echo "fontMetrics contains bad data".PHP_EOL; 34 | var_dump($fontMetrics); 35 | } 36 | } 37 | 38 | 39 | echo "ok"; 40 | ?> 41 | --EXPECT-- 42 | ok 43 | -------------------------------------------------------------------------------- /tests/bug_71742.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Bug #71742 polyline touched by array_walk 3 | --SKIPIF-- 4 | 2 * $index, 13 | 'y' => pow($index, 2) 14 | ); 15 | } 16 | 17 | $callback = function (&$coordinate) { 18 | $coordinate['y'] = 200 - $coordinate['y'] / 50; 19 | }; 20 | 21 | array_walk($coordinates, $callback); 22 | 23 | $imagick = new GMagick(); 24 | $imagick->newImage(200, 200, "white"); 25 | 26 | $draw = new GmagickDraw(); 27 | $draw->setFillColor("none"); 28 | $draw->setStrokeColor("black"); 29 | 30 | //Fatal error in PHP 7, but not in PHP <= 5.6 31 | $draw->polyline($coordinates); 32 | 33 | $draw->translate(0, -20); 34 | ////Works in PHP 7 35 | $draw->polyline (array_values($coordinates)); 36 | $imagick->drawImage($draw); 37 | //$imagick->writeImage(getcwd(). "/test.png"); 38 | $imagick->setImageFormat('png'); 39 | $bytes = $imagick->getImageBlob(); 40 | 41 | if (strlen($bytes) <= 0) { 42 | echo "Failed to generate image."; 43 | } 44 | 45 | //$imagick->writeImage("./bugTest.png"); 46 | 47 | echo "Ok"; 48 | 49 | ?> 50 | --EXPECT-- 51 | Ok -------------------------------------------------------------------------------- /tests/gmagick-001-read_and_write.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test read/write 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | readImage("magick:rose")->writeImage($filename); 13 | unlink($filename); 14 | echo "ok"; 15 | ?> 16 | --EXPECT-- 17 | ok 18 | -------------------------------------------------------------------------------- /tests/gmagick-002-crop_variations.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test crop with and without an image 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose")->cropImage(10, 10, 10, 10); 12 | echo "ok\n--\n"; 13 | $gm = new Gmagick(); 14 | try { 15 | $gm->cropImage(10, 10, 10, 10); 16 | } catch (GmagickException $e) { 17 | echo "got exception"; 18 | } 19 | ?> 20 | --EXPECTF-- 21 | ok 22 | -- 23 | got exception -------------------------------------------------------------------------------- /tests/gmagick-003-resize_variations.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test resize 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | resizeImage(10, 10, Gmagick::FILTER_LANCZOS, 0.5); 12 | $gm->resizeImage(10, 10, Gmagick::FILTER_UNDEFINED, 0.5, true); 13 | $gm->resizeImage(10, 10, Gmagick::FILTER_GAUSSIAN, 0.5, false); 14 | echo "ok"; 15 | ?> 16 | --EXPECTF-- 17 | ok 18 | -------------------------------------------------------------------------------- /tests/gmagick-004-composite_variations.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test composite variations 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | compositeImage($source, Gmagick::COMPOSITE_OVER, 0, 0); 15 | } catch (Exception $e) { 16 | echo "got exception\n"; 17 | } 18 | 19 | $source->read("magick:rose"); 20 | $gm->compositeImage($source, Gmagick::COMPOSITE_OVER, 0, 0); 21 | 22 | echo "ok"; 23 | ?> 24 | --EXPECTF-- 25 | got exception 26 | ok -------------------------------------------------------------------------------- /tests/gmagick-005-draw.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test read/write 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | setStrokeColor($pixel)->setStrokeWidth( 2 )->setFillColor($pixel)->ellipse( 200, 100, 50, 50, 0, 360 ); 14 | $filename = dirname(__FILE__) . '/test_constructor.jpg'; 15 | $gm = new GMagick("magick:rose"); 16 | $gm->drawImage($gd); 17 | $gm->write($filename); 18 | unlink($filename); 19 | echo "ok"; 20 | ?> 21 | --EXPECT-- 22 | ok 23 | -------------------------------------------------------------------------------- /tests/gmagick-006-annotateimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test annotate image 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 13 | 14 | $fonts = $gm->queryFonts(); 15 | 16 | if (!empty($fonts)) 17 | $gd->setFont($fonts[0]); 18 | 19 | $gm->annotateImage($gd, 5, 15, 0, 'Test Text'); 20 | echo "ok"; 21 | ?> 22 | --EXPECT-- 23 | ok 24 | -------------------------------------------------------------------------------- /tests/gmagick-007-blurimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test blur image 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 13 | $gm->blurImage(5, 3); 14 | $gm->writeImage($filename); 15 | unlink($filename); 16 | echo "ok"; 17 | ?> 18 | --EXPECT-- 19 | ok -------------------------------------------------------------------------------- /tests/gmagick-008-addimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test add image 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 13 | $gm->addImage($image); 14 | echo "ok"; 15 | ?> 16 | --EXPECT-- 17 | ok -------------------------------------------------------------------------------- /tests/gmagick-009-addimagenoise.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test addnoiseimage image 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->addNoiseImage(Gmagick::COLOR_BLACK); 13 | echo "ok"; 14 | ?> 15 | --EXPECT-- 16 | ok -------------------------------------------------------------------------------- /tests/gmagick-010-borderimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test border image 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 13 | $color=new GmagickPixel("rgb(255,255,255)"); 14 | $gm->borderImage($color,3,3); 15 | $gm->write($filename); 16 | echo "ok"; 17 | ?> 18 | --EXPECT-- 19 | ok -------------------------------------------------------------------------------- /tests/gmagick-011-charcoalimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test charcoal image 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 13 | $gm->charcoalImage(3,3); 14 | $gm->write($filename); 15 | echo "ok"; 16 | ?> 17 | --EXPECT-- 18 | ok -------------------------------------------------------------------------------- /tests/gmagick-012-chopimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test chop image 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 13 | $gm->chopImage(10, 10, 0, 0); 14 | $gm->write($filename); 15 | echo "ok"; 16 | ?> 17 | --EXPECTF-- 18 | ok -------------------------------------------------------------------------------- /tests/gmagick-013-commentimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test commentImage 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->commentImage("Test Comment"); 13 | echo "ok"; 14 | ?> 15 | --EXPECT-- 16 | ok 17 | -------------------------------------------------------------------------------- /tests/gmagick-014-current.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test current 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm2 = $gm->current(); 13 | echo "ok"; 14 | ?> 15 | --EXPECTF-- 16 | ok -------------------------------------------------------------------------------- /tests/gmagick-015-cyclecolormapimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test current 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->cycleColorMapImage(2); 13 | echo "ok"; 14 | ?> 15 | --EXPECTF-- 16 | ok -------------------------------------------------------------------------------- /tests/gmagick-016-despeckleimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Despeckle image 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->despeckleImage(); 13 | echo "ok"; 14 | ?> 15 | --EXPECTF-- 16 | ok -------------------------------------------------------------------------------- /tests/gmagick-017-destroy.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Destroy 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->destroy(); 13 | echo "ok"; 14 | ?> 15 | --EXPECTF-- 16 | ok -------------------------------------------------------------------------------- /tests/gmagick-018-edgeimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Edge 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->edgeImage(0.8); 13 | echo "ok"; 14 | ?> 15 | --EXPECTF-- 16 | ok -------------------------------------------------------------------------------- /tests/gmagick-019-embossimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Emboss 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->embossImage(0.8, 0.5); 13 | echo "ok"; 14 | ?> 15 | --EXPECTF-- 16 | ok -------------------------------------------------------------------------------- /tests/gmagick-020-enhanceimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Enhance 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->enhanceImage(); 13 | echo "ok"; 14 | ?> 15 | --EXPECTF-- 16 | ok -------------------------------------------------------------------------------- /tests/gmagick-021-equalizeimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Equalize 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->equalizeImage(); 13 | echo "ok"; 14 | ?> 15 | --EXPECTF-- 16 | ok -------------------------------------------------------------------------------- /tests/gmagick-022-flip_and_flop_image.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Flip and flop image 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->flipImage()->flopImage(); 13 | echo "1"; 14 | ?> 15 | --EXPECTF-- 16 | 1 -------------------------------------------------------------------------------- /tests/gmagick-023-gammaimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Gamma image 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->gammaImage(0.8); 13 | echo "1"; 14 | ?> 15 | --EXPECTF-- 16 | 1 -------------------------------------------------------------------------------- /tests/gmagick-024-getcopyright_getfilename.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test getCopyright, getFileName 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->getCopyright(); 13 | $gm->getFilename(); 14 | echo "ok"; 15 | ?> 16 | --EXPECTF-- 17 | ok -------------------------------------------------------------------------------- /tests/gmagick-025-set_and_getimageckgroundcolor.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test setImageBackgroundColor and getImageBackgroundColor methods 3 | --SKIPIF-- 4 | 9 | --FILE-- 10 | read("magick:rose"); 13 | $color=new GmagickPixel("rgb(255,255,255)"); 14 | $pixel = $gm->setImageBackgroundColor($color)->getimagebackgroundcolor(); 15 | print_r($pixel->getColor()); 16 | ?> 17 | --EXPECTF-- 18 | rgb(255,255,255) 19 | -------------------------------------------------------------------------------- /tests/gmagick-025-set_and_getimageckgroundcolor_q16.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test setImageBackgroundColor and getImageBackgroundColor methods 3 | --SKIPIF-- 4 | 9 | --FILE-- 10 | read("magick:rose"); 13 | $color=new GmagickPixel("rgb(255,255,255)"); 14 | $pixel = $gm->setImageBackgroundColor($color)->getimagebackgroundcolor(); 15 | print_r($pixel->getColor()); 16 | ?> 17 | --EXPECTF-- 18 | rgb(65535,65535,65535) 19 | -------------------------------------------------------------------------------- /tests/gmagick-026-set_getimageblueprimary.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Set, get imageblueprimary test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | print_r($gm->setImageBluePrimary(0.2, 0.2)->getImageBluePrimary()); 13 | ?> 14 | --EXPECTF-- 15 | Array 16 | ( 17 | [x] => 0.2 18 | [y] => 0.2 19 | ) -------------------------------------------------------------------------------- /tests/gmagick-027-set_getimagebordercolor.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Imagebordercolor test 3 | --SKIPIF-- 4 | 9 | --FILE-- 10 | read("magick:rose"); 13 | $color=new GmagickPixel("rgb(255,255,255)"); 14 | $pixel = $gm->setImageBorderColor($color)->getImageBorderColor(); 15 | print_r($pixel->getColor()); 16 | ?> 17 | --EXPECTF-- 18 | rgb(255,255,255) 19 | -------------------------------------------------------------------------------- /tests/gmagick-027-set_getimagebordercolor_q16.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Imagebordercolor test 3 | --SKIPIF-- 4 | 9 | --FILE-- 10 | read("magick:rose"); 13 | $color=new GmagickPixel("rgb(255,255,255)"); 14 | $pixel = $gm->setImageBorderColor($color)->getImageBorderColor(); 15 | print_r($pixel->getColor()); 16 | ?> 17 | --EXPECTF-- 18 | rgb(65535,65535,65535) 19 | -------------------------------------------------------------------------------- /tests/gmagick-028-set_getimagechanneldepth.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Set, get imagechanneldepth test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | echo $gm->setImageChannelDepth(1,1)->getImageChannelDepth(1); 13 | ?> 14 | --EXPECTF-- 15 | 1 -------------------------------------------------------------------------------- /tests/gmagick-029-set_getimagecolorspace.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Set, get imagecolorspace test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | echo $gm->setImageColorspace(2)->getImageColorspace(); 13 | ?> 14 | --EXPECTF-- 15 | 2 -------------------------------------------------------------------------------- /tests/gmagick-030-getimagecolors.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Getimagecolors test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | print_r($gm->getImageColors()); 13 | ?> 14 | --EXPECTF-- 15 | 3019 -------------------------------------------------------------------------------- /tests/gmagick-031-set_getimagecompose.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Set and get image compose 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | echo $gm->setImageCompose(1)->getImageCompose(); 13 | ?> 14 | --EXPECTF-- 15 | 1 -------------------------------------------------------------------------------- /tests/gmagick-032-set_getimagedelay.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Set, getimagedelay test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | echo $gm->setImageDelay(2)->getImageDelay(); 13 | ?> 14 | --EXPECTF-- 15 | 2 -------------------------------------------------------------------------------- /tests/gmagick-033-set_getimagedepth.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Set, getimagedepth 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | echo $gm->setImageDepth(2)->getImageDepth(); 13 | ?> 14 | --EXPECTF-- 15 | 2 -------------------------------------------------------------------------------- /tests/gmagick-034-set_getimagedispose.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Set, getimagedepth 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | echo $gm->setImageDispose(2)->getImageDispose(); 13 | ?> 14 | --EXPECTF-- 15 | 2 -------------------------------------------------------------------------------- /tests/gmagick-035-set_getfilename.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Set, get filename 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | echo $gm->setFilename("magickrose.png")->getFilename(); 13 | ?> 14 | --EXPECTF-- 15 | magickrose.png -------------------------------------------------------------------------------- /tests/gmagick-036-set_getimagefilename.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Set, get imagefilename 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | echo $gm->setImageFilename('magickrose.png')->getImageFilename(); 13 | ?> 14 | --EXPECTF-- 15 | magickrose.png -------------------------------------------------------------------------------- /tests/gmagick-037-set_getimagegamma.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Set, get image gamma 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | echo $gm->setImageGamma(0.2)->getImageGamma(); 13 | ?> 14 | --EXPECTF-- 15 | 0.2 -------------------------------------------------------------------------------- /tests/gmagick-038-setimagegreenprimary.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Set, get imagegreenprimary 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | print_r($gm->setImageGreenPrimary(0.2, 0.2)->getImageGreenPrimary()); 13 | ?> 14 | --EXPECTF-- 15 | Array 16 | ( 17 | [x] => 0.2 18 | [y] => 0.2 19 | ) -------------------------------------------------------------------------------- /tests/gmagick-039-getimageheight.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Set, get image height 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | echo $gm->getImageHeight(); 13 | ?> 14 | --EXPECTF-- 15 | 46 -------------------------------------------------------------------------------- /tests/gmagick-040-getimagehistogram.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Set, get image histogram 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->getImageHistogram(); 13 | echo "ok"; 14 | ?> 15 | --EXPECTF-- 16 | ok -------------------------------------------------------------------------------- /tests/gmagick-041-set_getimageinterlacescheme.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Set, get image interlace scheme 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | echo $gm->setImageInterlaceScheme(1)->getImageInterlaceScheme(); 13 | ?> 14 | --EXPECTF-- 15 | 1 -------------------------------------------------------------------------------- /tests/gmagick-042-set_getimageiterations.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Set, get image iterations 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | echo $gm->setImageIterations(2)->getImageIterations(); 13 | ?> 14 | --EXPECTF-- 15 | 2 -------------------------------------------------------------------------------- /tests/gmagick-043-set_getimageprofile.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Set, get imageprofile 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | echo $gm->setImageProfile("test", "test_profile")->getImageProfile("test"); 13 | ?> 14 | --EXPECTF-- 15 | test_profile -------------------------------------------------------------------------------- /tests/gmagick-044-set_getimageredprimary.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Set, get imageredprimary 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | print_r($gm->setImageRedPrimary(0.2, 0.2)->getImageRedPrimary()); 13 | ?> 14 | --EXPECTF-- 15 | Array 16 | ( 17 | [x] => 0.2 18 | [y] => 0.2 19 | ) -------------------------------------------------------------------------------- /tests/gmagick-045-set_getimagerenderingintent.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Set, get imagerenderingintent 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | echo $gm->setImageRenderingIntent(1)->getImageRenderingIntent(); 13 | ?> 14 | --EXPECTF-- 15 | 1 -------------------------------------------------------------------------------- /tests/gmagick-046-set_getimagerresolution.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Set, get imageresolution 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | print_r($gm->setImageResolution(0.2,0.2)->getImageResolution()); 13 | ?> 14 | --EXPECTF-- 15 | Array 16 | ( 17 | [x] => 0.2 18 | [y] => 0.2 19 | ) -------------------------------------------------------------------------------- /tests/gmagick-047-set_getimagescene.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Set, get imagescene 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | echo $gm->setImageScene(1)->getImageScene(); 13 | ?> 14 | --EXPECTF-- 15 | 1 -------------------------------------------------------------------------------- /tests/gmagick-048-getimagesignature.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Set, get imagesignature 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | echo $gm->getImageSignature(); 13 | ?> 14 | --EXPECTF-- 15 | 8b19185a62241bd7b79ecf3f619711f4ebbedd73eaeca0366f05778762b6614f -------------------------------------------------------------------------------- /tests/gmagick-049-set_getimagetype.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Set, get imagetype 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | echo $gm->setImageType(6)->getImageType(); 13 | ?> 14 | --EXPECTF-- 15 | 6 -------------------------------------------------------------------------------- /tests/gmagick-050-set_getimageunits.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Set, get imageunits 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | echo $gm->setImageUnits(2)->getImageUnits(); 13 | ?> 14 | --EXPECTF-- 15 | 2 -------------------------------------------------------------------------------- /tests/gmagick-051-set_getimagewhitepoint.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Set, get imagewhitepoint 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | print_r($gm->setImageWhitePoint(0.2, 0.2)->getImageWhitePoint()); 13 | ?> 14 | --EXPECTF-- 15 | Array 16 | ( 17 | [x] => 0.2 18 | [y] => 0.2 19 | ) -------------------------------------------------------------------------------- /tests/gmagick-052-getimagewidth.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | get imagewidth 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | echo $gm->getImageWidth(); 13 | ?> 14 | --EXPECTF-- 15 | 70 -------------------------------------------------------------------------------- /tests/gmagick-053-getpackagename.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | get packagename 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | echo $gm->getPackageName(); 13 | ?> 14 | --EXPECTF-- 15 | GraphicsMagick -------------------------------------------------------------------------------- /tests/gmagick-054-getquantumdepth.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | get quantumdepth 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $q=$gm->getQuantumDepth(); 13 | if (is_array($q) && count($q)==2 && isset($q['quantumDepthLong']) && isset($q['quantumDepthString'])) { 14 | echo "Struct OK\n"; 15 | if ($q['quantumDepthLong']=='8' && $q['quantumDepthString']=='Q8') { 16 | echo "Quantum OK\n"; 17 | } else if ($q['quantumDepthLong']=='16' && $q['quantumDepthString']=='Q16') { 18 | echo "Quantum OK\n"; 19 | } else { 20 | echo "Quantum KO\n"; 21 | print_r($q); 22 | } 23 | } else { 24 | echo "Struct KO\n"; 25 | print_r($q); 26 | } 27 | ?> 28 | --EXPECTF-- 29 | Struct OK 30 | Quantum OK -------------------------------------------------------------------------------- /tests/gmagick-055-getreleasedate.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | get releasedate 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->getReleaseDate(); 13 | echo "ok"; 14 | ?> 15 | --EXPECTF-- 16 | ok -------------------------------------------------------------------------------- /tests/gmagick-056-set_getsamplingfactors.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Set, getsamplingfactors 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $samples = array(1, 2); 13 | print_r($gm->setSamplingFactors($samples)->getSamplingFactors()); 14 | ?> 15 | --EXPECTF-- 16 | Array 17 | ( 18 | [0] => 1 19 | [1] => 2 20 | ) -------------------------------------------------------------------------------- /tests/gmagick-057-set_getsize.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | set,get size test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | print_r($gm->setSize(20, 20)->getSize()); 13 | ?> 14 | --EXPECTF-- 15 | Array 16 | ( 17 | [columns] => 20 18 | [rows] => 20 19 | ) -------------------------------------------------------------------------------- /tests/gmagick-058-getversion.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | getVersion test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->getVersion(); 13 | echo "ok"; 14 | ?> 15 | --EXPECTF-- 16 | ok 17 | -------------------------------------------------------------------------------- /tests/gmagick-059-hasnextimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | hasNextImage test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->hasNextImage(); 13 | echo "ok"; 14 | ?> 15 | --EXPECTF-- 16 | ok 17 | -------------------------------------------------------------------------------- /tests/gmagick-060-haspreviousimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | hasPreviousImage test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->hasPreviousImage(); 13 | echo "ok"; 14 | ?> 15 | --EXPECTF-- 16 | ok 17 | -------------------------------------------------------------------------------- /tests/gmagick-061-implodeimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | implode image test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->implodeImage(0.5); 13 | echo "ok"; 14 | ?> 15 | --EXPECTF-- 16 | ok 17 | -------------------------------------------------------------------------------- /tests/gmagick-062-labelimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | labelImage test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->labelImage("test"); 13 | echo "ok"; 14 | ?> 15 | --EXPECTF-- 16 | ok 17 | -------------------------------------------------------------------------------- /tests/gmagick-063-levelimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | levelImage test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->levelImage(0.2, 0.2, 0.2); 13 | echo "ok"; 14 | ?> 15 | --EXPECTF-- 16 | ok 17 | -------------------------------------------------------------------------------- /tests/gmagick-064-magnifyimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | magnifyImage test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->magnifyImage(); 13 | echo "ok"; 14 | ?> 15 | --EXPECTF-- 16 | ok -------------------------------------------------------------------------------- /tests/gmagick-065-mapimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | mapImage test 3 | --SKIPIF-- 4 | 9 | --FILE-- 10 | read("magick:rose"); 14 | $gm2->read("magick:rose"); 15 | $gm->mapImage($gm2, true); 16 | echo "ok"; 17 | ?> 18 | --EXPECTF-- 19 | ok 20 | -------------------------------------------------------------------------------- /tests/gmagick-066-medianfilterimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | medianFilterImage test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->medianFilterImage(0.5); 13 | echo "ok"; 14 | ?> 15 | --EXPECTF-- 16 | ok -------------------------------------------------------------------------------- /tests/gmagick-067-minifyimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | minifyImage test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->minifyImage(); 13 | echo "ok"; 14 | ?> 15 | --EXPECTF-- 16 | ok 17 | -------------------------------------------------------------------------------- /tests/gmagick-068-modulateimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | modulateImage test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->modulateImage(0.2, 0.2, 0.2); 13 | echo "ok"; 14 | ?> 15 | --EXPECTF-- 16 | ok 17 | -------------------------------------------------------------------------------- /tests/gmagick-069-trimimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | trimImage test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->trimImage(0.5); 13 | echo "ok"; 14 | ?> 15 | --EXPECTF-- 16 | ok -------------------------------------------------------------------------------- /tests/gmagick-070-motionblurimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | motionblur test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->motionBlurImage(0.2, 0.2, 0.2); 13 | echo "ok"; 14 | ?> 15 | --EXPECTF-- 16 | ok 17 | -------------------------------------------------------------------------------- /tests/gmagick-071-next_previousimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | next,previousImage test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->nextImage(); 13 | $gm->previousImage(); 14 | echo "ok"; 15 | ?> 16 | --EXPECTF-- 17 | ok 18 | -------------------------------------------------------------------------------- /tests/gmagick-072-oilpaintimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | oilPaintImage test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->oilPaintImage(0.2); 13 | echo "ok"; 14 | ?> 15 | --EXPECTF-- 16 | ok 17 | -------------------------------------------------------------------------------- /tests/gmagick-073-profileimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | profileImage test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->profileImage('icc', 'test_icc_profile'); 13 | echo "ok"; 14 | ?> 15 | --EXPECTF-- 16 | ok 17 | -------------------------------------------------------------------------------- /tests/gmagick-074-quantizeimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | quantizeImage test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->quantizeImage(2, 2, 2, true, true); 13 | echo "ok"; 14 | ?> 15 | --EXPECTF-- 16 | ok 17 | -------------------------------------------------------------------------------- /tests/gmagick-075-quantizeimages.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | quantizeImages test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->quantizeImages(2, 2, 2, true, true); 13 | echo "ok"; 14 | ?> 15 | --EXPECTF-- 16 | ok 17 | -------------------------------------------------------------------------------- /tests/gmagick-076-queryfonts.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | queryFonts test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->queryFonts(); 13 | echo "ok"; 14 | ?> 15 | --EXPECTF-- 16 | ok 17 | -------------------------------------------------------------------------------- /tests/gmagick-077-cropthumbnail.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | cropthumbnail test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->cropThumbnailImage(3, 3); 13 | 14 | //Test the the calculated values are actually correct. 15 | $desired_height = 250; 16 | $imageWidth = 1128; 17 | 18 | //Test the the calculated values are actually correct. 19 | $desired_height = 250; 20 | $imageWidth = 1128; 21 | $imageHeight = 1128; 22 | 23 | $legacySettings = array(0, 1); 24 | 25 | foreach($legacySettings as $legacy) { 26 | for ($desired_width = 245; $desired_width < 255; $desired_width++) { 27 | $gmagick = new Gmagick(); 28 | $gmagick->newImage ($imageWidth, $imageHeight, 'blue'); 29 | 30 | $gmagick->cropThumbnailImage( 31 | $desired_width, 32 | $desired_height, 33 | $legacy 34 | ); 35 | $error = false; 36 | 37 | $thumbnailImageWidth = $gmagick->getImageWidth(); 38 | $thumbnailImageHeight = $gmagick->getImageHeight(); 39 | 40 | if ($thumbnailImageHeight != $desired_height) { 41 | echo "Incorrect height for desired_width $desired_width imageHeight $imageHeight".PHP_EOL; 42 | $error = true; 43 | } 44 | 45 | $expectedWidth = $desired_width; 46 | $expectedHeight = $desired_height; 47 | 48 | if ($legacy == true && 49 | $desired_width == 250 && 50 | $desired_height == 250) { 51 | // The legacy behaviour is to generate a wrong size for this setting. 52 | // Thumbnail size of 249 x 250 does not matched desired size 250 x 250 53 | // for source image of 1128 x 1128 54 | $expectedWidth = 249; 55 | } 56 | 57 | if ($thumbnailImageWidth != $expectedWidth) { 58 | echo "Unexpected width of $thumbnailImageWidth for desired_width $desired_width, expected width is $expectedWidth".PHP_EOL; 59 | $error = true; 60 | } 61 | 62 | if ($thumbnailImageHeight != $expectedHeight) { 63 | echo "Unexpected height $thumbnailImageHeight for desired_width $desired_width, expected height is $expectedHeight".PHP_EOL; 64 | $error = true; 65 | } 66 | 67 | if ($error) { 68 | printf( 69 | "Thumbnail size of %d x %d does not matched expected size %d x %d for source image of %d x %d. Legacy is %d\n", 70 | $thumbnailImageWidth, $thumbnailImageHeight, 71 | $desired_width, $desired_height, 72 | $imageWidth, $imageHeight, 73 | $legacy 74 | ); 75 | } 76 | } 77 | } 78 | 79 | echo "ok"; 80 | 81 | ?> 82 | --EXPECTF-- 83 | ok 84 | -------------------------------------------------------------------------------- /tests/gmagick-078-rollimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | rollImage test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->rollImage(5,5); 13 | echo "ok"; 14 | ?> 15 | --EXPECTF-- 16 | ok -------------------------------------------------------------------------------- /tests/gmagick-079-rotateimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | rotateImage test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $color=new GmagickPixel("rgb(255,255,255)"); 13 | $gm->rotateImage($color, 0.8); 14 | echo "ok"; 15 | ?> 16 | --EXPECTF-- 17 | ok -------------------------------------------------------------------------------- /tests/gmagick-080-scaleimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | scaleImage test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->scaleImage(5, 5); 13 | echo "ok"; 14 | ?> 15 | --EXPECTF-- 16 | ok -------------------------------------------------------------------------------- /tests/gmagick-081-separateimagechannel.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | separateImageChannel test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->separateImageChannel(1); 13 | echo "ok"; 14 | ?> 15 | --EXPECTF-- 16 | ok -------------------------------------------------------------------------------- /tests/gmagick-082-shearimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | shearImage test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 13 | $gm->shearImage($color, 0.2, 0.2); 14 | echo "ok"; 15 | ?> 16 | --EXPECTF-- 17 | ok -------------------------------------------------------------------------------- /tests/gmagick-083-solarizeimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | solarizeImage test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->solarizeImage(1); 13 | echo "ok"; 14 | ?> 15 | --EXPECTF-- 16 | ok -------------------------------------------------------------------------------- /tests/gmagick-084-spreadimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | spreadImage test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->spreadImage(0.2); 13 | echo "ok"; 14 | ?> 15 | --EXPECTF-- 16 | ok -------------------------------------------------------------------------------- /tests/gmagick-085-stripimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | stripImage test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->stripImage(); 13 | echo "ok"; 14 | ?> 15 | --EXPECTF-- 16 | ok -------------------------------------------------------------------------------- /tests/gmagick-086-swirlimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | swirlImage test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->swirlImage(0.2); 13 | echo "ok"; 14 | ?> 15 | --EXPECTF-- 16 | ok -------------------------------------------------------------------------------- /tests/gmagick-087-setcompressionquality.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | setCompressionQuality test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 12 | $gm->setCompressionQuality(2); 13 | echo "ok"; 14 | ?> 15 | --EXPECTF-- 16 | ok 17 | -------------------------------------------------------------------------------- /tests/gmagick-088-getimageblob.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | getimageBlob test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | getimageBlob(); 12 | echo "ok"; 13 | ?> 14 | --EXPECTF-- 15 | ok 16 | -------------------------------------------------------------------------------- /tests/gmagick-089-getnumberimages.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | getNumberImages test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | getNumberImages()); 12 | ?> 13 | --EXPECTF-- 14 | 1 15 | -------------------------------------------------------------------------------- /tests/gmagick-090-setimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | setImage test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | setImage($replace); 13 | echo "1"; 14 | ?> 15 | --EXPECTF-- 16 | 1 17 | -------------------------------------------------------------------------------- /tests/gmagick-091-getimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | getImage test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | getImage(); 12 | echo "1"; 13 | ?> 14 | --EXPECTF-- 15 | 1 16 | -------------------------------------------------------------------------------- /tests/gmagick-092-getimagegeometry.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | setImage test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | getImageGeometry()); 12 | ?> 13 | --EXPECTF-- 14 | Array 15 | ( 16 | [width] => 70 17 | [height] => 46 18 | ) 19 | -------------------------------------------------------------------------------- /tests/gmagick-093-flattenimages.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | setImage test 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | flattenImages(); 12 | echo "ok"; 13 | ?> 14 | --EXPECTF-- 15 | ok 16 | -------------------------------------------------------------------------------- /tests/gmagick-094-thresholdimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | thresholdImage test 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | thresholdImage(2); 11 | echo "ok"; 12 | ?> 13 | --EXPECTF-- 14 | ok 15 | -------------------------------------------------------------------------------- /tests/gmagick-095-negateimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | negateImage test 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | negateImage(TRUE); 11 | echo "ok"; 12 | ?> 13 | --EXPECTF-- 14 | ok 15 | -------------------------------------------------------------------------------- /tests/gmagick-096-setinterlacescheme.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | setInterlaceScheme test 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | setInterlaceScheme(Gmagick::INTERLACE_LINE); 11 | echo "ok"; 12 | ?> 13 | --EXPECTF-- 14 | ok 15 | -------------------------------------------------------------------------------- /tests/gmagick-097-sampleimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | sampleimage test 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | sampleimage(5, 5); 11 | echo "ok"; 12 | ?> 13 | --EXPECTF-- 14 | ok 15 | -------------------------------------------------------------------------------- /tests/gmagick-098-cloneimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | cloneimage test 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | cloneimage(); 11 | echo "ok"; 12 | ?> 13 | --EXPECTF-- 14 | ok 15 | -------------------------------------------------------------------------------- /tests/gmagick-099-appendimages.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | appendimages test 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | newImage(100, 50, "blue"); 11 | $image->appendImages(); 12 | echo "ok"; 13 | ?> 14 | --EXPECTF-- 15 | ok 16 | -------------------------------------------------------------------------------- /tests/gmagick-100-coalesceimages.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | coalesceimages test 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | newImage(100, 50, "blue"); 11 | $image->newImage(100, 50, "yellow"); 12 | $image->coalesceImages(); 13 | echo "ok"; 14 | ?> 15 | --EXPECTF-- 16 | ok 17 | -------------------------------------------------------------------------------- /tests/gmagick-101-sharpenimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | sharpenimage test 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | sharpenImage(1.5, 1.2); 11 | echo "ok"; 12 | ?> 13 | --EXPECTF-- 14 | ok 15 | -------------------------------------------------------------------------------- /tests/gmagick-102-unsharpenmaskimage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | unsharpmaskimage test 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | unsharpMaskImage(0 , 0.5 , 1 , 0.05); 11 | echo "ok"; 12 | ?> 13 | --EXPECTF-- 14 | ok 15 | -------------------------------------------------------------------------------- /tests/gmagick-103-setgetimagecompression.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | setImageCompression test 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | setImageCompression(Gmagick::COMPRESSION_JPEG); 11 | echo $image->getImageCompression(); 12 | ?> 13 | --EXPECTF-- 14 | 5 -------------------------------------------------------------------------------- /tests/gmagick-104-setgetimagepage.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Gmagick::setImagePage test 3 | --SKIPIF-- 4 | 13 | --FILE-- 14 | setImagePage(10,10,10,10); 17 | $result = $image->getImagePage(); 18 | if (($result['width'] === 10) && ($result['height'] === 10) 19 | && ($result['x'] === 10) && ($result['y'] === 10)) { 20 | echo "ok"; 21 | } 22 | ?> 23 | --EXPECTF-- 24 | ok -------------------------------------------------------------------------------- /tests/gmagick-105-readimageblob.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Gmagick::readImageBlob 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | setImageFormat('png'); 11 | $imageBlob = $image->getImageBlob(); 12 | 13 | $imageReload = new Gmagick(); 14 | $imageReload->readImageBlob($imageBlob); 15 | printf( 16 | "Dimensions are %d x %d\n", 17 | $imageReload->getImageWidth(), 18 | $imageReload->getImageHeight() 19 | ); 20 | echo "ok"; 21 | 22 | ?> 23 | --EXPECTF-- 24 | Dimensions are 70 x 46 25 | ok -------------------------------------------------------------------------------- /tests/gmagick-106-testConstants.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test contants have symbols. 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | getConstants(); 14 | 15 | echo "ok"; 16 | ?> 17 | --EXPECTF-- 18 | ok -------------------------------------------------------------------------------- /tests/gmagick-107_setimagevirtualpixelmethod.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test Tutorial, edgeExtend 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | setImageVirtualPixelMethod($virtualPixelType); 16 | 17 | $gmagick->scaleimage(400, 300, true); 18 | 19 | $gmagick->setimagebackgroundcolor('pink'); 20 | 21 | $desiredWidth = 600; 22 | $originalWidth = $gmagick->getImageWidth(); 23 | 24 | //Make the image be the desired width. 25 | $gmagick->sampleimage($desiredWidth, $gmagick->getImageHeight()); 26 | 27 | //Now scale, rotate, translate (aka affine project) it 28 | //to be how you want 29 | $points = array(//The x scaling factor is 0.5 when the desired width is double 30 | //the source width 31 | ($originalWidth / $desiredWidth), 0, //Don't scale vertically 32 | 0, 1, //Offset the image so that it's in the centre 33 | ($desiredWidth - $originalWidth) / 2, 0); 34 | 35 | $amplitude = 5; 36 | $length = 20; 37 | $gmagick->waveImage($amplitude, $length); 38 | 39 | $bytes = $gmagick->getImageBlob(); 40 | if (strlen($bytes) <= 0) { echo "Failed to generate image.";} 41 | 42 | //Fyi it may be easier to think of the affine transform by 43 | //how it works for a rotation: 44 | //$affineRotate = array( 45 | // "sx" => cos($angle), 46 | // "sy" => cos($angle), 47 | // "rx" => sin($angle), 48 | // "ry" => -sin($angle), 49 | // "tx" => 0, 50 | // "ty" => 0, 51 | //); 52 | } 53 | 54 | edgeExtend($virtualPixelType) ; 55 | echo "Ok"; 56 | ?> 57 | --EXPECTF-- 58 | Ok -------------------------------------------------------------------------------- /tests/gmagick-108_adaptiveThresholdImage_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test Gmagick, adaptiveThresholdImage 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | adaptiveThresholdImage($width, $height, $adaptiveOffsetQuantum); 19 | $bytes = $gmagick->getImageBlob(); 20 | if (strlen($bytes) <= 0) { echo "Failed to generate image.";} 21 | } 22 | 23 | adaptiveThresholdImage($width, $height, $adaptiveOffset) ; 24 | echo "Ok"; 25 | ?> 26 | --EXPECTF-- 27 | Ok -------------------------------------------------------------------------------- /tests/gmagick-109_affineTransformImage_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test Gmagick, affineTransformImage 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | cos($angle), "sy" => cos($angle), 20 | "rx" => sin($angle), "ry" => -sin($angle), 21 | "tx" => 0, "ty" => 0, 22 | ); 23 | 24 | $draw->affine($affineRotate); 25 | 26 | $gmagick->affineTransformImage($draw); 27 | 28 | $bytes = $gmagick->getImageBlob(); 29 | if (strlen($bytes) <= 0) { echo "Failed to generate image.";} 30 | } 31 | 32 | affineTransformImage() ; 33 | echo "Ok"; 34 | ?> 35 | --EXPECTF-- 36 | Ok -------------------------------------------------------------------------------- /tests/gmagick-110_blackThresholdImage_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test Gmagick, blackThresholdImage 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | blackthresholdimage($thresholdColor); 16 | $bytes = $gmagick->getImageBlob(); 17 | if (strlen($bytes) <= 0) { echo "Failed to generate image.";} 18 | } 19 | 20 | blackThresholdImage($thresholdColor) ; 21 | echo "Ok"; 22 | ?> 23 | --EXPECTF-- 24 | Ok -------------------------------------------------------------------------------- /tests/gmagick-111_whiteThresholdImage_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test Gmagick, whiteThresholdImage 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | whiteThresholdImage($color); 16 | $bytes = $gmagick->getImageBlob(); 17 | if (strlen($bytes) <= 0) { echo "Failed to generate image.";} 18 | } 19 | 20 | whiteThresholdImage($color) ; 21 | echo "Ok"; 22 | ?> 23 | --EXPECTF-- 24 | Ok -------------------------------------------------------------------------------- /tests/gmagick-112_colorizeImage_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test Gmagick, colorizeImage 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | colorizeImage($color, $opacityColor); 19 | $bytes = $gmagick->getImageBlob(); 20 | if (strlen($bytes) <= 0) { echo "Failed to generate image.";} 21 | } 22 | 23 | colorizeImage($color, $opacity) ; 24 | echo "Ok"; 25 | ?> 26 | --EXPECTF-- 27 | Ok -------------------------------------------------------------------------------- /tests/gmagick-113_compareImages.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test PHP bug #59378 writing to php://memory is incomplete 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | setFormat("png"); 10 | 11 | $fp = fopen("php://memory", 'r+'); 12 | $gmagick->writeImageFile($fp); 13 | rewind($fp); 14 | $memoryBlob = stream_get_contents($fp); 15 | fclose($fp); 16 | 17 | //This test depends on getImageBlob working correctly. 18 | $imageBlob = $gmagick->getImageBlob(); 19 | 20 | //Read the images from the data blobs. 21 | $imageReopened = new Gmagick(); 22 | $imageReopened->readImageBlob($imageBlob); 23 | $memoryReopened = new Gmagick(); 24 | $memoryReopened->readImageBlob($memoryBlob); 25 | 26 | //Compare to see if they are identical. 27 | $result = $imageReopened->compareImages($memoryReopened, \Gmagick::METRIC_MEANABSOLUTEERROR); 28 | 29 | if ($result[1] == 0) { 30 | echo "Reopened images are identical."; 31 | } 32 | else { 33 | echo "Error, reopened images have changed."; 34 | var_dump($result); 35 | } 36 | 37 | ?> 38 | --EXPECTF-- 39 | Reopened images are identical. 40 | -------------------------------------------------------------------------------- /tests/gmagick-114_convolveImage_6.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test Gmagick, convolveImage 3 | --SKIPIF-- 4 | 9 | --FILE-- 10 | -1, 15 | 1 => -1, 16 | 2 => -1, 17 | 3 => -1, 18 | 4 => 8, 19 | 5 => -1, 20 | 6 => -1, 21 | 7 => -1, 22 | 8 => -1, 23 | ); 24 | 25 | function convolveImage($bias, $kernelMatrix) { 26 | $gmagick = new \Gmagick("magick:logo"); 27 | 28 | 29 | $gmagick->convolveImage($kernelMatrix); 30 | $bytes = $gmagick->getImageBlob(); 31 | if (strlen($bytes) <= 0) { echo "Failed to generate image.";} 32 | } 33 | 34 | convolveImage($bias, $kernelMatrix) ; 35 | echo "Ok"; 36 | ?> 37 | --EXPECTF-- 38 | Ok -------------------------------------------------------------------------------- /tests/gmagick-115_equalizeImage_case2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test Gmagick, equalizeImage 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | equalizeImage(); 16 | $gmagick->extentImage( 17 | $startX, $startY, $width, $height 18 | ); 19 | 20 | $bytes = $gmagick->getImageBlob(); 21 | if (strlen($bytes) <= 0) { echo "Failed to generate image.";} 22 | } 23 | $startX = 50; 24 | $startY = 50; 25 | $width = 150; 26 | $height = 150; 27 | 28 | extentImage($startX, $startY, $width, $height) ; 29 | echo "Ok"; 30 | ?> 31 | --EXPECTF-- 32 | Ok -------------------------------------------------------------------------------- /tests/gmagick-116_waveImage_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test Gmagick, waveImage 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | waveImage($amplitude, $length); 17 | $bytes = $gmagick->getImageBlob(); 18 | if (strlen($bytes) <= 0) { echo "Failed to generate image.";} 19 | } 20 | 21 | waveImage($amplitude, $length) ; 22 | echo "Ok"; 23 | ?> 24 | --EXPECTF-- 25 | Ok -------------------------------------------------------------------------------- /tests/gmagick-117_haldClutImage_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test Gmagick, haldClutImage 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | sepiatoneImage(55); 17 | $gmagick->haldClutImage($gmagickPalette); 18 | $bytes = $gmagick->getImageBlob(); 19 | if (strlen($bytes) <= 0) { echo "Failed to generate image.";} 20 | } 21 | 22 | haldClutImage() ; 23 | echo "Ok"; 24 | ?> 25 | --EXPECTF-- 26 | Ok -------------------------------------------------------------------------------- /tests/gmagick-118_shaveImage_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test Gmagick, shaveImage 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | shaveImage(100, 50); 15 | $bytes = $gmagick->getImageBlob(); 16 | if (strlen($bytes) <= 0) { echo "Failed to generate image.";} 17 | } 18 | 19 | shaveImage() ; 20 | echo "Ok"; 21 | ?> 22 | --EXPECTF-- 23 | Ok -------------------------------------------------------------------------------- /tests/gmagick-119_thumbnail_fill.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test filling thumbnail with color 3 | --SKIPIF-- 4 | = 0x660 && $v ['versionNumber'] < 0x670) 11 | die ('skip seems to be broken in this version of ImageMagick'); 12 | ?> 13 | --FILE-- 14 | setImageBackgroundColor("pink"); 18 | $gmagick->thumbnailImage(200, 200, true); 19 | 20 | 21 | echo "ok" 22 | ?> 23 | --EXPECT-- 24 | 25 | ok -------------------------------------------------------------------------------- /tests/gmagick-120_writeImageFile.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test PHP writing to php://memory 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | setFormat("png"); 10 | 11 | $fp = fopen("php://memory", 'r+'); 12 | $gmagick->writeImageFile($fp); 13 | rewind($fp); 14 | $memoryBlob = stream_get_contents($fp); 15 | fclose($fp); 16 | 17 | //This test depends on getImageBlob working correctly. 18 | $imageBlob = $gmagick->getImageBlob(); 19 | 20 | //Read the images from the data blobs. 21 | $imageReopened = new Gmagick(); 22 | $imageReopened->readImageBlob($imageBlob); 23 | $memoryReopened = new Gmagick(); 24 | $memoryReopened->readImageBlob($memoryBlob); 25 | 26 | //Compare to see if they are identical. 27 | $result = $imageReopened->compareImages($memoryReopened, \Gmagick::METRIC_MEANABSOLUTEERROR); 28 | 29 | if ($result[1] == 0) { 30 | echo "Reopened images are identical."; 31 | } 32 | else { 33 | echo "Error, reopened images have changed."; 34 | var_dump($result); 35 | } 36 | 37 | ?> 38 | --EXPECTF-- 39 | Reopened images are identical. 40 | -------------------------------------------------------------------------------- /tests/gmagick-121_deconstructGif_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test Tutorial, deconstructGif 3 | --SKIPIF-- 4 | 11 | --XFAIL-- 12 | GraphicMagick has multiple issues with 'image counts'. It appears to be confused how many images are in the list. 13 | --FILE-- 14 | setFormat("gif"); 18 | 19 | $circleRadius = 20; 20 | $imageFrames = 6; 21 | $imageSize = 200; 22 | 23 | $background = new \Gmagick(); 24 | $background->newImage($imageSize, $imageSize, "gray"); 25 | 26 | $blackWhite = new \Gmagick(); 27 | $blackWhite->newImage($imageSize, $imageSize, "white"); 28 | 29 | $backgroundPalette = clone $background; 30 | $backgroundPalette->quantizeImage(240, \Gmagick::COLORSPACE_RGB, 8, false, false); 31 | 32 | $blackWhitePalette = clone $blackWhite; 33 | $blackWhitePalette->quantizeImage(16, \Gmagick::COLORSPACE_RGB, 8, false, false); 34 | 35 | $backgroundPalette->addimage($blackWhitePalette); 36 | 37 | /* 38 | for($count=0 ; $count<$imageFrames ; $count++) { 39 | echo "Frame: ".$count."\n"; 40 | $drawing = new \GmagickDraw(); 41 | $drawing->setFillColor('white'); 42 | $drawing->setStrokeColor('rgba(64, 64, 64, 0.8)'); 43 | $strokeWidth = 4; 44 | $drawing->setStrokeWidth($strokeWidth); 45 | 46 | $distanceToMove = $imageSize + (($circleRadius + $strokeWidth) * 2); 47 | $offset = ($distanceToMove * $count / ($imageFrames -1)) - ($circleRadius + $strokeWidth); 48 | $drawing->translate( 49 | $offset, 50 | ($imageSize / 2) + ($imageSize / 3 * cos(20 * $count / $imageFrames)) 51 | ); 52 | $drawing->circle(0, 0, $circleRadius, 0); 53 | 54 | $frame = clone $background; 55 | $frame->drawimage($drawing); 56 | 57 | $frame->setImageDelay(10); 58 | 59 | $frame = new Gmagick(); 60 | $frame->newimage( int $width , int $height , string $background [, string $format ] ) 61 | 62 | 63 | $aniGif->addImage($frame); 64 | } 65 | */ 66 | 67 | $colors = array( 68 | "Red", 69 | "Orange", 70 | "Yellow", 71 | "Green", 72 | "Indigo", 73 | "Violet", 74 | ); 75 | 76 | foreach ($colors as $color) { 77 | $frame = new Gmagick(); 78 | $frame->newimage(100, 100, $color); 79 | $aniGif->addImage($frame); 80 | } 81 | 82 | $aniGif->setImageFormat('gif'); 83 | 84 | //Even this fails. 85 | //$aniGif->writeImage("./testgif.gif"); 86 | 87 | $aniGif = $aniGif->deconstructImages(); 88 | $bytes = $aniGif->getImagesBlob(); 89 | if (strlen($bytes) <= 0) { echo "Failed to generate image.";} 90 | 91 | echo "Ok"; 92 | ?> 93 | --EXPECTF-- 94 | Frame: 0 95 | Frame: 1 96 | Frame: 2 97 | Frame: 3 98 | Frame: 4 99 | Frame: 5 100 | Ok -------------------------------------------------------------------------------- /tests/gmagick-122_unsharpMaskImage_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test Gmagick, unsharpMaskImage 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | unsharpMaskImage($radius, $sigma, $amount, $unsharpThreshold); 20 | $bytes = $gmagick->getImageBlob(); 21 | if (strlen($bytes) <= 0) { echo "Failed to generate image.";} 22 | } 23 | 24 | unsharpMaskImage($radius, $sigma, $amount, $unsharpThreshold) ; 25 | echo "Ok"; 26 | ?> 27 | --EXPECTF-- 28 | Ok -------------------------------------------------------------------------------- /tests/gmagick-123_sharpenImage_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test Gmagick, sharpenImage 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | sharpenimage($radius, $sigma); 17 | $bytes = $gmagick->getImageBlob(); 18 | if (strlen($bytes) <= 0) { echo "Failed to generate image.";} 19 | } 20 | 21 | sharpenImage($radius, $sigma); 22 | echo "Ok"; 23 | ?> 24 | --EXPECTF-- 25 | Ok -------------------------------------------------------------------------------- /tests/gmagick-124__reduceNoiseImage_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test Gmagick, reduceNoiseImage 3 | --SKIPIF-- 4 | 9 | --FILE-- 10 | reduceNoiseImage($reduceNoise); 17 | $bytes = $gmagick->getImageBlob(); 18 | if (strlen($bytes) <= 0) { echo "Failed to generate image.";} 19 | } 20 | 21 | reduceNoiseImage($reduceNoise) ; 22 | echo "Ok"; 23 | ?> 24 | --EXPECTF-- 25 | Ok -------------------------------------------------------------------------------- /tests/gmagick-125_radialBlurImage_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test Gmagick, radialBlurImage 3 | --SKIPIF-- 4 | 10 | --FILE-- 11 | radialBlurImage(3); 17 | $gmagick->radialBlurImage(5); 18 | $gmagick->radialBlurImage(7); 19 | $bytes = $gmagick->getImageBlob(); 20 | if (strlen($bytes) <= 0) { echo "Failed to generate image.";} 21 | } 22 | 23 | radialBlurImage() ; 24 | echo "Ok"; 25 | ?> 26 | --EXPECTF-- 27 | Ok -------------------------------------------------------------------------------- /tests/gmagick-126_negateImage_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test Gmagick, negateImage 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | negateImage($grayOnly, $channel); 17 | $bytes = $gmagick->getImageBlob(); 18 | if (strlen($bytes) <= 0) { echo "Failed to generate image.";} 19 | } 20 | 21 | negateImage($grayOnly, $channel) ; 22 | echo "Ok"; 23 | ?> 24 | --EXPECTF-- 25 | Ok -------------------------------------------------------------------------------- /tests/gmagick-127_contrastImage_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test Gmagick, contrastImage 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | contrastImage($contrastType); 17 | } 18 | 19 | $bytes = $gmagick->getImageBlob(); 20 | if (strlen($bytes) <= 0) { echo "Failed to generate image.";} 21 | } 22 | 23 | contrastImage($contrastType) ; 24 | echo "Ok"; 25 | ?> 26 | --EXPECTF-- 27 | Ok -------------------------------------------------------------------------------- /tests/gmagick-128_staticMethods.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test static methods 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | queryFormats ()) . PHP_EOL; 12 | 13 | //echo gettype (Gmagick::queryFonts ()) . PHP_EOL; 14 | echo gettype ($gmagick->queryFonts ()) . PHP_EOL; 15 | 16 | echo 'success'; 17 | 18 | ?> 19 | --EXPECT-- 20 | array 21 | array 22 | success -------------------------------------------------------------------------------- /tests/gmagick-129_gettersAndSetters.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test static methods 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | getImageVirtualPixelMethod(); 16 | $gmagick->getImageBackgroundColor(); 17 | $gmagick->getImageBluePrimary(); 18 | $gmagick->getImageBorderColor(); 19 | $gmagick->getImagesBlob(); 20 | $gmagick->getImageColorspace(); 21 | $gmagick->getImageCompose(); 22 | $gmagick->getImageDelay(); 23 | $gmagick->getImageDepth(); 24 | $gmagick->getImageCompression(); 25 | $gmagick->getImageDispose(); 26 | $gmagick->getImageExtrema(); 27 | $gmagick->getImageFilename(); 28 | $gmagick->getImageFormat(); 29 | $gmagick->getImageGamma(); 30 | $gmagick->getImageGreenPrimary(); 31 | $gmagick->getImageIndex(); 32 | $gmagick->getImageInterlaceScheme(); 33 | $gmagick->getImageIterations(); 34 | $gmagick->getImageMatteColor(); 35 | 36 | $gmagick->getImageRedPrimary(); 37 | $gmagick->getImageRenderingIntent(); 38 | $gmagick->getImageResolution(); 39 | $gmagick->getImageScene(); 40 | $gmagick->getImageBoundingbox(0.1); 41 | $gmagick->getImageFuzz(); 42 | $gmagick->getImageSavedType(); 43 | 44 | $gmagick->getImageType(); 45 | $gmagick->getImageUnits(); 46 | $gmagick->getImageWhitepoint(); 47 | 48 | $gmagick->getSamplingfactors(); 49 | $gmagick->getSize(); 50 | $gmagick->getImageGeometry(); 51 | $gmagick->setImageAttribute("comment", "this is a comment"); 52 | $gmagick->setImageColormapColor(0, 'red'); 53 | 54 | $gmagick->setImageMatteColor('pink'); 55 | $gmagick->setDepth(16); 56 | $gmagick->setImageFuzz(0.1 * \GMAGICK::QUANTUM); 57 | $gmagick->setImageOption("jpeg", "preserve-settings", "true"); 58 | $gmagick->setImageSavedType(\GMAGICK::IMGTYPE_TRUECOLOR); 59 | $gmagick->setResolutionUnits(\GMAGICK::RESOLUTION_PIXELSPERCENTIMETER); 60 | $gmagick->setImageIndex(0); 61 | $gmagick->setInterlaceScheme(\GMAGICK::INTERLACE_PLANE); 62 | $gmagick->setImageCompression(\GMAGICK::COMPRESSION_NO); 63 | $gmagick->setImageFormat("BMP"); 64 | 65 | $gmagick->setResourceLimit(\GMAGICK::RESOURCETYPE_MEMORY, 16*1024*1024); 66 | $gmagick->getImageAttribute("comment"); 67 | $gmagick->getImageChannelExtrema(\GMAGICK::CHANNEL_RED); 68 | $gmagick->getImageChannelMean(\GMAGICK::CHANNEL_RED); 69 | $gmagick->getImageColormapColor(0); 70 | $gmagick->getImageChannelDepth(\GMAGICK::CHANNEL_RED); 71 | $gmagick->getResourceLimit(\GMAGICK::RESOURCETYPE_MEMORY); 72 | 73 | if (method_exists($gmagick, 'setImageGravity')) { 74 | $gmagick->setImageGravity(\GMAGICK::GRAVITY_SOUTHWEST); 75 | } 76 | 77 | if (method_exists($gmagick, 'getImageGravity')) { 78 | $gmagick->getImageGravity(); 79 | } 80 | 81 | if (method_exists($gmagick, 'getImagePage')) { 82 | $gmagick->getImagePage(); 83 | } 84 | 85 | 86 | // Don't know how to call this successfully. 87 | // $gmagick->get ImageProfile("ICC"); 88 | 89 | 90 | echo 'ok'; 91 | 92 | ?> 93 | --EXPECT-- 94 | ok -------------------------------------------------------------------------------- /tests/gmagick-130-reflection.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test that reflection works correctly 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | getMethods() as $reflectionMethod) { 17 | $parameters = $reflectionMethod->getParameters(); 18 | foreach ($parameters as $parameter) { 19 | if ($parameter->isDefaultValueAvailable() !== true) { 20 | continue; 21 | } 22 | 23 | try { 24 | $value = $parameter->getDefaultValue(); 25 | } 26 | catch (ReflectionException $re) { 27 | $method_name = $reflectionMethod->getName(); 28 | echo "Exception for $class::$method_name : " . $re->getMessage() . "\n"; 29 | } 30 | } 31 | } 32 | } 33 | 34 | echo "Ok"; 35 | ?> 36 | --EXPECTF-- 37 | Ok 38 | 39 | -------------------------------------------------------------------------------- /tests/gmagickdraw-001-setstrokecolor_setstrokewidth.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test set stroke color, set stroke width 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | setStrokeColor($pixel)->setStrokeWidth(2); 14 | echo "ok"; 15 | ?> 16 | --EXPECT-- 17 | ok -------------------------------------------------------------------------------- /tests/gmagickdraw-002-ellipse.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test ellipse 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | setFillColor($pixel)->ellipse( 200, 100, 50, 50, 0, 360 ); 14 | echo "ok"; 15 | ?> 16 | --EXPECT-- 17 | ok -------------------------------------------------------------------------------- /tests/gmagickdraw-003-annotate.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test annotate 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose");//->write($filename); 14 | $gd->annotate(10, 20, "Test Text"); 15 | $gm->drawImage($gd); 16 | $gm->write($filename); 17 | unlink($filename); 18 | echo "ok"; 19 | ?> 20 | --EXPECT-- 21 | ok -------------------------------------------------------------------------------- /tests/gmagickdraw-004-arc.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test arc 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 14 | $gd->arc(10, 10, 30, 30, 5, 10); 15 | $gm->drawImage($gd); 16 | $gm->write($filename); 17 | unlink($filename); 18 | echo "ok"; 19 | ?> 20 | --EXPECT-- 21 | ok -------------------------------------------------------------------------------- /tests/gmagickdraw-005-bezier.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test bezier 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 14 | $gd->bezier( array( 15 | array( "x" => 3 , "y" => 8 ), 16 | array( "x" => 13, "y" => 16 ), 17 | array( "x" => 20, "y" => 25 ), 18 | array( "x" => 25, "y" => 23 ), 19 | array( "x" => 33, "y" => 23 ), 20 | array( "x" => 33, "y" => 3 ), 21 | ) ); 22 | $gm->drawImage($gd); 23 | $gm->write($filename); 24 | unlink($filename); 25 | echo "ok"; 26 | ?> 27 | --EXPECT-- 28 | ok -------------------------------------------------------------------------------- /tests/gmagickdraw-006-setfillcolor_getfillcolor.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test setfillcolor, getfillcolor 3 | --SKIPIF-- 4 | 9 | --FILE-- 10 | setFillColor($pixel)->getFillColor()->getColor()); 15 | ?> 16 | --EXPECT-- 17 | rgb(255,255,255) 18 | -------------------------------------------------------------------------------- /tests/gmagickdraw-006-setfillcolor_getfillcolor_q16.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test setfillcolor, getfillcolor 3 | --SKIPIF-- 4 | 9 | --FILE-- 10 | setFillColor($pixel)->getFillColor()->getColor()); 15 | ?> 16 | --EXPECT-- 17 | rgb(65535,65535,65535) 18 | -------------------------------------------------------------------------------- /tests/gmagickdraw-007-setfillopacity_getfillopacity.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test setfillopacity, getfillopacity 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | setFillOpacity(0.8); 12 | echo $gd->getFillOpacity(); 13 | ?> 14 | --EXPECT-- 15 | 0.2 -------------------------------------------------------------------------------- /tests/gmagickdraw-008-setfont_getfont.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test setfont, getfont 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | setFont(dirname(__FILE__) . "/Vera.ttf")->getFont(),"Vera.ttf"); 12 | ?> 13 | --EXPECT-- 14 | Vera.ttf -------------------------------------------------------------------------------- /tests/gmagickdraw-009-setfontsize_getfontsize.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test setfontsize, getfontsize 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | setFontSize(1)->getFontSize(); 12 | ?> 13 | --EXPECT-- 14 | 1 -------------------------------------------------------------------------------- /tests/gmagickdraw-010-setfontstyle_getfontstyle.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test setfontstyle, getfontstyle 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | setFontStyle(Gmagick::STYLE_NORMAL)->getFontStyle(); 12 | ?> 13 | --EXPECT-- 14 | 0 -------------------------------------------------------------------------------- /tests/gmagickdraw-011-setfontweight_getfontweight.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test setfontweight, getfontweight 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | setFontWeight(101)->getFontWeight(); 12 | ?> 13 | --EXPECT-- 14 | 101 -------------------------------------------------------------------------------- /tests/gmagickdraw-012-setstrokeopacity_getstrokeopacity.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test setstrokeopacity, getstrokeopacity 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | setStrokeOpacity(0.8)->getStrokeOpacity(); 12 | ?> 13 | --EXPECT-- 14 | 0.8 -------------------------------------------------------------------------------- /tests/gmagickdraw-013-setstrokecolor_getstrokecolor.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test setstrokecolor, getstrokecolor 3 | --SKIPIF-- 4 | 9 | --FILE-- 10 | setStrokeColor($pixel)->getStrokeColor()->getColor()); 15 | ?> 16 | --EXPECT-- 17 | rgb(255,255,255) 18 | -------------------------------------------------------------------------------- /tests/gmagickdraw-013-setstrokecolor_getstrokecolor_q16.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test setstrokecolor, getstrokecolor 3 | --SKIPIF-- 4 | 9 | --FILE-- 10 | setStrokeColor($pixel)->getStrokeColor()->getColor()); 15 | ?> 16 | --EXPECT-- 17 | rgb(65535,65535,65535) 18 | -------------------------------------------------------------------------------- /tests/gmagickdraw-014-setstrokewidth_getstrokewidth.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test setstrokewidth, getstrokewidth 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | setStrokeWidth(2)->getStrokeWidth(); 12 | ?> 13 | --EXPECT-- 14 | 2 -------------------------------------------------------------------------------- /tests/gmagickdraw-015-settextdecoration_gettextdecoration.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test settextdecoration, gettextdecoration 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | setTextDecoration(Gmagick::DECORATION_UNDERLINE)->getTextDecoration(); 12 | ?> 13 | --EXPECT-- 14 | 1 -------------------------------------------------------------------------------- /tests/gmagickdraw-016-settextencoding_gettextencoding.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test settextencoding, gettextencoding 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | setTextEncoding("UTF-8")->getTextEncoding(); 12 | ?> 13 | --EXPECT-- 14 | UTF-8 -------------------------------------------------------------------------------- /tests/gmagickdraw-017-line.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test line 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 14 | $gd->line(8, 8, 18, 18); 15 | $gm->drawImage($gd); 16 | $gm->write($filename); 17 | unlink($filename); 18 | echo "ok"; 19 | ?> 20 | --EXPECT-- 21 | ok -------------------------------------------------------------------------------- /tests/gmagickdraw-018-point.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test point 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 14 | $gd->point(20,20); 15 | $gm->drawImage($gd); 16 | $gm->write($filename); 17 | unlink($filename); 18 | echo "ok"; 19 | ?> 20 | --EXPECT-- 21 | ok -------------------------------------------------------------------------------- /tests/gmagickdraw-019-polygon.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test polygon 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 14 | $polArray = array( array( 'x' => 3, 'y' => 4 ), array( 'x' => 2, 'y' => 6 ) ,array( 'x' => 5, 'y' => 10 ), array( 'x' => 3, 'y' => 4 )); 15 | $gd->polygon($polArray); 16 | $gm->drawImage($gd); 17 | $gm->write($filename); 18 | unlink($filename); 19 | echo "ok"; 20 | ?> 21 | --EXPECT-- 22 | ok -------------------------------------------------------------------------------- /tests/gmagickdraw-020-polyline.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test polyline 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 3, 'y' => 4 ), 13 | array( 'x' => 2, 'y' => 6 ), 14 | array( 'x' => 5, 'y' => 10 ), 15 | array( 'x' => 3, 'y' => 4 ) 16 | ); 17 | 18 | $floatPoints = array( 19 | array( 'x' => 3.5, 'y' => 4.5 ), 20 | array( 'x' => 2.5, 'y' => 6.5 ), 21 | array( 'x' => 5.5, 'y' => 10.5 ), 22 | array( 'x' => 3.5, 'y' => 4.5 ) 23 | ); 24 | 25 | $tests = array( 26 | $intPoints, 27 | $floatPoints 28 | ); 29 | 30 | foreach ($tests as $polArray) { 31 | $filename = dirname(__FILE__) . '/test_constructor.jpg'; 32 | $gm = new GMagick(); 33 | $gd = new GMagickDraw(); 34 | $gm->read("magick:rose"); 35 | $gd->polyline($polArray); 36 | $gm->drawImage($gd); 37 | $gm->write($filename); 38 | unlink($filename); 39 | echo "ok".PHP_EOL; 40 | } 41 | ?> 42 | --EXPECT-- 43 | ok 44 | ok -------------------------------------------------------------------------------- /tests/gmagickdraw-021-rectangle.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test rectangle 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 14 | $gd->rectangle(20,20,30,30); 15 | $gm->drawImage($gd); 16 | $gm->write($filename); 17 | unlink($filename); 18 | echo "ok"; 19 | ?> 20 | --EXPECT-- 21 | ok -------------------------------------------------------------------------------- /tests/gmagickdraw-022-rotate.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test rotate 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 14 | $gd->rectangle(20,20,30,30); 15 | $gd->rotate(45); 16 | $gm->drawImage($gd); 17 | $gm->write($filename); 18 | unlink($filename); 19 | echo "ok"; 20 | ?> 21 | --EXPECT-- 22 | ok -------------------------------------------------------------------------------- /tests/gmagickdraw-023-roundrectangle.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test round rectangle 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 14 | $gd->roundRectangle(30,30,35,35,5,5); 15 | $gm->drawImage($gd); 16 | $gm->write($filename); 17 | unlink($filename); 18 | echo "ok"; 19 | ?> 20 | --EXPECT-- 21 | ok -------------------------------------------------------------------------------- /tests/gmagickdraw-024-scale.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test scale 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | read("magick:rose"); 14 | $gd->rectangle(20,20,30,30); 15 | $gd->scale(0.5,0.5); 16 | $gm->drawImage($gd); 17 | $gm->write($filename); 18 | unlink($filename); 19 | echo "ok"; 20 | ?> 21 | --EXPECT-- 22 | ok -------------------------------------------------------------------------------- /tests/gmagickdraw-025-affine.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test affine 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 1, "rx" => 0, "ry" => 0, "sy" =>1, "tx" => 0, "ty" => 0); 12 | $gDraw->affine($affineArray); 13 | echo "ok"; 14 | ?> 15 | --EXPECT-- 16 | ok 17 | -------------------------------------------------------------------------------- /tests/gmagickdraw-026-setgravity_getgravity.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test affine 3 | --SKIPIF-- 4 | 13 | --FILE-- 14 | setGravity(2); 17 | echo $gDraw->getGravity(); 18 | ?> 19 | --EXPECT-- 20 | 2 21 | -------------------------------------------------------------------------------- /tests/gmagickdraw-027-setantialias_getantialias.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test and get anti-alias 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | setStrokeAntiAlias(true); 11 | echo $gDraw->getStrokeAntiAlias(); 12 | ?> 13 | --EXPECT-- 14 | 1 15 | -------------------------------------------------------------------------------- /tests/gmagickdraw-028-setlinecap_getlinecap.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test set and get line cap 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | setStrokeLineCap(2); 12 | echo $gDraw->getStrokeLineCap(); 13 | ?> 14 | --EXPECT-- 15 | 2 16 | -------------------------------------------------------------------------------- /tests/gmagickdraw-029-setlinejoin_getlinejoin.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test stroke line join 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | setStrokeLineJoin(2); 12 | echo $gDraw->getStrokeLineJoin(); 13 | ?> 14 | --EXPECT-- 15 | 2 16 | -------------------------------------------------------------------------------- /tests/gmagickdraw-030-setmiterlimit_getmiterlimit.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test get and set strokeMiterLimit 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | setStrokeMiterLimit(2); 12 | echo $gDraw->getStrokeMiterLimit(); 13 | ?> 14 | --EXPECT-- 15 | 2 16 | -------------------------------------------------------------------------------- /tests/gmagickdraw-031-setdashstrokearray_getdashstrokearray.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test set and get stroke dash array 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | setStrokeDashArray(array(3, 2)); 12 | print_r($gDraw->getStrokeDashArray()); 13 | ?> 14 | --EXPECT-- 15 | Array 16 | ( 17 | [0] => 3 18 | [1] => 2 19 | ) -------------------------------------------------------------------------------- /tests/gmagickdraw-032_circle_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test GmagickDraw, circle 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | setStrokeOpacity(1); 25 | $draw->setStrokeColor($strokeColor); 26 | $draw->setFillColor($fillColor); 27 | 28 | $draw->setStrokeWidth(2); 29 | $draw->setFontSize(72); 30 | 31 | $draw->circle($originX, $originY, $endX, $endY); 32 | 33 | $imagick = new \Gmagick(); 34 | $imagick->newImage(500, 500, $backgroundColor); 35 | $imagick->setImageFormat("png"); 36 | $imagick->drawImage($draw); 37 | 38 | $bytes = $imagick->getImageBlob(); 39 | if (strlen($bytes) <= 0) { echo "Failed to generate image.";} 40 | } 41 | 42 | circle($strokeColor, $fillColor, $backgroundColor, $originX, $originY, $endX, $endY) ; 43 | echo "Ok"; 44 | ?> 45 | --EXPECTF-- 46 | Ok -------------------------------------------------------------------------------- /tests/gmagickdraw-033_setClipPath_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test GmagickDraw, setClipPath 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | setStrokeColor($strokeColor); 16 | $draw->setFillColor($fillColor); 17 | $draw->setStrokeOpacity(1); 18 | $draw->setStrokeWidth(2); 19 | 20 | $clipPathName = 'testClipPath'; 21 | 22 | $draw->pushClipPath($clipPathName); 23 | $draw->rectangle(0, 0, 250, 250); 24 | $draw->popClipPath(); 25 | $draw->setClipPath($clipPathName); 26 | $draw->rectangle(100, 100, 400, 400); 27 | 28 | $storedPathName = $draw->getClipPath(); 29 | 30 | if (strcmp($storedPathName, $clipPathName) !== 0) { 31 | echo "Error retrieving clipPath: $storedPathName != $clipPathName \n"; 32 | } 33 | 34 | $imagick = new \Gmagick(); 35 | $imagick->newImage(500, 500, $backgroundColor); 36 | $imagick->setImageFormat("png"); 37 | 38 | $imagick->drawImage($draw); 39 | 40 | $bytes = $imagick->getImageBlob(); 41 | if (strlen($bytes) <= 0) { echo "Failed to generate image.";} 42 | } 43 | 44 | setClipPath($strokeColor, $fillColor, $backgroundColor) ; 45 | echo "Ok"; 46 | ?> 47 | --EXPECTF-- 48 | Ok -------------------------------------------------------------------------------- /tests/gmagickdraw_034_setClipRule_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test GmagickDraw, setClipRule 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | setStrokeColor($strokeColor); 17 | $draw->setFillColor($fillColor); 18 | $draw->setStrokeOpacity(1); 19 | $draw->setStrokeWidth(2); 20 | //\Gmagick::FILLRULE_EVENODD 21 | //\Gmagick::FILLRULE_NONZERO 22 | 23 | $clipPathName = 'testClipPath'; 24 | $draw->pushClipPath($clipPathName); 25 | $draw->setClipRule(\Gmagick::FILLRULE_EVENODD); 26 | 27 | $draw->rectangle(0, 0, 300, 500); 28 | $draw->rectangle(200, 0, 500, 500); 29 | $draw->popClipPath(); 30 | $draw->setClipPath($clipPathName); 31 | $draw->rectangle(200, 200, 300, 300); 32 | 33 | $clipRule = $draw->getClipRule(); 34 | if ($clipRule !== \Gmagick::FILLRULE_EVENODD) { 35 | echo "Failed to get correct clipRule $clipRule != \Gmagick::FILLRULE_EVENODD \n"; 36 | } 37 | 38 | $gmagick = new \Gmagick(); 39 | $gmagick->newImage(500, 500, $backgroundColor); 40 | $gmagick->setImageFormat("png"); 41 | 42 | $gmagick->drawImage($draw); 43 | 44 | $bytes = $gmagick->getImageBlob(); 45 | if (strlen($bytes) <= 0) { echo "Failed to generate image.";} 46 | } 47 | 48 | setClipRule($strokeColor, $fillColor, $backgroundColor) ; 49 | echo "Ok"; 50 | ?> 51 | --EXPECTF-- 52 | Ok -------------------------------------------------------------------------------- /tests/gmagickdraw_035_setClipUnits_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test GmagickDraw, setClipUnits 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | setStrokeColor($strokeColor); 17 | $draw->setFillColor($fillColor); 18 | $draw->setStrokeOpacity(1); 19 | $draw->setStrokeWidth(2); 20 | $clipPathName = 'testClipPath'; 21 | $draw->setClipUnits(\Gmagick::RESOLUTION_PIXELSPERINCH); 22 | $draw->pushClipPath($clipPathName); 23 | $draw->rectangle(0, 0, 250, 250); 24 | $draw->popClipPath(); 25 | $draw->setClipPath($clipPathName); 26 | $clipUnits = $draw->getClipUnits(); 27 | if ($clipUnits !== \Gmagick::RESOLUTION_PIXELSPERINCH) { 28 | echo "Failed to get correct clipUnits $clipRule != \Gmagick::RESOLUTION_PIXELSPERINCH \n"; 29 | } 30 | 31 | //RESOLUTION_PIXELSPERINCH 32 | //RESOLUTION_PIXELSPERCENTIMETER 33 | 34 | $draw->rectangle(200, 200, 300, 300); 35 | $imagick = new \Gmagick(); 36 | $imagick->newImage(500, 500, $backgroundColor); 37 | $imagick->setImageFormat("png"); 38 | 39 | $imagick->drawImage($draw); 40 | 41 | $bytes = $imagick->getImageBlob(); 42 | if (strlen($bytes) <= 0) { echo "Failed to generate image.";} 43 | } 44 | 45 | setClipUnits($strokeColor, $fillColor, $backgroundColor) ; 46 | echo "Ok"; 47 | ?> 48 | --EXPECTF-- 49 | Ok -------------------------------------------------------------------------------- /tests/gmagickdraw_036_pushPattern_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test GmagickDraw, pushPattern 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | setStrokeColor($strokeColor); 16 | $draw->setFillColor($fillColor); 17 | $draw->setStrokeWidth(1); 18 | $draw->setStrokeOpacity(1); 19 | $draw->setStrokeColor($strokeColor); 20 | $draw->setFillColor($fillColor); 21 | 22 | $draw->setStrokeWidth(1); 23 | 24 | $draw->pushPattern("MyFirstPattern", 0, 0, 50, 50); 25 | for ($x = 0; $x < 50; $x += 10) { 26 | for ($y = 0; $y < 50; $y += 5) { 27 | $positionX = $x + (($y / 5) % 5); 28 | $draw->rectangle($positionX, $y, $positionX + 5, $y + 5); 29 | } 30 | } 31 | $draw->popPattern(); 32 | 33 | $draw->setFillOpacity(0); 34 | $draw->rectangle(100, 100, 400, 400); 35 | $draw->setFillOpacity(1); 36 | 37 | $draw->setFillOpacity(1); 38 | 39 | $draw->pushGraphicContext(); 40 | $draw->setFillPatternURL('#MyFirstPattern'); 41 | $draw->setFillColor('yellow'); 42 | $draw->rectangle(100, 100, 400, 400); 43 | $draw->popGraphicContext(); 44 | 45 | $gmagick = new \Gmagick(); 46 | $gmagick->newImage(500, 500, $backgroundColor); 47 | $gmagick->setImageFormat("png"); 48 | 49 | $gmagick->drawImage($draw); 50 | 51 | $bytes = $gmagick->getImageBlob(); 52 | if (strlen($bytes) <= 0) { echo "Failed to generate image.";} 53 | } 54 | 55 | pushPattern($strokeColor, $fillColor, $backgroundColor) ; 56 | echo "Ok"; 57 | ?> 58 | --EXPECTF-- 59 | Ok -------------------------------------------------------------------------------- /tests/gmagickdraw_037_setFillRule_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test GmagickDraw, setFillRule 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | setStrokeWidth(1); 17 | $draw->setStrokeColor($strokeColor); 18 | $draw->setFillColor($fillColor); 19 | 20 | $fillRules = array(\Gmagick::FILLRULE_NONZERO, \Gmagick::FILLRULE_EVENODD); 21 | 22 | $points = 11; 23 | $size = 150; 24 | 25 | $draw->translate(175, 160); 26 | 27 | for ($x = 0; $x < 2; $x++) { 28 | $draw->setFillRule($fillRules[$x]); 29 | $draw->pathStart(); 30 | for ($n = 0; $n < $points * 2; $n++) { 31 | 32 | if ($n >= $points) { 33 | $angle = fmod($n * 360 * 4 / $points, 360) * pi() / 180; 34 | } 35 | else { 36 | $angle = fmod($n * 360 * 3 / $points, 360) * pi() / 180; 37 | } 38 | 39 | $positionX = $size * sin($angle); 40 | $positionY = $size * cos($angle); 41 | 42 | if ($n == 0) { 43 | $draw->pathMoveToAbsolute($positionX, $positionY); 44 | } 45 | else { 46 | $draw->pathLineToAbsolute($positionX, $positionY); 47 | } 48 | } 49 | 50 | $draw->pathClose(); 51 | $draw->pathFinish(); 52 | 53 | $currentFillRule = $draw->getFillRule(); 54 | 55 | if ($currentFillRule !== $fillRules[$x]) { 56 | echo "Failed to get correct fillRule $currentFillRule != ".$fillRules[$x]." \n"; 57 | } 58 | 59 | $draw->translate(325, 0); 60 | } 61 | 62 | $image = new \Gmagick(); 63 | $image->newImage(700, 320, $backgroundColor); 64 | $image->setImageFormat("png"); 65 | $image->drawImage($draw); 66 | 67 | $bytes = $image->getImageBlob(); 68 | if (strlen($bytes) <= 0) { echo "Failed to generate image.";} 69 | } 70 | 71 | setFillRule($fillColor, $strokeColor, $backgroundColor) ; 72 | echo "Ok"; 73 | ?> 74 | --EXPECTF-- 75 | Ok -------------------------------------------------------------------------------- /tests/gmagickdraw_038_setFontStretch_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test GmagickDraw, setFontStretch 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | setStrokeColor($strokeColor); 20 | $draw->setFillColor($fillColor); 21 | $draw->setStrokeWidth(2); 22 | $draw->setFontSize(36); 23 | 24 | $fontStretchTypes = array( 25 | \Gmagick::STRETCH_ULTRACONDENSED, 26 | \Gmagick::STRETCH_CONDENSED, 27 | \Gmagick::STRETCH_SEMICONDENSED, 28 | \Gmagick::STRETCH_SEMIEXPANDED, 29 | \Gmagick::STRETCH_EXPANDED, 30 | \Gmagick::STRETCH_EXTRAEXPANDED, 31 | \Gmagick::STRETCH_ULTRAEXPANDED, 32 | \Gmagick::STRETCH_ANY 33 | ); 34 | 35 | $offset = 0; 36 | foreach ($fontStretchTypes as $fontStretch) { 37 | $draw->setFontStretch($fontStretch); 38 | $draw->annotate(50, 75 + $offset, "Lorem Ipsum!"); 39 | $offset += 50; 40 | 41 | $currentFontStretch = $draw->getFontStretch($fontStretch); 42 | 43 | if ($currentFontStretch !== $fontStretch) { 44 | echo "Failed to get correct fontStretch $currentFontStretch != $fontStretch \n"; 45 | } 46 | } 47 | 48 | $gmagick = new \Gmagick(); 49 | $gmagick->newImage(500, 500, $backgroundColor); 50 | $gmagick->setImageFormat("png"); 51 | $gmagick->drawImage($draw); 52 | 53 | $bytes = $gmagick->getImageBlob(); 54 | if (strlen($bytes) <= 0) { echo "Failed to generate image.";} 55 | } 56 | 57 | setFontStretch($fillColor, $strokeColor, $backgroundColor) ; 58 | echo "Ok"; 59 | ?> 60 | --EXPECTF-- 61 | Ok -------------------------------------------------------------------------------- /tests/gmagickdraw_039_pathStart_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test GmagickDraw, pathStart 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | setStrokeOpacity(1); 17 | $draw->setStrokeColor($strokeColor); 18 | $draw->setFillColor($fillColor); 19 | 20 | $draw->setStrokeWidth(2); 21 | $draw->setFontSize(72); 22 | 23 | $draw->pathStart(); 24 | $draw->pathMoveToAbsolute(50, 50); 25 | $draw->pathLineToAbsolute(100, 50); 26 | $draw->pathLineToRelative(0, 50); 27 | $draw->pathLineToHorizontalRelative(-50); 28 | $draw->pathFinish(); 29 | 30 | $draw->pathStart(); 31 | $draw->pathMoveToAbsolute(50, 50); 32 | $draw->pathMoveToRelative(300, 0); 33 | $draw->pathLineToRelative(50, 0); 34 | $draw->pathLineToVerticalRelative(50); 35 | $draw->pathLineToHorizontalAbsolute(350); 36 | $draw->pathclose(); 37 | $draw->pathFinish(); 38 | 39 | $draw->pathStart(); 40 | $draw->pathMoveToAbsolute(50, 300); 41 | $draw->pathCurveToAbsolute(50, 300, 100, 200, 300, 300); 42 | $draw->pathLineToVerticalAbsolute(350); 43 | $draw->pathFinish(); 44 | 45 | $gmagick = new \Gmagick(); 46 | $gmagick->newImage(500, 500, $backgroundColor); 47 | $gmagick->setImageFormat("png"); 48 | 49 | $gmagick->drawImage($draw); 50 | 51 | $bytes = $gmagick->getImageBlob(); 52 | if (strlen($bytes) <= 0) { echo "Failed to generate image.";} 53 | } 54 | 55 | pathStart($strokeColor, $fillColor, $backgroundColor) ; 56 | echo "Ok"; 57 | ?> 58 | --EXPECTF-- 59 | Ok -------------------------------------------------------------------------------- /tests/gmagickdraw_040_pathCurveToQuadraticBezierAbsolute_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test GmagickDraw, pathCurveToQuadraticBezierAbsolute 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | setStrokeOpacity(1); 17 | $draw->setStrokeColor($strokeColor); 18 | $draw->setFillColor($fillColor); 19 | 20 | $draw->setStrokeWidth(2); 21 | $draw->setFontSize(72); 22 | 23 | $draw->pathStart(); 24 | $draw->pathMoveToAbsolute(50,250); 25 | 26 | // This specifies a quadratic bezier curve with the current position as the start 27 | // point, the control point is the first two params, and the end point is the last two params. 28 | $draw->pathCurveToQuadraticBezierAbsolute( 29 | 150,50, 30 | 250,250 31 | ); 32 | 33 | // This specifies a quadratic bezier curve with the current position as the start 34 | // point, the control point is mirrored from the previous curves control point 35 | // and the end point is defined by the x, y values. 36 | $draw->pathCurveToQuadraticBezierSmoothAbsolute( 37 | 450,250 38 | ); 39 | 40 | // This specifies a quadratic bezier curve with the current position as the start 41 | // point, the control point is mirrored from the previous curves control point 42 | // and the end point is defined relative from the current position by the x, y values. 43 | $draw->pathCurveToQuadraticBezierSmoothRelative( 44 | 200,-100 45 | ); 46 | 47 | $draw->pathFinish(); 48 | 49 | $gmagick = new \Gmagick(); 50 | $gmagick->newImage(700, 500, $backgroundColor); 51 | $gmagick->setImageFormat("png"); 52 | 53 | $gmagick->drawImage($draw); 54 | 55 | $bytes = $gmagick->getImageBlob(); 56 | if (strlen($bytes) <= 0) { echo "Failed to generate image.";} 57 | 58 | } 59 | 60 | pathCurveToQuadraticBezierAbsolute($strokeColor, $fillColor, $backgroundColor) ; 61 | echo "Ok"; 62 | ?> 63 | --EXPECTF-- 64 | Ok -------------------------------------------------------------------------------- /tests/gmagickdraw_041_popDefs_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test GmagickDraw, popDefs 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | setStrokeColor($strokeColor); 17 | $draw->setFillColor($fillColor); 18 | $draw->setstrokeOpacity(1); 19 | $draw->setStrokeWidth(2); 20 | $draw->setFontSize(72); 21 | $draw->pushDefs(); 22 | $draw->setStrokeColor('white'); 23 | $draw->rectangle(50, 50, 200, 200); 24 | $draw->popDefs(); 25 | 26 | $draw->rectangle(300, 50, 450, 200); 27 | 28 | $gmagick = new \Gmagick(); 29 | $gmagick->newImage(500, 500, $backgroundColor); 30 | $gmagick->setImageFormat("png"); 31 | $gmagick->drawImage($draw); 32 | 33 | $bytes = $gmagick->getImageBlob(); 34 | if (strlen($bytes) <= 0) { echo "Failed to generate image.";} 35 | } 36 | 37 | popDefs($strokeColor, $fillColor, $backgroundColor) ; 38 | echo "Ok"; 39 | ?> 40 | --EXPECTF-- 41 | Ok -------------------------------------------------------------------------------- /tests/gmagickdraw_042_setTextAntialias_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test GmagickDraw, setTextAntialias 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | setStrokeColor('none'); 19 | $draw->setFillColor($fillColor); 20 | $draw->setStrokeWidth(1); 21 | $draw->setFontSize(32); 22 | $draw->setTextAntialias(false); 23 | $draw->annotate(5, 30, "Lorem Ipsum!"); 24 | $draw->setTextAntialias(true); 25 | $draw->annotate(5, 65, "Lorem Ipsum!"); 26 | 27 | $currentValue = $draw->getTextAntialias(); 28 | 29 | if ($currentValue !== true) { 30 | echo "Failed to get textAntiAlias setting, which should be true\n"; 31 | var_dump($currentValue); 32 | } 33 | 34 | $gmagick = new \Gmagick(); 35 | $gmagick->newImage(220, 80, $backgroundColor); 36 | $gmagick->setImageFormat("png"); 37 | $gmagick->drawImage($draw); 38 | 39 | //Scale the image so that people can see the aliasing. 40 | $gmagick->scaleImage(220 * 6, 80 * 6); 41 | $gmagick->cropImage(640, 480, 0, 0); 42 | 43 | $bytes = $gmagick->getImageBlob(); 44 | if (strlen($bytes) <= 0) { echo "Failed to generate image.";} 45 | } 46 | 47 | setTextAntialias($fillColor, $backgroundColor); 48 | echo "Ok"; 49 | ?> 50 | --EXPECTF-- 51 | Ok -------------------------------------------------------------------------------- /tests/gmagickdraw_043_setViewBox_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test GmagickDraw, setViewBox 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | setStrokeColor($strokeColor); 17 | $draw->setFillColor($fillColor); 18 | $draw->setStrokeWidth(2); 19 | $draw->setFontSize(72); 20 | 21 | /* 22 | 23 | Sets the overall canvas size to be recorded with the drawing vector data. Usually this will be specified using the same size as the canvas image. When the vector data is saved to SVG or MVG formats, the viewbox is use to specify the size of the canvas image that a viewer will render the vector data on. 24 | 25 | */ 26 | 27 | $draw->circle(250, 250, 250, 0); 28 | $draw->setviewbox(0, 0, 200, 200); 29 | $draw->circle(125, 250, 250, 250); 30 | $draw->translate(250, 125); 31 | $draw->circle(0, 0, 125, 0); 32 | 33 | 34 | $gmagick = new \Gmagick(); 35 | $gmagick->newImage(500, 500, $backgroundColor); 36 | $gmagick->setImageFormat("png"); 37 | 38 | $gmagick->drawImage($draw); 39 | 40 | $bytes = $gmagick->getImageBlob(); 41 | if (strlen($bytes) <= 0) { echo "Failed to generate image.";} 42 | } 43 | 44 | setViewBox($strokeColor, $fillColor, $backgroundColor) ; 45 | echo "Ok"; 46 | ?> 47 | --EXPECTF-- 48 | Ok -------------------------------------------------------------------------------- /tests/gmagickdraw_044_setTextUnderColor_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test GmagickDraw, setTextUnderColor 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | setStrokeColor($strokeColor); 20 | $draw->setFillColor($fillColor); 21 | $draw->setStrokeWidth(2); 22 | $draw->setFontSize(72); 23 | $draw->annotate(50, 75, "Lorem Ipsum!"); 24 | $draw->setTextUnderColor($textUnderColor); 25 | $draw->annotate(50, 175, "Lorem Ipsum!"); 26 | 27 | $gmagick = new \Gmagick(); 28 | $gmagick->newImage(500, 500, $backgroundColor); 29 | $gmagick->setImageFormat("png"); 30 | $gmagick->drawImage($draw); 31 | 32 | $bytes = $gmagick->getImageBlob(); 33 | if (strlen($bytes) <= 0) { echo "Failed to generate image.";} 34 | } 35 | 36 | setTextUnderColor($strokeColor, $fillColor, $backgroundColor, $textUnderColor) ; 37 | echo "Ok"; 38 | ?> 39 | --EXPECTF-- 40 | Ok -------------------------------------------------------------------------------- /tests/gmagickdraw_045_setFontFamily_basic.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test GmagickDraw, setFontFamily 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | setStrokeColor($strokeColor); 23 | $draw->setFillColor($fillColor); 24 | //TODO - actually use setFontFamily 25 | $draw->setStrokeWidth(2); 26 | 27 | $draw->setFontSize(24); 28 | $draw->annotate(50, 50, "Lorem Ipsum!"); 29 | 30 | $draw->setFontSize(36); 31 | $draw->annotate(50, 100, "Lorem Ipsum!"); 32 | 33 | $draw->setFontSize(48); 34 | $draw->annotate(50, 150, "Lorem Ipsum!"); 35 | 36 | $draw->setFontSize(60); 37 | $draw->annotate(50, 200, "Lorem Ipsum!"); 38 | 39 | $draw->setFontSize(72); 40 | $draw->annotate(50, 250, "Lorem Ipsum!"); 41 | 42 | $gmagick = new \Gmagick(); 43 | $gmagick->newImage(500, 500, $backgroundColor); 44 | $gmagick->setImageFormat("png"); 45 | $gmagick->drawImage($draw); 46 | 47 | $bytes = $gmagick->getImageBlob(); 48 | if (strlen($bytes) <= 0) { echo "Failed to generate image.";} 49 | } 50 | 51 | setFontFamily($fillColor, $strokeColor, $backgroundColor) ; 52 | echo "Ok"; 53 | ?> 54 | --EXPECTF-- 55 | Ok -------------------------------------------------------------------------------- /tests/gmagickpixel-001-setcolor_getcolor.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test setColor and getColor methods 3 | --SKIPIF-- 4 | 9 | --FILE-- 10 | getColor()) . "\n"; 14 | var_dump($pixel->setColor($pixel->getColor())); 15 | echo strcmp($color, $pixel->getColor()) . "\n"; 16 | ?> 17 | --EXPECTF-- 18 | 0 19 | object(GmagickPixel)#%d (%d) { 20 | } 21 | 0 22 | -------------------------------------------------------------------------------- /tests/gmagickpixel-002-setcolorvalue_getcolorvalue.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test setColorValue and getColorValue methods 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | getColorValue(Gmagick::COLOR_BLACK). "\n"; 12 | $gp->setColorValue(Gmagick::COLOR_BLACK,1); 13 | echo $gp->getColorValue(Gmagick::COLOR_BLACK). "\n"; 14 | ?> 15 | --EXPECTF-- 16 | 0 17 | 1 -------------------------------------------------------------------------------- /tests/gmagickpixel-003-getcolorcount.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test getColorcount method 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | getColorCount(); 13 | ?> 14 | --EXPECTF-- 15 | 0 -------------------------------------------------------------------------------- /tests/gmagickpixel-004-clone.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test object cloning and get 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 13 | --EXPECTF-- 14 | -------------------------------------------------------------------------------- /tests/gmagickpixel-005-setcolorvaluequantum_getcolorvaluequantum.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test setColorValueQuantum and getColorValueQuantum methods 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | getColorValueQuantum(Gmagick::COLOR_BLACK). "\n"; 11 | $gp->setColorValueQuantum(Gmagick::COLOR_BLACK,1); 12 | echo $gp->getColorValueQuantum(Gmagick::COLOR_BLACK). "\n"; 13 | try { 14 | $gp->setColorValueQuantum(123456, 1); 15 | echo "GmagickPixelException was not thrown".PHP_EOL; 16 | } catch (GmagickPixelException $gpe) { 17 | //This is the expected exception 18 | echo $gpe->getMessage(); 19 | } 20 | ?> 21 | --EXPECTF-- 22 | 0 23 | 1 24 | Unknown color type: 123456 25 | -------------------------------------------------------------------------------- /tests/gmagickpixel-006-setcolorcount.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test getColorcount method 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | setColorCount(2); 13 | echo $pixel->getColorCount(); 14 | ?> 15 | --EXPECTF-- 16 | 2 -------------------------------------------------------------------------------- /tests/hald_8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vitoc/gmagick/2936e731e964719d84995a1e64722de5c5c0ee48/tests/hald_8.png -------------------------------------------------------------------------------- /tests/skipif.inc: -------------------------------------------------------------------------------- 1 | 19 | --EXPECTF-- 20 | OK -------------------------------------------------------------------------------- /util/graphicsmagick_dependency.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Give an error if the download fails. 4 | set -e 5 | # Echo all commands 6 | set -x 7 | 8 | graphicsmagick_fetch_and_build () { 9 | local version=$1 10 | local quantum=$2 11 | 12 | echo "version is ${version}, quantum depth is ${quantum}" 13 | gm_dir=${HOME}/gm/graphicsmagick_${version}_${quantum} 14 | 15 | 16 | # Figure out if the version is already there. 17 | case $version in 18 | 19 | dev) 20 | echo "Dev always needs updating" 21 | ;; 22 | 23 | *) 24 | # Both individual commits, and tagged versions are cacheable 25 | if [ -d "${gm_dir}" ]; then 26 | echo "Using cached directory ${gm_dir}" 27 | return 28 | fi 29 | ;; 30 | esac 31 | 32 | 33 | # Fetch the relevant version 34 | case $version in 35 | dev) 36 | set -e 37 | hg_dir="${HOME}/gm/hg_${version}_${quantum}" 38 | 39 | mkdir -p "${hg_dir}" 40 | cd "${hg_dir}" 41 | 42 | if [[ ! -d "GM" ]]; then 43 | hg clone http://hg.code.sf.net/p/graphicsmagick/code GM 44 | fi 45 | cd GM 46 | hg pull 47 | hg update 48 | ;; 49 | 50 | *) 51 | echo "version is ${version}" 52 | set +e 53 | # The next line can error 54 | start_str=${version:0:6} 55 | set -e 56 | 57 | # Currently hg doesn't allow fetching commits? 58 | # Leave this in for now - getting individual commits is great for bisecting 59 | # problems. 60 | #if [ "${start_str}" == "commit" ]; then 61 | # sha=${version:7:47} 62 | # wget -O "GraphicsMagick-${sha}.tar.gz" "https://github.com/ImageMagick/ImageMagick/archive/${sha}.tar.gz" 63 | # tar xvfz GraphicsMagick-${sha}.tar.gz 64 | # cd "GraphicsMagick-${sha}" 65 | #else 66 | 67 | wget -O GraphicsMagick-${version}.tar.gz http://sourceforge.net/projects/graphicsmagick/files/graphicsmagick/${version}/GraphicsMagick-${version}.tar.gz/download 68 | tar xfz GraphicsMagick-${version}.tar.gz 69 | cd GraphicsMagick-* 70 | #fi 71 | ;; 72 | esac 73 | 74 | 75 | # Actually build the project 76 | 77 | #ignore compile warnings/errors 78 | set +e 79 | 80 | ./configure \ 81 | --prefix="${HOME}/gm/graphicsmagick_${version}_${quantum}" \ 82 | --with-quantum-depth=${quantum} \ 83 | --enable-shared \ 84 | --exec-prefix="${HOME}/gm/graphicsmagick_${version}_${quantum}" \ 85 | --disable-openmp \ 86 | --with-perl=no \ 87 | --without-threads \ 88 | --without-magick-plus-plus 89 | 90 | make -j 4 91 | make install 92 | cd .. 93 | } 94 | 95 | graphicsmagick_fetch_and_build $1 $2 -------------------------------------------------------------------------------- /util/scanHeaders.php: -------------------------------------------------------------------------------- 1 | [ 35 | 'ColorspaceType', 36 | ], 37 | 'magick/compare.h' => [ 38 | //'HighlightStyle', // not exposed currently 39 | 'MetricType', 40 | ], 41 | 'magick/constitute.h' => [ 42 | // 'QuantumType', // not exposed currently 43 | // 'QuantumSampleType', // not exposed currently 44 | 'StorageType', 45 | ], 46 | 'magick/image.h' => [ 47 | // 'AlphaType', // not exposed currently 48 | 'ChannelType', 49 | // 'ClassType', // not exposed currently 50 | 'CompositeOperator', 51 | 'CompressionType', 52 | 'DisposeType', 53 | // 'EndianType', // not exposed currently 54 | 'FilterTypes', 55 | //'GeometryFlags', // not exposed currently 56 | // 'GravityType', // not exposed currently 57 | 'ImageType', 58 | 'InterlaceType', 59 | 'MontageMode', 60 | 'NoiseType', 61 | 'OrientationType', 62 | 'PreviewType', 63 | 'RenderingIntent', 64 | 'ResolutionType', 65 | ], 66 | 'magick/operator.h' => [ 67 | //'QuantumOperator', // not exposed currently 68 | ], 69 | 70 | 'magick/pixel_cache.h' => [ 71 | 'VirtualPixelMethod', 72 | ], 73 | 74 | 'magick/render.h' => [ 75 | 'AlignType', 76 | 'ClipPathUnits', 77 | 'DecorationType', 78 | 'FillRule', 79 | // 'GradientType', // not exposed currently 80 | 'LineCap', 81 | 'LineJoin', 82 | 'PaintMethod', 83 | //'PrimitiveType', // not exposed currently 84 | // 'ReferenceType', // not exposed currently 85 | // 'SpreadMethod' // not exposed currently 86 | ], 87 | 88 | 'magick/resource.h' => [ 89 | 'ResourceType' 90 | ], 91 | 92 | 'magick/type.h' => [ 93 | 'StretchType', 94 | 'StyleType', 95 | ], 96 | 97 | ]; 98 | 99 | $gmagickHelperContents = file_get_contents("../gmagick_helpers.c"); 100 | 101 | if ($gmagickHelperContents == false) { 102 | echo "failed to read ../gmagick_helpers.c\n"; 103 | exit(-1); 104 | } 105 | 106 | // We don't use these enums currently. 107 | $skipEnumList = [ 108 | // 'ComplexOperator', // used by ComplexImages - not exposed in wand api 109 | // 'PixelComponent', // present in 6.9.2 but not used? 110 | // 'PixelIntensityMethod', // Used by GrayscaleImage function that is not expose in wand api 111 | ]; 112 | 113 | 114 | foreach ($enumToCheck as $filename => $enums) { 115 | foreach ($enums as $enum) { 116 | if (in_array($enum, $skipEnumList)) { 117 | //We don't use these enums currently. 118 | continue; 119 | } 120 | 121 | $enumNameList = getEnumList($enum, $pathToImageMagick.$filename); 122 | foreach ($enumNameList as $enumName) { 123 | //echo "checking for $enumName\n"; 124 | if (stripos($gmagickHelperContents, $enumName) === false) { 125 | echo "value '$enumName' is missing for enum $enum.\n"; 126 | } 127 | } 128 | } 129 | } 130 | 131 | 132 | 133 | 134 | 135 | function getEnumList($enum, $filename) 136 | { 137 | $fileContents = file_get_contents($filename); 138 | 139 | if ($fileContents === false) { 140 | echo "Could not read file $filename \n"; 141 | exit(-1); 142 | } 143 | 144 | // These characters mess with the matching. 145 | $searchReplace = [ 146 | ',' 147 | ]; 148 | 149 | $pregString = "#\{([^\{\}]*)\}\s*$enum#sU"; 150 | 151 | preg_match($pregString, $fileContents, $matches); 152 | 153 | if (count($matches) == 0) { 154 | echo "Couldn't find enum $enum in $filename.\n"; 155 | return []; 156 | } 157 | 158 | $match = $matches[1]; 159 | 160 | foreach ($searchReplace as $search) { 161 | $match = str_replace($search, '', $match); 162 | } 163 | 164 | $match = preg_replace("#/\*.*\*/#sU", '', $match); 165 | 166 | $vars = explode("\n", $match); 167 | 168 | $trimmedVars = []; 169 | 170 | foreach ($vars as $var) { 171 | if (stripos($var, 'Undefined') !== false) { 172 | continue; 173 | } 174 | 175 | if (stripos($var, '#undef') !== false) { 176 | continue; 177 | } 178 | 179 | $equalsPosition = strpos($var, '='); 180 | if ($equalsPosition !== false) { 181 | $var = substr($var, 0, $equalsPosition); 182 | } 183 | 184 | $entry = trim($var); 185 | 186 | if (strlen($entry) === 0) { 187 | continue; 188 | } 189 | $trimmedVars[] = $entry; 190 | } 191 | 192 | return $trimmedVars; 193 | } 194 | --------------------------------------------------------------------------------