本文整理汇总了PHP中Picture::fromBase方法的典型用法代码示例。如果您正苦于以下问题:PHP Picture::fromBase方法的具体用法?PHP Picture::fromBase怎么用?PHP Picture::fromBase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Picture
的用法示例。
在下文中一共展示了Picture::fromBase方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ajaxSubmit
function ajaxSubmit($avatar)
{
$p = new \Picture();
$p->fromBase((string) $avatar->photobin->value);
$p->set($this->user->getLogin());
$r = new Set();
$r->setData($avatar->photobin->value)->request();
}
示例2: ajaxSubmit
function ajaxSubmit($avatar)
{
$p = new \Picture();
$p->fromBase($avatar->photobin->value);
$p->set('temp', 'jpeg', 60);
$p = new \Picture();
$p->get('temp');
$r = new Set();
$r->setData($p->toBase())->request();
}
示例3: handle
public function handle($stanza, $parent = false)
{
$jid = current(explode('/', (string) $parent->attributes()->from));
$evt = new \Event();
$cd = new \modl\ContactDAO();
$c = $cd->get($jid);
if ($c == null) {
$c = new \modl\Contact();
}
$p = new \Picture();
$p->fromBase((string) $stanza->items->item->data);
$p->set($jid);
$evt->runEvent('vcard', $c);
}
示例4: ajaxSend
function ajaxSend($to, $pack, $file)
{
if (!$this->validateJid($to)) {
return;
}
list($key, $ext) = explode('.', $file);
$filepath = dirname(__FILE__) . '/stickers/' . $pack . '/' . $key . '.png';
if (!file_exists($filepath)) {
return;
}
// We get the base64
$base64 = base64_encode(file_get_contents($filepath));
// Caching the picture
if (!file_exists(CACHE_PATH . md5($key) . '.png')) {
$p = new Picture();
$p->fromBase($base64);
$p->set($key, 'png');
}
// Creating a message
$m = new \Modl\Message();
$m->session = $this->user->getLogin();
$m->jidto = echapJid($to);
$m->jidfrom = $this->user->getLogin();
$m->sticker = $key;
$m->body = $this->__('sticker.sent');
$m->published = gmdate('Y-m-d H:i:s');
$session = \Session::start();
$m->id = Uuid::uuid4();
$m->type = 'chat';
$m->resource = $session->get('resource');
// Sending the sticker
$html = "<p><img alt='Sticker' src='cid:sha1+" . $key . "@bob.xmpp.org'/></p>";
$p = new Publish();
$p->setTo($m->jidto)->setContent($m->body)->setHTML($html)->setId($m->id)->request();
$md = new \Modl\MessageDAO();
$md->set($m);
// Sending it to Chat
$packet = new Moxl\Xec\Payload\Packet();
$packet->content = $m;
$c = new Chat();
$c->onMessage($packet);
}
示例5: createThumbnails
public function createThumbnails()
{
$p = new \Picture();
$p->fromBase($this->photobin);
$p->set($this->jid);
if (isset($this->email)) {
\createEmailPic(strtolower($this->jid), $this->email);
}
}
示例6: set
public function set($stanza, $parent = false)
{
if ($stanza->body || $stanza->subject) {
$jid = explode('/', (string) $stanza->attributes()->from);
$to = current(explode('/', (string) $stanza->attributes()->to));
if (isset($stanza->attributes()->id)) {
$this->id = (string) $stanza->attributes()->id;
}
// This is not very beautiful
$user = new \User();
$this->session = $user->getLogin();
$this->jidto = $to;
$this->jidfrom = $jid[0];
if (isset($jid[1])) {
$this->__set('resource', $jid[1]);
}
$this->type = 'chat';
if ($stanza->attributes()->type) {
$this->type = (string) $stanza->attributes()->type;
}
if ($stanza->body) {
$this->__set('body', (string) $stanza->body);
}
if ($stanza->subject) {
$this->__set('subject', (string) $stanza->subject);
}
if ($stanza->html) {
$xml = \simplexml_load_string((string) $stanza->html->body);
if ($xml) {
$results = $xml->xpath('//img/@src');
if (is_array($results) && !empty($results)) {
if (substr((string) $results[0], 0, 10) == 'data:image') {
$str = explode('base64,', $results[0]);
if (isset($str[1])) {
$p = new \Picture();
$p->fromBase(urldecode($str[1]));
$key = sha1(urldecode($str[1]));
$p->set($key, 'png');
$this->sticker = $key;
}
} else {
$this->sticker = getCid((string) $results[0]);
}
}
}
}
if ($stanza->replace) {
$this->newid = $this->id;
$this->id = (string) $stanza->replace->attributes()->id;
$this->edited = true;
}
if ($stanza->delay) {
$this->published = gmdate('Y-m-d H:i:s', strtotime($stanza->delay->attributes()->stamp));
} elseif ($parent && $parent->delay) {
$this->published = gmdate('Y-m-d H:i:s', strtotime($parent->delay->attributes()->stamp));
} else {
$this->published = gmdate('Y-m-d H:i:s');
}
$this->checkPicture();
}
}