function smarty_function_image_link($params, &$smarty)
{
    $playlistInfo = $params['_playlist_info'];
    if (is_a($playlistInfo, 'PlaylistInfo')) {
        $imageid = $playlistInfo->imageid;
    }
    $mediaInfo = $params['_media_info'];
    if (is_a($mediaInfo, 'MediaInfo')) {
        $imageid = $mediaInfo->imageid;
    }
    $imageInfo = $params['_image_info'];
    if (is_a($imageInfo, 'ImageInfo')) {
        $imageid = $imageInfo->imageid;
    }
    if ($params['_info']) {
        $info = $params['_info'];
        $imageid = $info->imageid;
    }
    $name = $params['size'];
    $size = ImageInfo::name2size($name);
    if (!$imageid || !$size) {
        if (!$size) {
            $size = 64;
        }
        print "<img height='{$size}' width='{$size}' border='1'>";
        return;
    }
    //printf( "<div style=\"height: %d; width: %d;\">", $size, $size );
    printf("<img src=\"%simage.php?id=%d&size=%s\">", API_URL, $imageid, $name);
    //printf( "</div>" );
}
Example #2
0
 public static function getGps($exifCoord, $hemi)
 {
     $degrees = count($exifCoord) > 0 ? ImageInfo::gps2Num($exifCoord[0]) : 0;
     $minutes = count($exifCoord) > 1 ? ImageInfo::gps2Num($exifCoord[1]) : 0;
     $seconds = count($exifCoord) > 2 ? ImageInfo::gps2Num($exifCoord[2]) : 0;
     $flip = ($hemi == 'W' or $hemi == 'S') ? -1 : 1;
     return $flip * ($degrees + $minutes / 60 + $seconds / 3600);
 }
Example #3
0
 function initialize()
 {
     $imageid = $_REQUEST['id'];
     $this->size = ImageInfo::name2size($_REQUEST['size']);
     if (!$imageid || !$this->size) {
         throw new VoiceException(CommonMessages::get()->msg('INVALID_PARAMETER'));
     }
     $this->imageInfo = $this->imageDb->getInfo($imageid);
     if (!$this->imageInfo) {
         throw new VoiceException(CommonMessages::get()->msg('NO_IMAGE_INFO'));
     }
 }
Example #4
0
 function newInfo(ImageInfo $info)
 {
     if (!$info->userid || !ImageInfo::isValidType($info->type)) {
         return null;
     }
     $now = date('c');
     $sql = sprintf("INSERT INTO %s (`user_id`,`upload_time`,`type`) VALUES(:userid,:now,:type)", self::TABLE_INFO);
     $params = array(':userid' => $info->userid, ':now' => $now, ':type' => $info->type);
     $state = $this->pdo->prepare($sql);
     if (!$state->execute($params)) {
         return null;
     }
     $sql = sprintf("SELECT * FROM %s WHERE `user_id`=:userid AND `upload_time`=:now LIMIT 1", self::TABLE_INFO);
     unset($params[':type']);
     $state = $this->pdo->prepare($sql);
     if (!$state->execute($params)) {
         return null;
     }
     $hash = $state->fetch(PDO::FETCH_ASSOC);
     return new ImageInfo($hash);
 }
Example #5
0
<?php

require_once '../class/DBAL.php';
require_once '../class/ImageInfo.php';
$db = DBAL::getInstance();
$user_id = 1;
// This should be replaced with some sort of authentication service
if (isset($_FILES) && !empty($_FILES) && isset($_GET) && !empty($_GET)) {
    $thumbnails = array();
    $filename = $user_id . "_" . rand(0, 10000);
    $phy_path = dirname(__FILE__) . "\\..\\upload\\";
    $uri_path = 'http://' . $_SERVER['SERVER_NAME'] . dirname($_SERVER["REQUEST_URI"]) . '/../upload/';
    $tmp_file = $_FILES["file"]["tmp_name"];
    $org_file = $phy_path . $filename . ".jpg";
    move_uploaded_file($tmp_file, $org_file);
    $info = ImageInfo::getImageInfo($org_file);
    $latitude = $info['lat'];
    $longitude = $info['lng'];
    $photo_shot = $info['photo_shot'];
    $description = $_GET['description'];
    $tags = explode(',', $_GET['tags']);
    if (!empty($latitude)) {
        // Create three pictures, 2 thumbnails and one main
        // Dimensions
        // Small: 160x120
        // Medium: 260x180
        // Large: 640x480
        array_push($thumbnails, array('phy_path' => create_thumb($org_file, $phy_path . $filename . "_small.jpg", 160, 120), 'uri_path' => $uri_path . $filename . "_small.jpg", 'type' => 0));
        array_push($thumbnails, array('phy_path' => create_thumb($org_file, $phy_path . $filename . "_medium.jpg", 260, 180), 'uri_path' => $uri_path . $filename . "_medium.jpg", 'type' => 1));
        array_push($thumbnails, array('phy_path' => create_thumb($org_file, $phy_path . $filename . "_large.jpg", 640, 480), 'uri_path' => $uri_path . $filename . "_large.jpg", 'type' => 2));
        $db->insertPicture($user_id, $phy_path . $filename . ".jpg", $uri_path . $filename . ".jpg", $latitude, $longitude, $photo_shot, $description, $tags, $thumbnails);
Example #6
0
 function resize($argImageBinary, $width = 0, $height = 0, $proportional = false)
 {
     if ($height <= 0 && $width <= 0) {
         return false;
     }
     $info = ImageInfo::getInfoFromData($argImageBinary);
     $image = imagecreatefromstring($argImageBinary);
     $final_width = 0;
     $final_height = 0;
     $width_old = $info->w;
     $height_old = $info->h;
     if (false !== $proportional) {
         if ($width == 0) {
             $factor = $height / $height_old;
         } elseif ($height == 0) {
             $factor = $width / $width_old;
         } else {
             $factor = min($width / $width_old, $height / $height_old);
         }
         $final_width = round($width_old * $factor);
         $final_height = round($height_old * $factor);
     } else {
         $final_width = $width;
         $final_height = $height;
         $width_gap = $width_old / $width;
         $height_gap = $height_old / $height;
     }
     $resizedImageData = imagecreatetruecolor($final_width, $final_height);
     if ($info->type == IMAGETYPE_GIF || $info->type == IMAGETYPE_PNG) {
         $trnprt_indx = imagecolortransparent($image);
         // If we have a specific transparent color
         if ($trnprt_indx >= 0) {
             // Get the original image's transparent color's RGB values
             $trnprt_color = imagecolorsforindex($image, $trnprt_indx);
             // Allocate the same color in the new image resource
             $trnprt_indx = imagecolorallocate($resizedImageData, $trnprt_color['red'], $trnprt_color['green'], $trnprt_color['blue']);
             // Completely fill the background of the new image with allocated color.
             imagefill($resizedImageData, 0, 0, $trnprt_indx);
             // Set the background color for new image to transparent
             imagecolortransparent($resizedImageData, $trnprt_indx);
         } elseif ($info->type == IMAGETYPE_PNG) {
             // Turn off transparency blending (temporarily)
             imagealphablending($resizedImageData, false);
             // Create a new transparent color for image
             $color = imagecolorallocatealpha($resizedImageData, 255, 255, 255, 127);
             // Completely fill the background of the new image with allocated color.
             imagefill($resizedImageData, 0, 0, $color);
             // Restore transparency blending
             imagesavealpha($resizedImageData, true);
         }
     }
     if (false !== $proportional) {
         imagecopyresampled($resizedImageData, $image, 0, 0, 0, 0, $final_width, $final_height, $width_old, $height_old);
     } else {
         //横より縦の比率が大きい場合は、求める画像サイズより縦長なので縦の上下をカット
         if ($width_gap < $height_gap) {
             $cut = ceil(($height_gap - $width_gap) * $final_height / 2);
             imagecopyresampled($resizedImageData, $image, 0, 0, 0, $cut, $final_width, $final_height, $width_old, $height_old - $cut * 2);
             //縦より横の比率が大きい場合は、求める画像サイズより横長なので横の左右をカット
         } elseif ($width_gap > $height_gap) {
             $cut = ceil(($width_gap - $height_gap) * $final_width / 2);
             imagecopyresampled($resizedImageData, $image, 0, 0, $cut, 0, $final_width, $final_height, $width_old - $cut * 2, $height_old);
             //縦横比が同じなら、そのまま縮小
         } else {
             imagecopyresampled($resizedImageData, $image, 0, 0, 0, 0, $final_width, $final_height, $width_old, $height_old);
         }
     }
     $imageBinary = NULL;
     ob_start();
     if (IMAGETYPE_JPEG == $info->type) {
         imagejpeg($resizedImageData);
     } elseif (IMAGETYPE_GIF == $info->type) {
         imagegif($resizedImageData);
     } elseif (IMAGETYPE_PNG == $info->type) {
         imagepng($resizedImageData);
     }
     $imageBinary = ob_get_clean();
     imagedestroy($resizedImageData);
     return $imageBinary;
 }
 function fromPath($path)
 {
     $info = ImageInfo::create($path);
     $ret = Image::fromImageInfo($info);
     return $ret;
 }