Imagick Text 正在覆盖每一帧

Imagick Text is Overwriting Each Frames

我创建了这个 imagick php 代码来创建我自己的 gif 格式图像。 除了一件事,所有的代码都是完美的。最后一个文本(日期)覆盖了标题文本。有人能解决这个问题吗?

我构建的结果是这样的

[![在此处输入图片描述][1]][1]

这是来自

的代码
        ob_clean();
        $text=ucfirst('Title Name');
        $image = new Imagick('1.gif'); 

        $draw = new ImagickDraw(); 
        $frameCount = 0;
        foreach($image as $frame){
        $image->setImageDelay((($frameCount % 40) * 40));

        $draw->setGravity (Imagick::GRAVITY_NORTHWEST);
        $draw->setTextAlignment(Imagick::ALIGN_CENTER);

        $imgSize   = $image->getImageGeometry();
        $imgHeight = $imgSize['height']; 
        $imgWidth = $imgSize['width'];
        // Calculate size
        $textProperties = array( 'textWidth' => 0 );
        $textDesiredWidth = intval( $imgWidth * 0.9 );

        $defaultFontSize = 25;
        $fontSize = 0;
        $draw->setFillColor('white'); 
        /* Font properties */
        $draw->setFont('assets/fonts/EX.ttf'); 
        while ( $textProperties['textWidth'] <= $textDesiredWidth ) {
            $draw->setFontSize( $fontSize );
            $textProperties = $image->queryFontMetrics( $draw, $text );
            $fontSize++;
        }

        if($fontSize>$defaultFontSize){
            $draw->setFontSize( $defaultFontSize );
            $centerY = floor( ($imgHeight) / 3.3 );
        }else{
            $centerY = floor( ($imgHeight) / 3.6 );
        }
        $centerX = intval( ($imgWidth) / 2 );
        $image->annotateImage( $draw, $centerX, $centerY, 0, $text );

如您所见,日期(“58 天前”)覆盖了 gif 图片中的文本 "PAYING"

谁能帮我解决这个问题? 谢谢

找到修复。!!

首先我们需要知道图像的高度然后反转Y位置

$imgHeight/1

并放在正确的位置。