Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When will the imagick extension support php8.4? Now it will report an error #698

Open
kejilion opened this issue Nov 22, 2024 · 33 comments
Open

Comments

@kejilion
Copy link


Warning: PHP Startup: Unable to load dynamic library 'imagick.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20240924/imagick.so (Error relocating /usr/local/lib/php/extensions/no-debug-non-zts-20240924/imagick.so: php_strtolower: symbol not found), /usr/local/lib/php/extensions/no-debug-non-zts-20240924/imagick.so.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20240924/imagick.so.so: No such file or directory)) in Unknown on line 0

How do I solve this problem? Thank you

@yendyr
Copy link

yendyr commented Nov 22, 2024

same problem here

@kejilion
Copy link
Author

I'm trying to install it like this, I don't know if it works

docker exec php install-php-extensions 65e27f2bc0

@picov
Copy link

picov commented Nov 22, 2024

PHP 8.4.1 with ImageMagick-7.1.1-41
#pecl install imagick
....
In /tmp/pear/install/imagick/Imagick.stub.php:
Imagick::newImage(): Parameter format has null default, but is not nullable
make: *** [Makefile:191: /tmp/pear/install/imagick/Imagick_arginfo.h] Error 1
ERROR: `make INSTALL_ROOT="/tmp/pear/install/pear-build-rootti7iddt3pa35cOi0VJK/install-imagick-3.7.0" install' failed

@nephaste
Copy link

nephaste commented Nov 22, 2024

same issue with PECL install
seems better building from source... works on aarch64, but my x86_64 version has issue (weird)

edit : finally worked problem was between keybard and chair... using a phpize from source and ./configure in my prefix all runs

@kejilion
Copy link
Author

I have successfully installed imagick in the docker php:fpm-alpine build I used

@pennedav
Copy link

Running into an issue while building using the Debian (Bookworm) PHP 8.4 Apache image.

Partial Dockerfile:

FROM php:8.4-apache-bookworm
...
RUN pecl install imagick-3.7.0 \
    && docker-php-ext-enable imagick
...

Selected output:

18.17 In /tmp/pear/temp/imagick/Imagick.stub.php:
18.17 Imagick::newImage(): Parameter format has null default, but is not nullable
18.18 make: *** [Makefile:191: /tmp/pear/temp/imagick/Imagick_arginfo.h] Error 1
18.19 ERROR: `make INSTALL_ROOT="/tmp/pear/temp/pear-build-defaultuserogvs7jscec7c7Cd3ecS/install-imagick-3.7.0" install' failed
------
Dockerfile:27
--------------------
  26 |
  27 | >>> RUN pecl install imagick-3.7.0 \
  28 | >>>     && docker-php-ext-enable imagick
  29 |
--------------------
ERROR: failed to solve: process "/bin/sh -c pecl install imagick-3.7.0     && docker-php-ext-enable imagick" did not complete successfully: exit code: 1

@BowFarmer
Copy link

When I try to install it on php 8.4 with pecl, I get this:
/imagick-3.7.0/imagick.c:606:7: error: call to undeclared function 'php_strtolower'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]

@BowFarmer
Copy link

I did manage to work around the 'php_strtolower' issue with php 8.4. I install imagick with pecl, and during the installation the process stops to confirm the prefix for the installation:

Please provide the prefix of ImageMagick installation [autodetect] :

Before hitting enter I edit imagick.c which at that point in my case is in:

/private/tmp/pear/temp/imagick/imagick.c

And I comment out line 606 with the 'php_strtolower' call which no longer seems to work in php 8.4.
//php_strtolower(Z_STRVAL_P(retval), Z_STRLEN_P(retval));
After that I let pecl finish the installation and it has no problems compiling and installing imagick. And I have imagick working with php 8.4 and it works fine with WordPress. Not sure what the implications are of not having that string not being converted to lowercase, but I haven't run into issues yet. I'm primarily using imagick for a WordPress development site and am testing the ramifications of using php 8.4.

@usarise
Copy link

usarise commented Nov 25, 2024

And I comment out line 606 with the 'php_strtolower' call which no longer seems to work in php 8.4.
//php_strtolower(Z_STRVAL_P(retval), Z_STRLEN_P(retval));

It is better to make changes from this branch

@picov
Copy link

picov commented Nov 25, 2024

But then real question is: does this project is still active ?
Latest official release is v3.7.0 released on 2022-01-11 !
Latest commit is on Mar 18, 2023 !

@BowFarmer
Copy link

Imagick is primarily a wrapper that allows PHP to interface with ImageMagick, where all the actual image manipulation happens. Unlike ImageMagick, which needs to evolve to keep up with new formats, improvements, and image processing capabilities, Imagick's role is simpler—it's about maintaining compatibility and providing PHP bindings. Therefore, it doesn't necessarily need frequent changes unless compatibility issues arise, as with new PHP versions or changes in ImageMagick's API.

@picov
Copy link

picov commented Nov 25, 2024

@BowFarmer
It looks like there are compatibility issues however.

@BowFarmer
Copy link

BowFarmer commented Nov 25, 2024

I'm not working on this project but as usarise pointed out earlier, there is a fix that is being worked on:
65e27f2bc0
You can see three instances in that fix where php_strtolower has been changed to zend_str_tolower for PHP 8.4 compatibility.

@jderusse
Copy link

actually, I feel the project is not maintain anymore.
There is another issue with pho 8.3 that is fixed in master but no released (see this issue for example #640)

I believe, someone should fork it, a d make it the new default.

@usarise
Copy link

usarise commented Nov 25, 2024

Docker users don't feel the full impact of stagnation as much.
https://github.com/mlocati/docker-php-extension-installer uses the https://github.com/mvorisek/imagick or https://github.com/mvorisek/imagick/tree/fix_php84 branch, which contains all actual fixes.

@usarise
Copy link

usarise commented Nov 25, 2024

Latest commit is on Mar 18, 2023 !

@picov In reality latest commit is on Jul 7, 2024.
Relevant branch here is actually -> https://github.com/Imagick/imagick/tree/develop

@BowFarmer
Copy link

So for those of using pecl, and installing imagick as pecl install imagick, is there a timeline when those changes for php 8.4 will be in the main branch?

@usarise
Copy link

usarise commented Nov 25, 2024

@BowFarmer Of course not.
It doesn't even include all the fixes for PHP 8.3 yet.

@usarise
Copy link

usarise commented Nov 25, 2024

@BowFarmer Latest released for pecl 2022-01-11,
a month after the release of 8.1.1
Since then, 3 new versions of the PHP have been released, but pecl is still not updated.

@tianon
Copy link

tianon commented Nov 25, 2024

I think this is a duplicate of #689

@GeLoLabs
Copy link

GeLoLabs commented Dec 1, 2024

For those who want something working, here my Dockerfile:

# Imagick
ARG IMAGICK_VERSION=3.7.0
RUN set -eux \
    && apk add --no-cache \
      imagemagick \
      jpegoptim \
      libwebp \
      libwebp-tools \
    && apk add --no-cache --virtual .imagick-deps \
      $PHPIZE_DEPS \
      imagemagick-dev \
      libjpeg-turbo-dev \
      libpng-dev \
      libwebp-dev \
#    && pecl install imagick-"$IMAGICK_VERSION" \
#    && docker-php-ext-enable imagick \
#    && apk del .imagick-deps
    && curl -L -o /tmp/imagick.tar.gz https://github.com/Imagick/imagick/archive/tags/${IMAGICK_VERSION}.tar.gz \
    && tar --strip-components=1 -xf /tmp/imagick.tar.gz \
    && sed -i 's/php_strtolower/zend_str_tolower/g' imagick.c \
    && phpize \
    && ./configure \
    && make \
    && make install \
    && echo "extension=imagick.so" > /usr/local/etc/php/conf.d/ext-imagick.ini \
    && rm -rf /tmp/* \
    && apk del .imagick-deps

@jamesfreeman959
Copy link

Thanks for this - can confirm it works for be building on the php:8.3.14-fpm container image.

@cyformatician
Copy link

I did manage to work around the 'php_strtolower' issue with php 8.4. I install imagick with pecl, and during the installation the process stops to confirm the prefix for the installation:

Please provide the prefix of ImageMagick installation [autodetect] :

Before hitting enter I edit imagick.c which at that point in my case is in:

/private/tmp/pear/temp/imagick/imagick.c

And I comment out line 606 with the 'php_strtolower' call which no longer seems to work in php 8.4. //php_strtolower(Z_STRVAL_P(retval), Z_STRLEN_P(retval)); After that I let pecl finish the installation and it has no problems compiling and installing imagick. And I have imagick working with php 8.4 and it works fine with WordPress. Not sure what the implications are of not having that string not being converted to lowercase, but I haven't run into issues yet. I'm primarily using imagick for a WordPress development site and am testing the ramifications of using php 8.4.

Many thanks for sharing the workaround ... this was it but instead of commenting the line out, I replaced php_strtolower with zend_str_tolower.

Cheers!

@BowFarmer
Copy link

Thanks.

@joeworkman
Copy link

I did manage to work around the 'php_strtolower' issue with php 8.4. I install imagick with pecl, and during the installation the process stops to confirm the prefix for the installation:

Please provide the prefix of ImageMagick installation [autodetect] :

Before hitting enter I edit imagick.c which at that point in my case is in:

/private/tmp/pear/temp/imagick/imagick.c

And I comment out line 606 with the 'php_strtolower' call which no longer seems to work in php 8.4. //php_strtolower(Z_STRVAL_P(retval), Z_STRLEN_P(retval)); After that I let pecl finish the installation and it has no problems compiling and installing imagick. And I have imagick working with php 8.4 and it works fine with WordPress. Not sure what the implications are of not having that string not being converted to lowercase, but I haven't run into issues yet. I'm primarily using imagick for a WordPress development site and am testing the ramifications of using php 8.4.

Many thanks for sharing the workaround ... this was it but instead of commenting the line out, I replaced php_strtolower with zend_str_tolower.

Cheers!

This is exactly what I did, and it just worked for me. I am running this on an Intel Mac via homebrew.

@PaulCombal
Copy link

PaulCombal commented Dec 7, 2024

I'm suddenly hit with something that doesn't look like a PHP version error:

122.1 In /tmp/pear/temp/imagick/Imagick.stub.php:
122.1 Imagick::newImage(): Parameter format has null default, but is not nullable
122.1 make: *** [Makefile:191: /tmp/pear/temp/imagick/Imagick_arginfo.h] Error 1
122.1 ERROR: `make -j8 INSTALL_ROOT="/tmp/pear/temp/pear-build-defaultuser2382nrd40alp54NOMPX/install-imagick-3.7.0" install' failed

The deployment somehow still succeeded so I'm at a loss

@wilianmaique
Copy link

[3.7.0](https://pecl.php.net/package/imagick/3.7.0/windows) 3.7.0 not work in php 8.4.2

waja added a commit to waja/docker-php84-fpm that referenced this issue Dec 23, 2024
@olivervogel
Copy link

olivervogel commented Dec 30, 2024

I managed to get Imagick to run under PHP 8.4 and macOS with the following adjustments.

  1. Install Imagemagick
brew install imagemagick
  1. Install & Configure Imagick
git clone https://github.com/Imagick/imagick
cd imagick
phpize && ./configure
  1. Important part: Comment out line 606 in imagick/imagick.c otherwise make will fail

  2. Install Imagick

make
make install
  1. Enable Imagick

Add extension="imagick.so" to php.ini.

@naizhao
Copy link

naizhao commented Dec 31, 2024

ServBay's build works.

@proligde
Copy link

Not sure if this info helps, but I guess it's relevant:

I have a multi arch build pipeline here using the official php 8.4 container image as build base, adding imagick-3.7.0 and it is working well on x86 but on arm64 I get the same error as @picov Imagick::newImage(): Parameter format has null default, but is not nullable so I assume at least that very issue might be architecture related. Or at least related to the underlying versions in the different architectures.

@tiger42
Copy link

tiger42 commented Jan 3, 2025

I have exactly the same problem as @proligde in my multi arch build pipeline. I am also using the official PHP 8.4 image as base image. The amd64 (x86) version compiles fine, the arm64 version fails with the error mentioned before.

@HansVanEijsden
Copy link

I have modified my PHP build script to apply the patch automatically, from https://patch-diff.githubusercontent.com/raw/Imagick/imagick/pull/690.patch
For who finds it useful, I've attached my build script.
php84.sh.txt

@fmonts
Copy link

fmonts commented Jan 17, 2025

The build by deb.sury.org for ubuntu (tested on 24.04) works

# add-apt-repository ppa:ondrej/php
# apt install php8.4-imagick
# php -v
PHP 8.4.2 (cli) (built: Dec 24 2024 06:05:05) (NTS)
# php --ri imagick

imagick

imagick module => enabled
imagick module version => 3.7.0
imagick classes => Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator, ImagickKernel
Imagick compiled with ImageMagick version => ImageMagick 6.9.12-98 Q16 x86_64 18038 https://legacy.imagemagick.org
Imagick using ImageMagick library version => ImageMagick 6.9.12-98 Q16 x86_64 18038 https://legacy.imagemagick.org
ImageMagick copyright => (C) 1999 ImageMagick Studio LLC
ImageMagick release date => 2024-03-31
ImageMagick number of supported formats:  => 240

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests