Book Image

ImageMagick Tricks

By : Sohail Salehi
Book Image

ImageMagick Tricks

By: Sohail Salehi

Overview of this book

<p>The book is packed with interesting and fun examples. We had a lot of fun coming up with cool ways to demonstrate ImageMagick's power, and we're sure you'll have fun learning how to create them.<br /><br />Although the printed book is in black and white, there is a full colour PDF of the screenshots freely available that includes all of the images in the book. Use it to see exactly what the ImageMagick effects look like in colour, or browse through it and see just what you'll learn to do with this book.<br /><br />ImageMagick is a free software suite to create, edit, and compose bitmap images using text-based commands. The commands can be issued from the command line, but more often will be included in web or desktop applications &acirc;&euro;&ldquo; carrying out complex image-manipulation tasks in response to the user's input.<br /><br />ImageMagick is a popular way for generating images on-the-fly in web pages, whether it's generating thumbnails from a large image, or creating complex combinations of images, text, and effects chosen by a visitor or the web site's creator.</p>
Table of Contents (18 chapters)
ImageMagick Tricks
Credits
About the Author
About the Reviewers
Preface
5
Identify, Display, and Import
Index

E-card A: Simple Letters


After choosing your image write PHP code to generate graphical letters with colored background as follows. It is assumed that you’ve designed a complete web form with any required controls already, and that form gets the user multi-line string (in this case three lines are provided; you can expand this code to support more lines).

<?php
Session_start();
//initializing variables
$message1 = POST_[‘msg_1stline’];
$message2 = POST_[‘msg_2ndline’];
$message3 = POST_[‘msg_3rdline’];
$backgnd = POST_[‘image’];
// Save the path where convert is installed in a variable
$convert = "/usr/bin/convert"; $mogrify = "/usr/bin/mogrify"; // a function for writing each line of text as a block of letters
function write_text(int $x, int $y, string $msg)
{
//create a new image with the same size as the background
//for writing the first line of the letters on
$CMD = "$convert size 540x400 xc:transparent line1".strip_tags(SID).".gif";
exec($CMD);
for($i=0;$i<strlen($msg);$i++)...