Combine 2 images side by side into 1 with ImageMagick (PHP)

后端 未结 4 1666
清酒与你
清酒与你 2021-02-08 09:28

I think this is an easy one.

I have 2 Pictures/JPGs and i want them to merge into one picture where the 2 are side by side.

So i have pic [A] and pic [B] and I w

4条回答
  •  太阳男子
    2021-02-08 09:44

    Here the PHP Code I use at Kinoulink (a french start-up) :

    $im1 = new \Imagick($media1);
    $im2 = new \Imagick($media2);
    $imTotal = new \Imagick();
    
    $im1->cropthumbnailimage(62, 128);
    $im2->cropthumbnailimage(62, 128);
    
    $imTotal->newimage(128, 128, '#ffffffff');
    
    $imTotal->compositeimage($im1, \Imagick::COMPOSITE_DEFAULT, 0, 0);
    $imTotal->compositeimage($im2, \Imagick::COMPOSITE_DEFAULT, 66, 0);
    
    $imTotal->writeimage($albumCoverFilePath);
    

提交回复
热议问题