2015-08-03 11:35:01 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
function createEmailPic($jid, $email) {
|
2015-12-15 11:54:49 +01:00
|
|
|
$cachefile = DOCUMENT_ROOT.'/cache/'.$jid.'_email.png';
|
|
|
|
|
|
|
|
if(file_exists(DOCUMENT_ROOT.'/cache/'.$jid.'_email.png'))
|
|
|
|
unlink(DOCUMENT_ROOT.'/cache/'.$jid.'_email.png');
|
|
|
|
|
|
|
|
$draw = new ImagickDraw();
|
2015-12-21 22:59:03 +01:00
|
|
|
try {
|
|
|
|
$draw->setFontSize(13);
|
|
|
|
$draw->setGravity(Imagick::GRAVITY_CENTER);
|
2015-12-15 11:54:49 +01:00
|
|
|
|
2015-12-21 22:59:03 +01:00
|
|
|
$canvas = new Imagick();
|
2015-12-15 11:54:49 +01:00
|
|
|
|
2015-12-21 22:59:03 +01:00
|
|
|
$metrics = $canvas->queryFontMetrics($draw, $email);
|
2015-12-15 11:54:49 +01:00
|
|
|
|
2015-12-21 22:59:03 +01:00
|
|
|
$canvas->newImage($metrics['textWidth'], $metrics['textHeight'], "transparent", "png");
|
|
|
|
$canvas->annotateImage($draw, 0, 0, 0, $email);
|
2015-12-15 11:54:49 +01:00
|
|
|
|
2015-12-21 22:59:03 +01:00
|
|
|
$canvas->setImageFormat('PNG');
|
|
|
|
$canvas->writeImage($cachefile);
|
|
|
|
} catch (ImagickException $e) {
|
|
|
|
error_log($e->getMessage());
|
|
|
|
}
|
2015-08-03 11:35:01 +02:00
|
|
|
}
|