Greetings,% username.

Today I want to demonstrate the capabilities of the wonderful IMagick, and show how you can easily get an animated 3D gif image. This can be useful, for example, in stores that sell mobile phones, and they want to show the phone to buyers in 3D, without using Flash.
')
At one time, while developing the JS gallery, I needed to rotate images in perspective (for thumbnails) using PHP. Having realized this, I read the
post, but I was upset that I had to “manually” create images from which rotation would “gather”. And I decided to automate this matter, the solution is available by
reference . Also available
demo .
Opportunities:
- Generate gif image rotation, and save the “storyboard” to the specified directory
- Set the width, height and background color of the generated GIF image
- Spin duration control
- Set the number of frames per second
Using:
In spite of the presence of examples, I will show in the downloaded archive, I will give a simple example of use:
Connect the downloaded class:
include_once( 'nxcimage3drotation.php' );
Create an instance of the nxcImage3DRotation class, specifying the width, height and background color of the GIF that will be obtained as a result
$rotation = new nxcImage3DRotation( 150, 220, 'rgb(220, 110, 170)' );
Actually, create a GIF image of rotation, specifying:
- front, back, left and right images
- frames per second
- rotation time (in seconds)
- directory where storyboard will be saved
$animation = $rotation->getRotationAnimation(
array(
'front' => 'images/iphone4g/front.jpg',
'back' => 'images/iphone4g/back.jpg',
'left' => 'images/iphone4g/left.jpg',
'right' => 'images/iphone4g/right.jpg'
),
20,
4,
'output_images/iphone4g'
);
Display image
header( 'Content-Type: image/gif' );
echo $animation->getImagesBlob();
PS: Writing a php class that builds 4 phone images (with rounded corners) animated 3D gif is not the true goal of this topic. In it, I want to show the power and magic of ImageMagick. In addition, I want to note that the current solution has never been applied on a live project, but Just4Fun is written :)