Warp Image around cylinder
Posted: 2016-02-19T03:45:46-07:00
I am just starting to learn PHP's Imagick library and I am needing to warp an image around a cyclinder mug - similar to this:
Getting started with Imagick i have been using the following examples:
http://www.phpimagick.com/Imagick/rotateImage
To successfully rotate/scale/extent etc the image but cannot see how I can wrap it round a cylinder.
I can see there is a way of doing so with Cylindrical Displacement in the docs:
http://www.imagemagick.org/Usage/mappin ... e_cylinder
Like so:
However this just doesn't make much sense to me when i've been using code such as:
Can anyone help in how I can achieve this using the second way of coding or if there is a way of converting it across?
I'm completely stuck on this.
Thanks
Getting started with Imagick i have been using the following examples:
http://www.phpimagick.com/Imagick/rotateImage
To successfully rotate/scale/extent etc the image but cannot see how I can wrap it round a cylinder.
I can see there is a way of doing so with Cylindrical Displacement in the docs:
http://www.imagemagick.org/Usage/mappin ... e_cylinder
Like so:
Code: Select all
convert rose: -background black -gravity south -splice 0x8 \
\( +clone -sparse-color barycentric '0,0 black 69,0 white' \) \
\( +clone -function arcsin 0.5 \) \
\( -clone 1 -level 25%,75% \
-function polynomial -4,4,0 -gamma 2 \
+level 50%,0 \) \
-delete 1 -swap 0,1 miff:- |\
composite - -virtual-pixel black -displace 17x7 rose_cylinder.png
Code: Select all
$img = new Imagick($the_img_path);
// to resize
$img->resizeImage($_w, $_h, imagick::FILTER_LANCZOS, 1, false);
// to crop
$img->cropImage($crop_w, $crop_h, $crop_x, $crop_y);
I'm completely stuck on this.
Thanks