-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
ImageMagick errors on PHP 8.3 image after recent updates #155
Comments
@yobottehg ImageMagick didn't exist on our 8.3 image until about a week ago; my guess would be that your app's integration with ImageMagick was failing silently previously, and now hat ImageMagick exists it's failing explicitly. Right now ImageMagick isn't fully supported by the extension installer the images use, so that could be why it doesn't work seamlessly. @AaronFeledy has been working on this and may be able to put together a working example for you. |
I successfully tested this with the 8.3 image by placing it in If something is still not working, please provide more info. <?php
class SimpleImagickTest
{
private $testImage;
public function __construct()
{
$this->testImage = sys_get_temp_dir() . '/imagick_test_' . uniqid() . '.png';
}
public function runTest()
{
try {
$this->checkExtension();
$this->createTestImage();
$this->testBasicOperations();
$this->cleanup();
echo "All tests passed successfully!\n";
return true;
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
$this->cleanup();
return false;
}
}
private function checkExtension()
{
if (!extension_loaded('imagick')) {
throw new Exception('Imagick extension is not installed');
}
echo "✓ Imagick extension is installed<br>\n";
}
private function createTestImage()
{
try {
$draw = new ImagickDraw();
// Set up text properties with system font
$draw->setFontSize(40);
$draw->setFillColor('white');
$draw->setGravity(Imagick::GRAVITY_CENTER);
// Try to find a system font that works
$possibleFonts = [
'/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf', // Linux
'/Library/Fonts/Arial Bold.ttf', // macOS
'C:\\Windows\\Fonts\\arial.ttf', // Windows
'/usr/share/fonts/truetype/liberation/LiberationSans-Bold.ttf' // Ubuntu
];
$fontFound = false;
foreach ($possibleFonts as $font) {
if (file_exists($font)) {
$draw->setFont($font);
$fontFound = true;
break;
}
}
// Create base image
$im = new Imagick();
$im->newPseudoImage(400, 200, "gradient:#e03f92-black");
// Add text (only if we found a font)
if ($fontFound) {
$im->annotateImage($draw, 0, 0, 0, "LANDO");
}
$im->setImageFormat('png');
$im->writeImage($this->testImage);
if (file_exists($this->testImage)) {
echo "✓ Successfully created test image<br>";
$this->displayImage();
} else {
throw new Exception('Failed to create test image');
}
} catch (Exception $e) {
throw new Exception('Failed to create test image: ' . $e->getMessage());
}
}
private function testBasicOperations()
{
$image = new Imagick($this->testImage);
// Test resize
$image->resizeImage(50, 50, Imagick::FILTER_LANCZOS, 1);
$image->writeImage($this->testImage);
if ($image->getImageWidth() !== 50) {
throw new Exception('Resize operation failed');
}
echo "✓ Resize operation successful<br>";
$this->displayImage();
// Test rotate
$image->rotateImage(new ImagickPixel('none'), 90);
$image->writeImage($this->testImage);
if ($image->getImageHeight() !== 50) {
throw new Exception('Rotate operation failed');
}
echo "✓ Rotate operation successful<br>";
$this->displayImage();
}
private function displayImage()
{
echo '<img src="data:image/png;base64,' . base64_encode(file_get_contents($this->testImage)) . '"><br><br>';
}
private function cleanup()
{
if (file_exists($this->testImage)) {
@unlink($this->testImage);
}
}
}
// Run the test
$test = new SimpleImagickTest();
$test->runTest(); |
@AaronFeledy and @reynoldsalec I was able to run the script sucessfully. However to get the Drupal imagemagick module working again i needed to explicitly install imagemagick via apt-get in the I think this is unrelated to the docker extension but more to the base docker image which apparently did not have this installed anymore. |
You're right. It seems Drupal's |
Since some days I get the following ImageMagick errors on the official PHP 8.3 image:
[error] ImageMagick error 127: sh: 1: exec: identify: not found
I use Drupal 10.3 and the ImageMagick module. Has something changed what I need to adjust in the settings?
The text was updated successfully, but these errors were encountered: