Distort or distort the image.

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

Any help is appreciated!

before and after

+4
source share
3 answers

Using Imagemagick with php and 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 changes. 2 / You need to use + to distort the non-distort, since the image is larger than the original image.

Imagemagick examples using php on my website http://www.rubblewebs.co.uk/imagemagick/operator.php

+6
source

Perspective distortion should give you what you want. Example:

 convert original.png -matte -virtual-pixel white +distort Perspective '0,0,0,0 0,100,0,100 100,100,90,110 100,0,90,5' distorted.png 

In TYPO3, you can apply it in (ab) using the SCALE object in GIFBUILDER . Example:

 temp.example = IMAGE temp.example { file = GIFBUILDER file { format = jpg quality = 100 maxWidth = 9999 maxHeight = 9999 XY = [10.w],[10.h] 10 = IMAGE 10.file = fileadmin/original.png 20 = SCALE 20 { params = -matte -virtual-pixel white +distort Perspective '0,0,0,0 0,100,0,100 100,100,90,110 100,0,90,5' } } } 
+4
source

I think you are looking for the function Imagick::shearImage . This creates a checkerboard square and distorts it in a parallelogram (save this as a PHP file and open in your browser):

 <?php $im = new Imagick(); $im->newPseudoImage(300, 300, "pattern:checkerboard"); $im->setImageFormat('png'); $im->shearImage("transparent", 0, 10); header("Content-Type: image/png"); echo $im; ?> 

In a larger script, to shift the image named myimg.png and save it as myimg-sheared.png, you can use:

 $im = new Imagick("myimg.png"); $im->shearImage("transparent", 0, 10); $im->writeImage("myimg_sheared.png"); 

If shearImage not universal enough, you can try the Imagick::DISTORTION_PERSPECTIVE method with the Imagick::DISTORTION_PERSPECTIVE function.

+2
source

Source: https://habr.com/ru/post/1401193/


All Articles