/** * creates a transient image (that is, one that is not stored in the database) * * @param object $gallery * @param string $image the full path to the image * @return transientimage */ function Transientimage(&$album, $image) { if (!is_object($album)) { return NULL; } $this->album = $album; $this->localpath = $image; $filename = makeSpecialImageName($image); $this->filename = $filename; $this->displayname = substr(basename($image), 0, strrpos(basename($image), '.')); if (empty($this->displayname)) { $this->displayname = $this->filename; } $this->filemtime = filemtime($this->localpath); $this->comments = null; parent::PersistentObject('images', array('filename' => $filename, 'albumid' => $this->album->id), 'filename', false, true); }
/** * Get a custom sized version of this image based on the parameters. * * @param string $alt Alt text for the url * @param int $size size * @param int $width width * @param int $height height * @param int $cropw crop width * @param int $croph crop height * @param int $cropx crop x axis * @param int $cropy crop y axis * @param string $class Optional style class * @param string $id Optional style id * @param bool $thumbStandin set true to inhibit watermarking * @return string */ function getCustomImage($size, $width, $height, $cropw, $croph, $cropx, $cropy, $thumbStandin = false) { if ($thumbStandin & 1) { if ($this->objectsThumb == NULL) { $filename = makeSpecialImageName($this->getThumbImageFile()); $path = ZENFOLDER . '/i.php?a=' . urlencode($this->album->name) . '&i=' . urlencode($filename); return WEBPATH . "/" . $path . ($size ? "&s={$size}" : "") . ($width ? "&w={$width}" : "") . ($height ? "&h={$height}" : "") . ($cropw ? "&cw={$cropw}" : "") . ($croph ? "&ch={$croph}" : "") . ($cropx ? "&cx={$cropx}" : "") . ($cropy ? "&cy={$cropy}" : "") . "&t=true"; } else { $filename = $this->objectsThumb; $wmt = getOption(get_class($this) . '_watermark'); if ($wmt) { $wmt = '&wmt=' . $wmt; } $cachefilename = getImageCacheFilename($alb = $this->album->name, $filename, getImageParameters(array($size, $width, $height, $cropw, $croph, $cropx, $cropy, NULL, NULL, NULL, $thumbStandin, NULL, NULL))); if (file_exists(SERVERCACHE . $cachefilename) && filemtime(SERVERCACHE . $cachefilename) > $this->filemtime) { return WEBPATH . substr(CACHEFOLDER, 0, -1) . pathurlencode(imgSrcURI($cachefilename)); } else { $path = ZENFOLDER . '/i.php?a=' . urlencode($alb) . '&i=' . urlencode($filename); if (substr($path, 0, 1) == "/") { $path = substr($path, 1); } return WEBPATH . "/" . $path . ($size ? "&s={$size}" : "") . ($width ? "&w={$width}" : "") . ($height ? "&h={$height}" : "") . ($cropw ? "&cw={$cropw}" : "") . ($croph ? "&ch={$croph}" : "") . ($cropx ? "&cx={$cropx}" : "") . ($cropy ? "&cy={$cropy}" : "") . "&t=true" . $wmt; } } } else { $filename = $this->filename; $cachefilename = getImageCacheFilename($this->album->name, $filename, getImageParameters(array($size, $width, $height, $cropw, $croph, $cropx, $cropy, NULL, NULL, NULL, $thumbStandin, NULL, NULL))); if (file_exists(SERVERCACHE . $cachefilename) && filemtime(SERVERCACHE . $cachefilename) > $this->filemtime) { return WEBPATH . substr(CACHEFOLDER, 0, -1) . pathurlencode(imgSrcURI($cachefilename)); } else { return WEBPATH . '/' . ZENFOLDER . '/i.php?a=' . urlencode($this->album->name) . '&i=' . urlencode($filename) . ($size ? "&s={$size}" : "") . ($width ? "&w={$width}" : "") . ($height ? "&h={$height}" : "") . ($cropw ? "&cw={$cropw}" : "") . ($croph ? "&ch={$croph}" : "") . ($cropx ? "&cx={$cropx}" : "") . ($cropy ? "&cy={$cropy}" : ""); } } }
/** * Get a custom sized version of this image based on the parameters. * * @param string $alt Alt text for the url * @param int $size size * @param int $width width * @param int $height height * @param int $cropw crop width * @param int $croph crop height * @param int $cropx crop x axis * @param int $cropy crop y axis * @param string $class Optional style class * @param string $id Optional style id * @param bool $thumbStandin set to true to treat as thumbnail * @param bool $effects ignored * @return string */ function getCustomImage($size, $width, $height, $cropw, $croph, $cropx, $cropy, $thumbStandin = false, $effects = NULL) { if ($thumbStandin) { $wmt = getOption('Video_watermark'); if (empty($wmt)) { $wmt = getWatermarkParam($this, WATERMARK_THUMB); } } else { $wmt = NULL; } if ($thumbStandin & 1) { $args = array($size, $width, $height, $cropw, $croph, $cropx, $cropy, NULL, $thumbStandin, NULL, $thumbStandin, NULL, NULL, NULL); if ($this->objectsThumb == NULL) { $filename = makeSpecialImageName($this->getThumbImageFile()); if (!getOption('video_watermark_default_images')) { $args[11] = '!'; } $mtime = NULL; } else { $filename = filesystemToInternal($this->objectsThumb); $mtime = filemtime(ALBUM_FOLDER_SERVERPATH . '/' . internalToFilesystem($this->imagefolder) . '/' . $this->objectsThumb); } return getImageURI($args, $this->album->name, $filename, $this->filemtime); } else { $args = getImageParameters(array($size, $width, $height, $cropw, $croph, $cropx, $cropy, NULL, $thumbStandin, NULL, $thumbStandin, $wmt, NULL, $effects), $this->album->name); $filename = $this->filename; return getImageURI($args, $this->album->name, $filename, $this->filemtime); } }
} $timg = get_image($imgpath); $width = imagesx($timg); $height = imagesy($timg); } if (getOption('thumb_crop')) { $thumbcropwidth = $cropwidth; $thumbcropheight = $cropheight; } else { if (isImagePhoto($imageobj)) { $thumbcropwidth = $imageobj->getWidth(); $thumbcropheight = $imageobj->getHeight(); } else { $imgpath = getThumbImageFile(); if ($this->objectsThumb == NULL) { $imagepart = makeSpecialImageName($imgpath); } else { $imagepart = basename($imgpath); } $thumbcropwidth = imagesx($timg); $thumbcropheight = imagesy($timg); } $tsize = getOption('thumb_size'); $max = max($thumbcropwidth, $thumbcropheight); $thumbcropwidth = $thumbcropwidth * ($tsize / $max); $thumbcropheight = $thumbcropheight * ($tsize / $max); } $size = min(400, $width, $height); if ($width >= $height) { $sr = $size / $width; $sizedwidth = $size;
/** * Get a custom sized version of this image based on the parameters. * * @param string $alt Alt text for the url * @param int $size size * @param int $width width * @param int $height height * @param int $cropw crop width * @param int $croph crop height * @param int $cropx crop x axis * @param int $cropy crop y axis * @param string $class Optional style class * @param string $id Optional style id * @param bool $thumbStandin set to true to treat as thumbnail * @param bool $effects ignored * @return string */ function getCustomImage($size, $width, $height, $cropw, $croph, $cropx, $cropy, $thumbStandin = false, $effects = NULL) { if ($thumbStandin) { $wmt = getOption('Video_watermark'); if (empty($wmt)) { $wmt = getWatermarkParam($this, WATERMARK_THUMB); } } else { $wmt = NULL; } $args = getImageParameters(array($size, $width, $height, $cropw, $croph, $cropx, $cropy, NULL, $thumbStandin, NULL, $thumbStandin, $wmt, NULL, $effects), $this->album->name); if ($thumbStandin & 1) { if ($this->objectsThumb == NULL) { $filename = makeSpecialImageName($this->getThumbImageFile()); if (!getOption('video_watermark_default_images')) { $args[11] = '!'; } return getImageProcessorURI($args, $this->album->name, $filename); } else { $filename = $this->objectsThumb; $cachefilename = getImageCacheFilename($alb = $this->album->name, $filename, getImageParameters(array($size, $width, $height, $cropw, $croph, $cropx, $cropy, NULL, $thumbStandin, NULL, $thumbStandin, NULL, NULL, NULL)), $this->album->name); if (file_exists(SERVERCACHE . $cachefilename) && filemtime(SERVERCACHE . $cachefilename) > $this->filemtime) { return WEBPATH . '/' . CACHEFOLDER . pathurlencode(imgSrcURI($cachefilename)); } else { return getImageProcessorURI($args, $this->album->name, $filename); } } } else { $filename = $this->filename; $cachefilename = getImageCacheFilename($this->album->name, $filename, $args); if (file_exists(SERVERCACHE . $cachefilename) && filemtime(SERVERCACHE . $cachefilename) > $this->filemtime) { return WEBPATH . '/' . CACHEFOLDER . pathurlencode(imgSrcURI($cachefilename)); } else { return getImageProcessorURI($args, $this->album->name, $filename); } } }
/** * creates a transient image (that is, one that is not stored in the database) * * @param string $image the full path to the image * @return transientimage */ function __construct($album, $image) { if (!is_object($album)) { $album = new AlbumBase('Transient'); } $this->album = $album; $this->localpath = $image; $filename = makeSpecialImageName($image); $this->filename = $filename; $this->displayname = stripSuffix(basename($image)); if (empty($this->displayname)) { $this->displayname = $this->filename['name']; } $this->filemtime = @filemtime($this->localpath); $this->comments = null; $this->instantiate('images', array('filename' => $filename['name'], 'albumid' => $this->album->getID()), 'filename', true, true); $this->exists = false; }