Rajesh Dante
Rajesh Dante

Reputation: 29

php Imagick rotate and merge

i have 2 images one background and another one is layer first i want to rotate it then i want to place it somewhere using x and y.. it can be done using GD but in gd when rotate the image i get low quality and zigzag border.. so i tried to rotate in imagick it done its job good without zigzag and without loosing quality.. so i want to know how to place that rotated image to background...

Background

Background image

Image_2

layer image

Output should look like this

3

EDIT:

The code I have tried so far:

<?php 
  $imagick = new Imagick(); 
  $imagick->readImage('137.png'); 
  $imagick->rotateImage(new ImagickPixel('none'), -13.55); 
  $imagick->writeImage('my_rotated.png'); 
  $imagick->clear(); 
  $imagick->destroy(); 
?>

Upvotes: 0

Views: 2785

Answers (1)

Ibrahim Benzer
Ibrahim Benzer

Reputation: 498

I was trying to find a solution myself. I guess this should get what you need:

$background = 'background.png';
$image = new Imagick($background);

// you can place the code below in a loop to put more images in order
$imgfile = 'foreground-image.png';
$part1 = new Imagick($imgfile);
$part1->rotateImage(new ImagickPixel('none'), -13.55);
$image->compositeImage($part1, Imagick::COMPOSITE_OVER, $left, $top);


$image->writeImage('my_rotated.png');

//save , flush , destroy etc...

Upvotes: 2

Related Questions