Jump to content

Wave An Image With Imagick


Byron

Recommended Posts

Wave an image with just a few lines of code using the Imagick Class (only on Stevie). This is the original image:

 

http://byrondallas.heliohost.org/php/imagick/landscape.jpeg

 

Here is the waved image:

 

http://byrondallas.heliohost.org/php/imagick/wave.php

 

Here's the code. You can use any color for the backgroundcolor. If you want the background to be transparent (like my example) you'll need to set the format to gif or png.

 

<?php
$image = new imagick("landscape.jpeg");
$image->setimagebackgroundcolor("transparent");
$image->waveImage(20, 240);
$image->setImageFormat('png');
# uncomment line below to write image to directory
# $image->writeimage("landscape_wav.png");
header("Content-Type: image/png");
echo $image;
?>

 

You can play around with the amplitude and length, this line: $image->waveImage(20, 240); to get different wave patterns.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...