Page 1 of 1
Trying to make motivational posters with ImageMagick
Posted: 2008-06-04T07:04:45-07:00
by benito
Hello!
My image skills are very limited with ImageMagick. Im trying to create a motivational poster like this one:
After a few steps i managed to get this result starting with a white rectangle image.
I use this code to make that:
Code: Select all
<?php
shell_exec('convert source.jpg -bordercolor 000000 -border 3x3 step1.jpg');
shell_exec('convert step1.jpg -bordercolor white -border 2x2 step2.jpg');
shell_exec('convert step2.jpg -bordercolor 000000 -border 10%x10% step3.jpg');
?>
Now im stuck with the last steps.
1. Extend the black border at bottom.
2. Place the Two lines of text, centered and if its possible autosized.
What commands i need to make this?
Thanks
Re: Trying to make motivational posters with ImageMagick
Posted: 2008-06-04T07:18:33-07:00
by Bonzo
You could check out my example on this page
http://www.rubblewebs.co.uk/imagemagick ... border.jpg as it may save you some steps.
Also every time you save an image as a jpg you are getting some jpg compression, use png or other lossless format and save to jpg last !
Re: Trying to make motivational posters with ImageMagick
Posted: 2008-06-04T08:41:30-07:00
by benito
Thanks Bonzo
Now i managed to make this result:
Now i need to know how to separate the texts and if its possible how to auto size the font.
This is the code i use
Code: Select all
<?php
exec('convert source.jpg -bordercolor 000000 -border 3x3 step1.ppm'); // add small black border
exec('convert step1.ppm -bordercolor white -border 2x2 step2.ppm'); // add white line around the image
exec('convert step2.ppm -bordercolor 000000 -border 10%x10% step3.ppm'); //add a wide black border around
exec("convert step3.ppm -size 15x15 xc:black -background black -append -font 'roman.ttf' -pointsize 64 -fill white -draw \"gravity South text 0,0 'SOME TITLE'\" text1.ppm");
exec("convert text1.ppm -size 15x15 xc:black -background black -append -font 'roman.ttf' -pointsize 32 -fill white -draw \"gravity South text 0,0 'MORE TEXT MORE TEXT MORE TEXT MORE TEXT '\" step4.jpg");
?>
Re: Trying to make motivational posters with ImageMagick
Posted: 2008-06-04T10:21:22-07:00
by Bonzo
This is the sort of thing you can do and so have less tempory images to deal with ( 3 different ways to do the same thing):
Your original code cleaned up a bit.
Code: Select all
<?php
exec('convert source.jpg -bordercolor black -border 3x3 step1.ppm'); // add small black border
exec('convert step1.ppm -bordercolor white -border 2x2 step2.ppm'); // add white line around the image
exec('convert step2.ppm -bordercolor black -border 10%x10% step3.ppm'); //add a wide black border around
exec("convert step3.ppm -font 'roman.ttf' -pointsize 64 -fill white -draw \"gravity South text 0,0 'SOME TITLE'\" -pointsize 32 -fill white -draw \"gravity South text 0,-20 'MORE TEXT MORE TEXT MORE TEXT MORE TEXT '\" step4.jpg");
?>
<img src="step4.jpg">
Read the image in and resize it and add the borders; create a black background and put the image onto it. Write the text directly to the first image.
<?php
exec("convert \( source.jpg -resize 250x250 -bordercolor black -border 3x3 -bordercolor white -border 2x2 \) -size 300x400 xc:black -gravity north -geometry +0+30 +swap -composite border.png");
exec("convert border.png -pointsize 32 -fill white -draw \"gravity South text 0,60 'SOME TITLE'\" -pointsize 16 -gravity south -annotate +0+30 \"MORE TEXT MORE TEXT\\nMORE TEXT MORE TEXT \" text.png");
?>
<img src="text.png">
Read the image in and resize it and add the borders; create a black background and put the image onto it. Write the text to another image then paste the text onto the first image.
<?php
exec("convert \( source.jpg -resize 250x250 -bordercolor black -border 3x3 -bordercolor white -border 2x2 \) -size 300x400 xc:black -gravity north -geometry +0+30 +swap -composite border.png");
exec("convert \( -size 300x100 -background black -font verdana.ttf -fill white -gravity North caption:\"The quick red fox jumped over the lazy brown dog.\" -flatten \) border.png -gravity south +swap -composite caption1.jpg");
?>
The only thing is you would need to use something like getimagesize and and use the values in your code e.g replace -size 300x400 with -size {$width}x{$height}
You also might like to take a look at
http://www.imagemagick.org/Usage/