gpt4 book ai didi

php - php 上的 3d Canvas 框架

转载 作者:行者123 更新时间:2023-12-04 05:46:08 25 4
gpt4 key购买 nike

我正在做一个在运行时创建框架的项目,但是 所有者想要困难的事情 :) 我设法对这个项目做了一些事情。

but the owner wants to like these :

First thing

and

second thing

I found some codes on the internet which is this.

        $im = new Imagick('Penguins.jpg');       
$im->setImageFormat('png');
$d = $im->getImageGeometry();
$w = $d['width'];
$h = $d['height'];
$im3 = new Imagick();
$im3->newImage(1, $h, 'none', 'png');
$im3->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);
$im1 = $im->clone();

$im1->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);
$im1->setImageMatte(true);
$im1->cropImage(($w - 10), $h, 0, 0);
/* $controlPoints = array(
kenar açisi, orta açi,15,15,
($w - 10), 0, ($w - 10), 0,
0, $h, 25, ($h - 20),
($w - 10), $h, ($w - 10), $h
);*/
$controlPoints = array(
0,0,15,15,
($w - 10), 0, ($w - 10), 0,
0, $h, 25, ($h - 20),
($w - 10), $h, ($w - 10), $h
);
$im1->distortImage(Imagick::DISTORTION_BILINEAR, $controlPoints, true);
$im2 = $im->clone();
$im2->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);
$im2->setImageMatte(true);
$im2->cropImage(10, $h, ($w - 10), 0);
$controlPoints2 = array(
0, 0, 0, 0,
10, 0, 10, 10,
0, $h, 0, $h,
10, $h, 10, ($h - 10)
);
$im2->distortImage(Imagick::DISTORTION_BILINEAR, $controlPoints2, true);

$im4 = $im->clone();
$im4->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);
$im4->setImageMatte(true);
$im4->cropImage($w, 10, 0, 0);
$controlPoints4 = array(
0, 0, 0, 0,
10, 0, 10, 10,
$w, 10, $w, 10,
$w, 10, ($w -10 ), 10
);
$im4->distortImage(Imagick::DISTORTION_BILINEAR, $controlPoints4, true);

$image = new Imagick();
$image->addImage($im4);
$image->addImage($im1);
$image->addImage($im3);
$image->addImage($im2);
$image->resetIterator();
$combined = $image->appendImages(false);
$shadow = $combined->clone();
$shadow->setImageBackgroundColor(new ImagickPixel('black'));
$shadow->shadowImage(50, 3, 5, 5);
$shadow->compositeImage($combined, Imagick::COMPOSITE_OVER, 0, 0);
header("Content-Type: image/png");
echo $shadow;

And Result :

enter image description here

Thanks for the help.

最佳答案

我也是 imagick 的新手,我相信我们正在从事相同类型的项目。

这是我的方法,但它需要改进。

$im = new Imagick('Koala.jpg');
$im->setImageFormat('png');
$im->cropThumbnailImage(300,200);

$p1 = $im->clone();
$p1->cropImage(50, 150, 0, 25);
$p1->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);
$p1->setImageMatte(true);

$cPoints = array(
0,0, 5,5,
50,0, 50,0,
0,150, 5,145,
50,150, 50,150
);

$p1->distortImage(Imagick::DISTORTION_BILINEAR, $cPoints, true);

$p2 = $im->clone();
$p2->cropImage(5, 150, 50, 25);
$p2->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);
$p2->setImageMatte(true);

$cPoints2 = array(
0,0, 0,0,
5,0, 5,5,
0,150, 0,150,
5,150, 5,145
);

$p2->distortImage(Imagick::DISTORTION_BILINEAR, $cPoints2, true);

$canvas1 = new Imagick();
$canvas1->newImage(55, 200, 'none','png');
$canvas1->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);
$canvas1->setImageMatte(true);

$canvas1->compositeImage( $p1, imagick::COMPOSITE_OVER, 0,25 );
$canvas1->compositeImage( $p2, imagick::COMPOSITE_OVER, 50,25 );

$p3 = new Imagick();
$p3->newImage(10, 200, 'none','png');
$p3->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);

$p4 = $im->clone();
$p4->cropImage(50, 200, 65, 0);
$p4->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);
$p4->setImageMatte(true);

$cPoints4 = array(
0,0, 5,5,
50,0, 50,0,
0,200, 5,195,
50,200, 50,200
);

$p4->distortImage(Imagick::DISTORTION_BILINEAR, $cPoints4, true);

$p5 = $im->clone();
$p5->cropImage(5, 200, 135, 0);
$p5->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);
$p5->setImageMatte(true);

$cPoints5 = array(
0,0, 0,0,
5,0, 5,5,
0,200, 0,200,
5,200, 5,195
);

$p5->distortImage(Imagick::DISTORTION_BILINEAR, $cPoints5, true);

$p6 = new Imagick();
$p6->newImage(10, 200, 'none','png');
$p6->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);

$p7 = $im->clone();
$p7->cropImage(50, 150, 150, 25);
$p7->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);
$p7->setImageMatte(true);

$cPoints7 = array(
0,0, 5,5,
50,0, 50,0,
0,150, 5,145,
50,150, 50,150
);

$p7->distortImage(Imagick::DISTORTION_BILINEAR, $cPoints7, true);

$p8 = $im->clone();
$p8->cropImage(5, 150, 200, 25);
$p8->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);
$p8->setImageMatte(true);

$cPoints8 = array(
0,0, 0,0,
5,0, 5,5,
0,150, 0,150,
5,150, 5,145
);

$p8->distortImage(Imagick::DISTORTION_BILINEAR, $cPoints8, true);

$canvas2 = new Imagick();
$canvas2->newImage(55, 200, 'none','png');
$canvas2->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);
$canvas2->setImageMatte(true);

$canvas2->compositeImage( $p7, imagick::COMPOSITE_OVER, 0,25 );
$canvas2->compositeImage( $p8, imagick::COMPOSITE_OVER, 50,25 );

$pImage = new Imagick();
$pImage->addImage($canvas1);
$pImage->addImage($p3);
$pImage->addImage($p4);
$pImage->addImage($p5);
$pImage->addImage($p6);
$pImage->addImage($canvas2);
$pImage->resetIterator();

$combined = $pImage->appendImages(false);

$shadow = $combined->clone();

$shadow->setImageBackgroundColor( new ImagickPixel( 'black' ) );

$shadow->shadowImage( 50, 3, 5, 5 );


$shadow->compositeImage( $combined, Imagick::COMPOSITE_OVER, 0, 0 );

header("Content-Type: image/png");
echo $shadow;

结果是;

希望对你有帮助但如果您找到更简单的解决方案,请告诉我们,因为我也需要它:)

关于php - php 上的 3d Canvas 框架,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10663683/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com