Speed up generation of multiple images
Posted: 2013-10-04T13:42:54-07:00
Hi,
I'm new to ImageMagick and could use some help. I'm running IM through PHP and have to generate two lines of outlined text. The only way that I could get it to work and look the way I wanted was to do two convert commands to generate two versions of the same text... one with a white border, then one with the same size transparent border... so that I could overlay one over the other and get a white border around readable text.
Since I'm generating two lines of text, I needed 4 "convert" commands to create the two lines... and I just know this could be simplified in order to speed things up.
Here's the code I have right now:
Is there anything obvious here that would enable me to consolidate these four convert commands into one or two?
Thanks for your help!
- John
I'm new to ImageMagick and could use some help. I'm running IM through PHP and have to generate two lines of outlined text. The only way that I could get it to work and look the way I wanted was to do two convert commands to generate two versions of the same text... one with a white border, then one with the same size transparent border... so that I could overlay one over the other and get a white border around readable text.
Since I'm generating two lines of text, I needed 4 "convert" commands to create the two lines... and I just know this could be simplified in order to speed things up.
Here's the code I have right now:
Code: Select all
//Create Top Line with white stroke
$fontSize = $_REQUEST['fontSize'] * 6.927;
$top_line_filename = $output . "_top_line_" . urlencode($textLine1) . $fontName . ".png";
$command = "convert -background transparent -gravity center -stroke '#fffffe' -strokewidth 13 -fill '#120255' -font " . $base_path . "fonts/" . $fontName . '.ttf -size 1270x300 -pointsize ' . $fontSize . ' label:"' . $textLine1 . '" -bordercolor none -border 2 -rotate 0 -distort Arc "45 0" ' . $top_line_filename;
$convert = $location . ' ' . $command;
exec($convert);
//Create top line with transparent stroke to overlay on previous image
$top_line_filename2 = $output . "_top_line2_" . urlencode($textLine1) . $fontName . ".png";
$command = "convert -background transparent -gravity center -stroke transparent -strokewidth 13 -fill '#120255' -font " . $base_path . "fonts/" . $fontName . '.ttf -size 1270x300 -pointsize ' . $fontSize . ' label:"' . $textLine1 . '" -bordercolor none -border 2 -rotate 0 -distort Arc "45 0" ' . $top_line_filename2;
$convert = $location . ' ' . $command;
exec($convert);
//create bottom line with white stroke
$bottom_line_filename = $output . "_bottom_line_" . urlencode($textLine2) . $fontName . ".png";
$command = "convert -background transparent -gravity center -stroke '#fffffe' -strokewidth 13 -fill '#120255' -font " . $base_path . "fonts/" . $fontName . '.ttf -size 1270x300 -pointsize ' . $fontSize . ' label:"' . $textLine2 . '" -bordercolor none -border 2 -rotate 0 -distort Arc "0 0" ' . $bottom_line_filename;
$convert = $location . ' ' . $command;
exec($convert);
//Create bottom line with transparent stroke to overlay on previous image
$bottom_line_filename2 = $output . "_bottom_line2_" . urlencode($textLine2) . $fontName . ".png";
$command = "convert -background transparent -gravity center -stroke transparent -strokewidth 13 -fill '#120255' -font " . $base_path . "fonts/" . $fontName . '.ttf -size 1270x300 -pointsize ' . $fontSize . ' label:"' . $textLine2 . '" -bordercolor none -border 2 -rotate 0 -distort Arc "0 0" ' . $bottom_line_filename2;
$convert = $location . ' ' . $command;
Thanks for your help!
- John