最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

image processing - Performance Regression with Imagick between PHP 7.2 and 8.2 - Stack Overflow

programmeradmin5浏览0评论

I'm noticing a significant performance difference when running the same Imagick script on PHP 7.2 versus PHP 8.2. Here are the results I’ve gathered:

  • PHP 7.2, ImageMagick 7.0.7, Imagick 3.44: 3.8 seconds

  • PHP 8.2, ImageMagick 7.1, Imagick 3.7: 13.32 seconds

Same spec machine, tested on windows and centos, both 64bit architecture imagick with similar results.

I’m wondering if anyone has encountered similar issues or knows why this change between PHP versions might be affecting Imagick's performance so drastically? Or know any fixes for this? Below is the test script I’m using (it does this on other functions too not just distorts, this is just an example):

<?php

$startTime = microtime(true);

// Get script directory
$script_path = dirname(__FILE__) . "/";

$controlPoints = [
    1.5,
    0, 0, 355, 70,
    0, 3708, 337, 974,
    1380, 0, 657, 105,
    1380, 3708, 654, 956,
];

echo "Doing Distortion 1\n";

$design = new Imagick($script_path . 'input.png');

// Apply distortion
try {
    $design->distortImage(Imagick::DISTORTION_POLYNOMIAL, $controlPoints, true);
} catch (Exception $e) {
    echo "Error applying distortion: " . $e->getMessage() . "\n";
}

// Write the distorted image to an output file
$design->writeImage($script_path . "testoutput.png");

$endTime = microtime(true);
$executionTime = ($endTime - $startTime);

echo "Execution Time: " . $executionTime . " seconds\n";
发布评论

评论列表(0)

  1. 暂无评论