Пример #1
0
function createIcon($file)
{
    // @todo: Add support for others methods.
    if (class_exists("Imagick")) {
        $img = new Imagick();
        $img->readImageBlob(file_get_contents($file));
        $img->thumbnailImage(100, 100, true);
        return base64_encode($img);
    } elseif (extension_loaded('gd')) {
        return createIconGD($file);
    } else {
        return giftThumbnail();
    }
}
Пример #2
0
 /**
  * Set your profile picture
  *
  * @param string $jid
  * @param string $filepath
  *  URL or localpath to image file
  */
 protected function sendSetPicture($jid, $filepath)
 {
     if (stripos($filepath, 'http') !== false && !preg_match('/\\s/', $filepath)) {
         $extension = end(explode(".", $filepath));
         $newImageName = rand(0, 100000);
         $imagePath = static::PICTURES_FOLDER . "/" . $newImageName . ".jpg";
         if ($extension == 'jpg') {
             copy($filepath, $imagePath);
             $filepath = $imagePath;
         }
     }
     preprocessProfilePicture($filepath);
     $fp = @fopen($filepath, "r");
     if ($fp) {
         $data = fread($fp, filesize($filepath));
         if ($data) {
             //this is where the fun starts
             $picture = new ProtocolNode("picture", null, null, $data);
             $icon = createIconGD($filepath, 96, true);
             $thumb = new ProtocolNode("picture", array("type" => "preview"), null, $icon);
             $hash = array();
             $nodeID = $this->createMsgId("setphoto");
             $hash["id"] = $nodeID;
             $hash["to"] = $this->getJID($jid);
             $hash["type"] = "set";
             $hash["xmlns"] = "w:profile:picture";
             $node = new ProtocolNode("iq", $hash, array($picture, $thumb), null);
             $this->sendNode($node);
             $this->waitForServer($nodeID);
         }
     }
 }
Пример #3
0
 /**
  * Set your profile picture
  *
  * @param string $jid
  * @param string $filepath
  *  URL or localpath to image file
  */
 protected function sendSetPicture($jid, $filepath)
 {
     preprocessProfilePicture($filepath);
     $fp = @fopen($filepath, "r");
     if ($fp) {
         $data = fread($fp, filesize($filepath));
         if ($data) {
             //this is where the fun starts
             $picture = new ProtocolNode("picture", null, null, $data);
             $icon = createIconGD($filepath, 96, true);
             $thumb = new ProtocolNode("picture", array("type" => "preview"), null, $icon);
             $hash = array();
             $nodeID = $this->createMsgId("setphoto");
             $hash["id"] = $nodeID;
             $hash["to"] = $this->getJID($jid);
             $hash["type"] = "set";
             $hash["xmlns"] = "w:profile:picture";
             $node = new ProtocolNode("iq", $hash, array($picture, $thumb), null);
             $this->sendNode($node);
             $this->waitForServer($nodeID);
         }
     }
 }
Пример #4
0
 /**
  * Set your profile picture
  *
  * @param string $jid
  * @param string $filepath URL or localpath to image file
  */
 protected function sendSetPicture($jid, $filepath)
 {
     $nodeID = $this->createIqId();
     $data = preprocessProfilePicture($filepath);
     $preview = createIconGD($filepath, 96, true);
     $picture = new ProtocolNode("picture", array("type" => "image"), null, $data);
     $preview = new ProtocolNode("picture", array("type" => "preview"), null, $preview);
     $node = new ProtocolNode("iq", array('id' => $nodeID, 'to' => $this->getJID($jid), 'type' => 'set', 'xmlns' => 'w:profile:picture'), array($picture, $preview), null);
     $this->sendNode($node);
     $this->waitForServer($nodeID);
 }
Пример #5
0
function createVideoIcon($file)
{
    /* should install ffmpeg for the method to work successfully  */
    if (checkFFMPEG()) {
        //generate thumbnail
        $preview = sys_get_temp_dir() . '/' . md5($file) . '.jpg';
        @unlink($preview);
        //capture video preview
        $command = "ffmpeg -i \"" . $file . "\" -f mjpeg -ss 00:00:01 -vframes 1 \"" . $preview . "\"";
        exec($command);
        return createIconGD($preview);
    } else {
        return base64_decode(videoThumbnail());
    }
}
Пример #6
0
function createVideoIcon($file)
{
    // @todo: Add support for video thumbnail create.
    // @see: http://stackoverflow.com/questions/14662027/generate-thumbnail-for-a-bunch-of-mp4-video-in-a-folder
    //return giftThumbnail();
    /* should install ffmpeg for the method to work successfully  */
    if (checkFFMPEG()) {
        //generate thumbnail
        $preview = sys_get_temp_dir() . '/' . md5($file) . '.jpg';
        @unlink($preview);
        //capture video preview
        $command = "ffmpeg -i \"" . $file . "\" -f image2 -vframes 1 \"" . $preview . "\"";
        exec($command);
        // Parsear la imagen
        //TODO: Make it work using libGD (see createIcon())
        return createIconGD($preview);
    } else {
        //fallback
        return giftThumbnail();
    }
}
Пример #7
0
 /**
  * Set your profile picture.
  *
  * @param string $jid
  * @param string $filepath URL or localpath to image file
  */
 protected function sendSetPicture($jid, $filepath)
 {
     $nodeID = $this->createIqId();
     $data = preprocessProfilePicture($filepath);
     $preview = createIconGD($filepath, 96, true);
     $picture = new ProtocolNode('picture', ['type' => 'image'], null, $data);
     $preview = new ProtocolNode('picture', ['type' => 'preview'], null, $preview);
     $node = new ProtocolNode('iq', ['id' => $nodeID, 'to' => $this->getJID($jid), 'type' => 'set', 'xmlns' => 'w:profile:picture'], [$picture, $preview], null);
     $this->sendNode($node);
 }
Пример #8
0
 /**
  * Set your profile picture
  *
  * @param string $jid
  * @param string $filepath
  *  URL or localpath to image file
  */
 protected function sendSetPicture($jid, $filepath)
 {
     $data = preprocessProfilePicture($filepath);
     $preview = createIconGD($filepath, 96, true);
     $picture = new ProtocolNode("picture", array("type" => "image"), null, $data);
     $preview = new ProtocolNode("picture", array("type" => "preview"), null, $preview);
     $hash = array();
     $nodeID = $this->createMsgId("setphoto");
     $hash["id"] = $nodeID;
     $hash["to"] = $this->getJID($jid);
     $hash["type"] = "set";
     $hash["xmlns"] = "w:profile:picture";
     $node = new ProtocolNode("iq", $hash, array($picture, $preview), null);
     $this->sendNode($node);
     $this->waitForServer($nodeID);
 }