Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

imagemagick skew or distort an image

Well how could I change the before image to the after image by using imagemagick? Is it the -skew command or the -distort, and how can I use it preferably in typo3 and php?

Any help is appreciated!

before and after

like image 656
netcase Avatar asked Mar 13 '12 15:03

netcase


1 Answers

Using Imagemagick with php and the command line:

// Working on the original image size of 400 x 300
$cmd = "before.jpg -matte -virtual-pixel transparent".  
" +distort Perspective \"0,0 0,0  400,0 400,22  400,300 400,320  0,300 0,300 \" "; 
exec("convert $cmd perspective.png");

Note: 1/ This is for later versions of Imagemagick - the perspective operator has change. 2/ You need to use +distort not -distort as the image is larger than the initial image boundrys.

Examples of Imagemagick with php usage on my site http://www.rubblewebs.co.uk/imagemagick/operator.php

like image 92
Bonzo Avatar answered Sep 27 '22 22:09

Bonzo