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

28 lines
769 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();
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());
}
}