php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81235 Imagick::newPseudoImage gives open_basedir restriction error
Submitted: 2021-07-08 13:10 UTC Modified: 2021-10-01 10:16 UTC
Votes:5
Avg. Score:4.8 ± 0.4
Reproduced:5 of 5 (100.0%)
Same Version:3 (60.0%)
Same OS:1 (20.0%)
From: meelmva at hotmail dot com Assigned: cmb (profile)
Status: Closed Package: imagick (PECL)
PHP Version: 7.4.21 OS: Docker on Debian 10.9 on WSL2
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: meelmva at hotmail dot com
New email:
PHP Version: OS:

 

 [2021-07-08 13:10 UTC] meelmva at hotmail dot com
Description:
------------
When creating a pseudo image with newPseudoImage() and a pseudoString "canvas:white" a ImagickException is thrown with the message:

open_basedir restriction in effect. File(canvas:white) is not within the allowed path(s) in /path/to/script.php

When running the script on PHP 7.4.20 no error is given.

To test this, make sure that the open_basedir configuration option is set to the current directory containing the test script.

Test script:
---------------
<?php

ini_set('display_errors', 1);
error_reporting(E_ALL);

$blankPage = new \Imagick();
$blankPage->newPseudoImage(10, 10, "canvas:white");

echo 'finished';

Expected result:
----------------
newPseudoImage should not throw a Exception and "finished" should be printed.

Actual result:
--------------
A ImagickException is thrown.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-07-08 13:18 UTC] cmb@php.net
Are you using the same imagick version with PHP 7.4.20 and
7.4.21?
 [2021-07-08 13:33 UTC] meelmva at hotmail dot com
Yes, they both have version 3.5.0 of the module and 6.9.10-23 of ImageMagick.

I checked it with the following command:
php -i |grep "imagick module version"

The result is:
imagick module version => 3.5.0

ImageMagick is version:
ImageMagick 6.9.10-23 Q16 x86_64 20190101 https://imagemagick.org

If have checked it by running the following command in the interactive PHP shell (php -a):
print_r(imagick::getVersion());
 [2021-07-08 17:12 UTC] meelmva at hotmail dot com
-Operating System: Debian GNU/Linux 10.9 +Operating System: Docker on Debian 10.9 on WSL2
 [2021-07-08 17:12 UTC] meelmva at hotmail dot com
Changes OS to better represent the environment.
 [2021-07-10 01:15 UTC] me at brian dot tw
Same problem here on PHP 7.4.39 running on 4.19.0-0.bpo.16-amd64 #1 SMP Debian 4.19.181-1~deb9u1 (2021-03-29) x86_64.

My hosting provider allows me to roll back to an older version, and the code works flawlessly there.

Code
---:
  <?php
        $youtube_background = new Imagick();
        $youtube_background->newPseudoImage(2560, 1440, "canvas:black");
        ...


Output on PHP 7.4.39
-------------------:
  Fatal error: Uncaught ImagickException: open_basedir restriction in effect. 
  File(canvas:black) is not within the allowed path(s) in /var/www/html/XXX/index.php:3
  Stack trace:
  #0 /var/www/html/XXX/index.php(3): Imagick->newpseudoimage(2560, 1440, 'canvas:black')
  #1 {main}
  thrown in /var/www/html/XXXindex.php on line 3

Output on PHP 7.3.29:
--------------------:
[generates the image like itʼs supposed to]
 [2021-08-02 13:24 UTC] cmb@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: cmb
 [2021-08-02 13:24 UTC] cmb@php.net
<https://github.com/Imagick/imagick/pull/451> submitted.
 [2021-08-09 10:24 UTC] cmb@php.net
-Assigned To: cmb +Assigned To:
 [2021-10-01 10:16 UTC] cmb@php.net
-Status: Verified +Status: Closed -Assigned To: +Assigned To: cmb
 [2021-10-08 13:35 UTC] xqkeeffdgcxxppsjbm at mrvpt dot com
The same problem applies to the "pattern:checkerboard" pseudoString
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 20:01:36 2025 UTC