1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/movim_ynh.git synced 2024-09-03 19:46:19 +02:00
movim_ynh/sources/system/UtilsPicture.php
2015-12-21 22:59:03 +01:00

27 lines
769 B
PHP

<?php
function createEmailPic($jid, $email) {
$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();
try {
$draw->setFontSize(13);
$draw->setGravity(Imagick::GRAVITY_CENTER);
$canvas = new Imagick();
$metrics = $canvas->queryFontMetrics($draw, $email);
$canvas->newImage($metrics['textWidth'], $metrics['textHeight'], "transparent", "png");
$canvas->annotateImage($draw, 0, 0, 0, $email);
$canvas->setImageFormat('PNG');
$canvas->writeImage($cachefile);
} catch (ImagickException $e) {
error_log($e->getMessage());
}
}