Simple MagickWand Text Generator

Just finishing up for the day and wanted to quickly publish this, it might be a bit sloppy..

Change Font Face, Size, Color & Background image height and width by modifying the GET parameters.

Example GET = <img src=”http://primaryschoolteaching.co.uk/generator/font2.php?font=kiddy&txt=api%20for%20school%20fonts&width=150&height=50&fontsize=15&colorcode=b6d4f1″>

Example output =

Code (copy and paste to test2.php and change url):


<?php
$font = $_GET[‘font’];
$txt = $_GET[‘txt’];
$height = $_GET[‘height’];
$width = $_GET[‘width’];
$fontsize = $_GET[‘fontsize’];
$color = $_GET[‘colorcode’];

// die if font permissions are bad
if(!is_readable(“$font.ttf”)) {
die(“$font is not readable!”);
}

if(extension_loaded(‘magickwand’)) {
$resource = NewMagickWand();
$status = MagickReadImage($resource, “white-pixel.jpg“);
$resource = MagickTransformImage($resource,’0x0′,”$heightx$width”);
$draw = NewDrawingWand();

DrawSetFont($draw,”/path/to/$font.ttf“);
DrawSetFontSize($draw, $fontsize);
DrawSetFillColor($draw, “#$color”);
MagickCropImage($resource, 200, 30, 0, 0 );

$status = MagickAnnotateImage($resource, $draw, 5, 20, 0, “$txt”);

header(‘Content-Type: image/gif’);
echo MagickEchoImageBlob($resource);
exit;
}
?>

You could now use jQuery to pass the color or whatever on the fly so it autoregens each time you edit a param.. Simples! Don’t forget to supply a background file!

How to use Open source software to turn a portrait picture into something that resembles a cartoon (with additional alternatives) — (TECHNICAL)

Important notes: Not everyone thinks a cartoon looks the same, cartoons come in many different formats and I try to present some options on this page. This is a technical document and not for general purpose consumption.
ImageMagick++ and GMIC are required. GimpUI is not but Gimp is. Unix is probably required and is recommended.
What I have tried to do is take a normal picture of a primary school kid and treat it so that it is more appealing to the pupil to put on an object of their personal posession.
I have released my findings so if anyone else tries to do the same thing they can:
Simplfied instructions:
Install GIMP-Devel
Install Dependancies for ImageMagick++
Install ImageMagick++
Install Dependancies for GMIC (take note on ftw3)
Install GMIC (takes a long time)
Once GMIC is installed run the commands that I have placed above each example.
You may wish to process this with PHP or Python or so, that should be very simple to do 🙂

GMIC seems to have much lower overheads than ImageMagick++.

Original Image:





GMIC command:
gmic example.jpg -tetris 50 -o example3.jpg



GMIC command:
gmic example.jpg -edges 30 -o example5.jpg




GMIC command:
gmic example.jpg -drawing 30 -o example7.jpg
GMIC command:
gmic example.jpg -stencilbw 20 -o example6.jpg
Yes this looks very weird but if you apply the same effect to the picture of a boy they look like Harry Potter which is pretty cool if your a Primary School kid..
GMIC command:
gmic example.jpg -pencilbw 1 -o example8.jpg