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

24 lines
648 B
PHP
Raw Normal View History

<?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();
$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);
}