3 * @file include/Photo.php
4 * @brief This file contains the Photo class for image processing
8 use Friendica\Core\Cache;
9 use Friendica\Core\Config;
10 use Friendica\Core\System;
11 use Friendica\Database\DBM;
13 require_once("include/photos.php");
20 * Put back gd stuff, not everybody have Imagick
30 * @brief supported mimetypes and corresponding file extensions
32 public static function supportedTypes() {
33 if (class_exists('Imagick')) {
35 // Imagick::queryFormats won't help us a lot there...
36 // At least, not yet, other parts of friendica uses this array
38 'image/jpeg' => 'jpg',
44 $t['image/jpeg'] ='jpg';
45 if (imagetypes() & IMG_PNG) {
46 $t['image/png'] = 'png';
53 public function __construct($data, $type=null) {
54 $this->imagick = class_exists('Imagick');
55 $this->types = static::supportedTypes();
56 if (!array_key_exists($type, $this->types)){
61 if ($this->is_imagick() && $this->load_data($data)) {
64 // Failed to load with Imagick, fallback
65 $this->imagick = false;
67 return $this->load_data($data);
70 public function __destruct() {
72 if ($this->is_imagick()) {
73 $this->image->clear();
74 $this->image->destroy();
77 if (is_resource($this->image)) {
78 imagedestroy($this->image);
83 public function is_imagick() {
84 return $this->imagick;
88 * @brief Maps Mime types to Imagick formats
89 * @return arr With with image formats (mime type as key)
91 public function get_FormatsMap() {
93 'image/jpeg' => 'JPG',
100 private function load_data($data) {
101 if ($this->is_imagick()) {
102 $this->image = new Imagick();
104 $this->image->readImageBlob($data);
105 } catch (Exception $e) {
106 // Imagick couldn't use the data
111 * Setup the image to the format it will be saved to
113 $map = $this->get_FormatsMap();
114 $format = $map[$type];
115 $this->image->setFormat($format);
117 // Always coalesce, if it is not a multi-frame image it won't hurt anyway
118 $this->image = $this->image->coalesceImages();
121 * setup the compression here, so we'll do it only once
123 switch($this->getType()){
125 $quality = Config::get('system', 'png_quality');
126 if ((! $quality) || ($quality > 9)) {
127 $quality = PNG_QUALITY;
130 * From http://www.imagemagick.org/script/command-line-options.php#quality:
132 * 'For the MNG and PNG image formats, the quality value sets
133 * the zlib compression level (quality / 10) and filter-type (quality % 10).
134 * The default PNG "quality" is 75, which means compression level 7 with adaptive PNG filtering,
135 * unless the image has a color map, in which case it means compression level 7 with no PNG filtering'
137 $quality = $quality * 10;
138 $this->image->setCompressionQuality($quality);
141 $quality = Config::get('system', 'jpeg_quality');
142 if ((! $quality) || ($quality > 100)) {
143 $quality = JPEG_QUALITY;
145 $this->image->setCompressionQuality($quality);
148 // The 'width' and 'height' properties are only used by non-Imagick routines.
149 $this->width = $this->image->getImageWidth();
150 $this->height = $this->image->getImageHeight();
156 $this->valid = false;
157 $this->image = @imagecreatefromstring($data);
158 if ($this->image !== false) {
159 $this->width = imagesx($this->image);
160 $this->height = imagesy($this->image);
162 imagealphablending($this->image, false);
163 imagesavealpha($this->image, true);
171 public function is_valid() {
172 if ($this->is_imagick()) {
173 return ($this->image !== false);
178 public function getWidth() {
179 if (!$this->is_valid()) {
183 if ($this->is_imagick()) {
184 return $this->image->getImageWidth();
189 public function getHeight() {
190 if (!$this->is_valid()) {
194 if ($this->is_imagick()) {
195 return $this->image->getImageHeight();
197 return $this->height;
200 public function getImage() {
201 if (!$this->is_valid()) {
205 if ($this->is_imagick()) {
207 $this->image = $this->image->deconstructImages();
213 public function getType() {
214 if (!$this->is_valid()) {
221 public function getExt() {
222 if (!$this->is_valid()) {
226 return $this->types[$this->getType()];
229 public function scaleImage($max) {
230 if (!$this->is_valid()) {
234 $width = $this->getWidth();
235 $height = $this->getHeight();
237 $dest_width = $dest_height = 0;
239 if ((! $width)|| (! $height)) {
243 if ($width > $max && $height > $max) {
245 // very tall image (greater than 16:9)
246 // constrain the width - let the height float.
248 if ((($height * 9) / 16) > $width) {
250 $dest_height = intval(($height * $max) / $width);
251 } elseif ($width > $height) {
252 // else constrain both dimensions
254 $dest_height = intval(($height * $max) / $width);
256 $dest_width = intval(($width * $max) / $height);
262 $dest_height = intval(($height * $max) / $width);
264 if ($height > $max) {
266 // very tall image (greater than 16:9)
267 // but width is OK - don't do anything
269 if ((($height * 9) / 16) > $width) {
270 $dest_width = $width;
271 $dest_height = $height;
273 $dest_width = intval(($width * $max) / $height);
277 $dest_width = $width;
278 $dest_height = $height;
284 if ($this->is_imagick()) {
286 * If it is not animated, there will be only one iteration here,
287 * so don't bother checking
289 // Don't forget to go back to the first frame
290 $this->image->setFirstIterator();
293 // FIXME - implement horizantal bias for scaling as in followin GD functions
294 // to allow very tall images to be constrained only horizontally.
296 $this->image->scaleImage($dest_width, $dest_height);
297 } while ($this->image->nextImage());
299 // These may not be necessary any more
300 $this->width = $this->image->getImageWidth();
301 $this->height = $this->image->getImageHeight();
307 $dest = imagecreatetruecolor($dest_width, $dest_height);
308 imagealphablending($dest, false);
309 imagesavealpha($dest, true);
310 if ($this->type=='image/png') {
311 imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha
313 imagecopyresampled($dest, $this->image, 0, 0, 0, 0, $dest_width, $dest_height, $width, $height);
315 imagedestroy($this->image);
317 $this->image = $dest;
318 $this->width = imagesx($this->image);
319 $this->height = imagesy($this->image);
322 public function rotate($degrees) {
323 if (!$this->is_valid()) {
327 if ($this->is_imagick()) {
328 $this->image->setFirstIterator();
330 $this->image->rotateImage(new ImagickPixel(), -$degrees); // ImageMagick rotates in the opposite direction of imagerotate()
331 } while ($this->image->nextImage());
335 // if script dies at this point check memory_limit setting in php.ini
336 $this->image = imagerotate($this->image,$degrees,0);
337 $this->width = imagesx($this->image);
338 $this->height = imagesy($this->image);
341 public function flip($horiz = true, $vert = false) {
342 if (!$this->is_valid()) {
346 if ($this->is_imagick()) {
347 $this->image->setFirstIterator();
350 $this->image->flipImage();
353 $this->image->flopImage();
355 } while ($this->image->nextImage());
359 $w = imagesx($this->image);
360 $h = imagesy($this->image);
361 $flipped = imagecreate($w, $h);
363 for ($x = 0; $x < $w; $x++) {
364 imagecopy($flipped, $this->image, $x, 0, $w - $x - 1, 0, 1, $h);
368 for ($y = 0; $y < $h; $y++) {
369 imagecopy($flipped, $this->image, 0, $y, 0, $h - $y - 1, $w, 1);
372 $this->image = $flipped;
375 public function orient($filename) {
376 if ($this->is_imagick()) {
377 // based off comment on http://php.net/manual/en/imagick.getimageorientation.php
378 $orientation = $this->image->getImageOrientation();
379 switch ($orientation) {
380 case imagick::ORIENTATION_BOTTOMRIGHT:
381 $this->image->rotateimage("#000", 180);
383 case imagick::ORIENTATION_RIGHTTOP:
384 $this->image->rotateimage("#000", 90);
386 case imagick::ORIENTATION_LEFTBOTTOM:
387 $this->image->rotateimage("#000", -90);
391 $this->image->setImageOrientation(imagick::ORIENTATION_TOPLEFT);
394 // based off comment on http://php.net/manual/en/function.imagerotate.php
396 if (!$this->is_valid()) {
400 if ((!function_exists('exif_read_data')) || ($this->getType() !== 'image/jpeg')) {
404 $exif = @exif_read_data($filename,null,true);
409 $ort = $exif['IFD0']['Orientation'];
416 case 2: // horizontal flip
420 case 3: // 180 rotate left
424 case 4: // vertical flip
425 $this->flip(false, true);
428 case 5: // vertical flip + 90 rotate right
429 $this->flip(false, true);
433 case 6: // 90 rotate right
437 case 7: // horizontal flip + 90 rotate right
442 case 8: // 90 rotate left
447 // logger('exif: ' . print_r($exif,true));
454 public function scaleImageUp($min) {
455 if (!$this->is_valid()) {
460 $width = $this->getWidth();
461 $height = $this->getHeight();
463 $dest_width = $dest_height = 0;
465 if ((!$width)|| (!$height)) {
469 if ($width < $min && $height < $min) {
470 if ($width > $height) {
472 $dest_height = intval(($height * $min) / $width);
474 $dest_width = intval(($width * $min) / $height);
480 $dest_height = intval(($height * $min) / $width);
482 if ($height < $min) {
483 $dest_width = intval(($width * $min) / $height);
486 $dest_width = $width;
487 $dest_height = $height;
492 if ($this->is_imagick()) {
493 return $this->scaleImage($dest_width, $dest_height);
496 $dest = imagecreatetruecolor($dest_width, $dest_height);
497 imagealphablending($dest, false);
498 imagesavealpha($dest, true);
499 if ($this->type=='image/png') {
500 imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha
502 imagecopyresampled($dest, $this->image, 0, 0, 0, 0, $dest_width, $dest_height, $width, $height);
504 imagedestroy($this->image);
506 $this->image = $dest;
507 $this->width = imagesx($this->image);
508 $this->height = imagesy($this->image);
513 public function scaleImageSquare($dim) {
514 if (!$this->is_valid()) {
518 if ($this->is_imagick()) {
519 $this->image->setFirstIterator();
521 $this->image->scaleImage($dim, $dim);
522 } while ($this->image->nextImage());
526 $dest = imagecreatetruecolor($dim, $dim);
527 imagealphablending($dest, false);
528 imagesavealpha($dest, true);
529 if ($this->type=='image/png') {
530 imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha
532 imagecopyresampled($dest, $this->image, 0, 0, 0, 0, $dim, $dim, $this->width, $this->height);
534 imagedestroy($this->image);
536 $this->image = $dest;
537 $this->width = imagesx($this->image);
538 $this->height = imagesy($this->image);
542 public function cropImage($max, $x, $y, $w, $h) {
543 if (!$this->is_valid()) {
547 if ($this->is_imagick()) {
548 $this->image->setFirstIterator();
550 $this->image->cropImage($w, $h, $x, $y);
552 * We need to remove the canva,
553 * or the image is not resized to the crop:
554 * http://php.net/manual/en/imagick.cropimage.php#97232
556 $this->image->setImagePage(0, 0, 0, 0);
557 } while ($this->image->nextImage());
558 return $this->scaleImage($max);
561 $dest = imagecreatetruecolor($max, $max);
562 imagealphablending($dest, false);
563 imagesavealpha($dest, true);
564 if ($this->type=='image/png') {
565 imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha
567 imagecopyresampled($dest, $this->image, 0, 0, $x, $y, $max, $max, $w, $h);
569 imagedestroy($this->image);
571 $this->image = $dest;
572 $this->width = imagesx($this->image);
573 $this->height = imagesy($this->image);
576 public function saveImage($path) {
577 if (!$this->is_valid()) {
581 $string = $this->imageString();
585 $stamp1 = microtime(true);
586 file_put_contents($path, $string);
587 $a->save_timestamp($stamp1, "file");
590 public function imageString() {
591 if (!$this->is_valid()) {
595 if ($this->is_imagick()) {
597 $this->image = $this->image->deconstructImages();
598 $string = $this->image->getImagesBlob();
606 // Enable interlacing
607 imageinterlace($this->image, true);
609 switch($this->getType()){
611 $quality = Config::get('system', 'png_quality');
612 if ((!$quality) || ($quality > 9)) {
613 $quality = PNG_QUALITY;
615 imagepng($this->image, null, $quality);
618 $quality = Config::get('system', 'jpeg_quality');
619 if ((!$quality) || ($quality > 100)) {
620 $quality = JPEG_QUALITY;
622 imagejpeg($this->image, null, $quality);
624 $string = ob_get_contents();
632 public function store($uid, $cid, $rid, $filename, $album, $scale, $profile = 0, $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '', $desc = '') {
634 $r = dba::select('photo', array('guid'), array("`resource-id` = ? AND `guid` != ?", $rid, ''), array('limit' => 1));
635 if (DBM::is_result($r)) {
641 $x = dba::select('photo', array('id'), array('resource-id' => $rid, 'uid' => $uid, 'contact-id' => $cid, 'scale' => $scale), array('limit' => 1));
643 $fields = array('uid' => $uid, 'contact-id' => $cid, 'guid' => $guid, 'resource-id' => $rid, 'created' => datetime_convert(), 'edited' => datetime_convert(),
644 'filename' => basename($filename), 'type' => $this->getType(), 'album' => $album, 'height' => $this->getHeight(), 'width' => $this->getWidth(),
645 'datasize' => strlen($this->imageString()), 'data' => $this->imageString(), 'scale' => $scale, 'profile' => $profile,
646 'allow_cid' => $allow_cid, 'allow_gid' => $allow_gid, 'deny_cid' => $deny_cid, 'deny_gid' => $deny_gid, 'desc' => $desc);
648 if (DBM::is_result($x)) {
649 $r = dba::update('photo', $fields, array('id' => $x['id']));
651 $r = dba::insert('photo', $fields);
660 * Guess image mimetype from filename or from Content-Type header
662 * @arg $filename string Image filename
663 * @arg $fromcurl boolean Check Content-Type header from curl request
665 function guess_image_type($filename, $fromcurl=false) {
666 logger('Photo: guess_image_type: '.$filename . ($fromcurl?' from curl headers':''), LOGGER_DEBUG);
671 $h = explode("\n",$a->get_curl_headers());
673 list($k,$v) = array_map("trim", explode(":", trim($l), 2));
676 if (array_key_exists('Content-Type', $headers))
677 $type = $headers['Content-Type'];
680 // Guessing from extension? Isn't that... dangerous?
681 if (class_exists('Imagick') && file_exists($filename) && is_readable($filename)) {
683 * Well, this not much better,
684 * but at least it comes from the data inside the image,
685 * we won't be tricked by a manipulated extension
687 $image = new Imagick($filename);
688 $type = $image->getImageMimeType();
689 $image->setInterlaceScheme(Imagick::INTERLACE_PLANE);
691 $ext = pathinfo($filename, PATHINFO_EXTENSION);
692 $types = Photo::supportedTypes();
693 $type = "image/jpeg";
694 foreach ($types as $m => $e){
701 logger('Photo: guess_image_type: type='.$type, LOGGER_DEBUG);
707 * @brief Updates the avatar links in a contact only if needed
709 * @param string $avatar Link to avatar picture
710 * @param int $uid User id of contact owner
711 * @param int $cid Contact id
712 * @param bool $force force picture update
714 * @return array Returns array of the different avatar sizes
716 function update_contact_avatar($avatar, $uid, $cid, $force = false) {
717 $r = q("SELECT `avatar`, `photo`, `thumb`, `micro`, `nurl` FROM `contact` WHERE `id` = %d LIMIT 1", intval($cid));
718 if (!DBM::is_result($r)) {
721 $data = array($r[0]["photo"], $r[0]["thumb"], $r[0]["micro"]);
724 if (($r[0]["avatar"] != $avatar) || $force) {
725 $photos = import_profile_photo($avatar, $uid, $cid, true);
728 q("UPDATE `contact` SET `avatar` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s', `avatar-date` = '%s' WHERE `id` = %d",
729 dbesc($avatar), dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]),
730 dbesc(datetime_convert()), intval($cid));
732 // Update the public contact (contact id = 0)
734 $pcontact = dba::select('contact', array('id'), array('nurl' => $r[0]['nurl']), array('limit' => 1));
735 if (DBM::is_result($pcontact)) {
736 update_contact_avatar($avatar, 0, $pcontact['id'], $force);
747 function import_profile_photo($photo, $uid, $cid, $quit_on_error = false) {
749 $r = q("SELECT `resource-id` FROM `photo` WHERE `uid` = %d AND `contact-id` = %d AND `scale` = 4 AND `album` = 'Contact Photos' LIMIT 1",
753 if (DBM::is_result($r) && strlen($r[0]['resource-id'])) {
754 $hash = $r[0]['resource-id'];
756 $hash = photo_new_resource();
759 $photo_failure = false;
761 $filename = basename($photo);
762 $img_str = fetch_url($photo, true);
764 if ($quit_on_error && ($img_str == "")) {
768 $type = guess_image_type($photo, true);
769 $img = new Photo($img_str, $type);
770 if ($img->is_valid()) {
772 $img->scaleImageSquare(175);
774 $r = $img->store($uid, $cid, $hash, $filename, 'Contact Photos', 4);
777 $photo_failure = true;
779 $img->scaleImage(80);
781 $r = $img->store($uid, $cid, $hash, $filename, 'Contact Photos', 5);
784 $photo_failure = true;
786 $img->scaleImage(48);
788 $r = $img->store($uid, $cid, $hash, $filename, 'Contact Photos', 6);
791 $photo_failure = true;
794 $suffix = '?ts='.time();
796 $photo = System::baseUrl() . '/photo/' . $hash . '-4.' . $img->getExt() . $suffix;
797 $thumb = System::baseUrl() . '/photo/' . $hash . '-5.' . $img->getExt() . $suffix;
798 $micro = System::baseUrl() . '/photo/' . $hash . '-6.' . $img->getExt() . $suffix;
800 // Remove the cached photo
802 $basepath = $a->get_basepath();
804 if (is_dir($basepath."/photo")) {
805 $filename = $basepath.'/photo/'.$hash.'-4.'.$img->getExt();
806 if (file_exists($filename)) {
809 $filename = $basepath.'/photo/'.$hash.'-5.'.$img->getExt();
810 if (file_exists($filename)) {
813 $filename = $basepath.'/photo/'.$hash.'-6.'.$img->getExt();
814 if (file_exists($filename)) {
819 $photo_failure = true;
822 if ($photo_failure && $quit_on_error) {
826 if ($photo_failure) {
827 $photo = System::baseUrl() . '/images/person-175.jpg';
828 $thumb = System::baseUrl() . '/images/person-80.jpg';
829 $micro = System::baseUrl() . '/images/person-48.jpg';
832 return(array($photo,$thumb,$micro));
836 function get_photo_info($url) {
839 $data = Cache::get($url);
841 if (is_null($data) || !$data || !is_array($data)) {
842 $img_str = fetch_url($url, true, $redirects, 4);
843 $filesize = strlen($img_str);
845 if (function_exists("getimagesizefromstring")) {
846 $data = getimagesizefromstring($img_str);
848 $tempfile = tempnam(get_temppath(), "cache");
851 $stamp1 = microtime(true);
852 file_put_contents($tempfile, $img_str);
853 $a->save_timestamp($stamp1, "file");
855 $data = getimagesize($tempfile);
860 $data["size"] = $filesize;
863 Cache::set($url, $data);
869 function scale_image($width, $height, $max) {
871 $dest_width = $dest_height = 0;
873 if ((!$width) || (!$height)) {
877 if ($width > $max && $height > $max) {
879 // very tall image (greater than 16:9)
880 // constrain the width - let the height float.
882 if ((($height * 9) / 16) > $width) {
884 $dest_height = intval(($height * $max) / $width);
885 } elseif ($width > $height) {
886 // else constrain both dimensions
888 $dest_height = intval(($height * $max) / $width);
890 $dest_width = intval(($width * $max) / $height);
896 $dest_height = intval(($height * $max) / $width);
898 if ($height > $max) {
900 // very tall image (greater than 16:9)
901 // but width is OK - don't do anything
903 if ((($height * 9) / 16) > $width) {
904 $dest_width = $width;
905 $dest_height = $height;
907 $dest_width = intval(($width * $max) / $height);
911 $dest_width = $width;
912 $dest_height = $height;
916 return array("width" => $dest_width, "height" => $dest_height);
919 function store_photo(App $a, $uid, $imagedata = "", $url = "") {
920 $r = q("SELECT `user`.`nickname`, `user`.`page-flags`, `contact`.`id` FROM `user` INNER JOIN `contact` on `user`.`uid` = `contact`.`uid`
921 WHERE `user`.`uid` = %d AND `user`.`blocked` = 0 AND `contact`.`self` = 1 LIMIT 1",
924 if (!DBM::is_result($r)) {
925 logger("Can't detect user data for uid ".$uid, LOGGER_DEBUG);
929 $page_owner_nick = $r[0]['nickname'];
932 /// $default_cid = $r[0]['id'];
933 /// $community_page = (($r[0]['page-flags'] == PAGE_COMMUNITY) ? true : false);
935 if ((strlen($imagedata) == 0) && ($url == "")) {
936 logger("No image data and no url provided", LOGGER_DEBUG);
938 } elseif (strlen($imagedata) == 0) {
939 logger("Uploading picture from ".$url, LOGGER_DEBUG);
941 $stamp1 = microtime(true);
942 $imagedata = @file_get_contents($url);
943 $a->save_timestamp($stamp1, "file");
946 $maximagesize = Config::get('system', 'maximagesize');
948 if (($maximagesize) && (strlen($imagedata) > $maximagesize)) {
949 logger("Image exceeds size limit of ".$maximagesize, LOGGER_DEBUG);
953 $tempfile = tempnam(get_temppath(), "cache");
955 $stamp1 = microtime(true);
956 file_put_contents($tempfile, $imagedata);
957 $a->save_timestamp($stamp1, "file");
959 $data = getimagesize($tempfile);
961 if (!isset($data["mime"])) {
963 logger("File is no picture", LOGGER_DEBUG);
967 $ph = new Photo($imagedata, $data["mime"]);
969 if (!$ph->is_valid()) {
971 logger("Picture is no valid picture", LOGGER_DEBUG);
975 $ph->orient($tempfile);
978 $max_length = Config::get('system', 'max_image_length');
980 $max_length = MAX_IMAGE_LENGTH;
982 if ($max_length > 0) {
983 $ph->scaleImage($max_length);
986 $width = $ph->getWidth();
987 $height = $ph->getHeight();
989 $hash = photo_new_resource();
993 // Pictures are always public by now
994 //$defperm = '<'.$default_cid.'>';
998 $r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 0, 0, $defperm);
1001 logger("Picture couldn't be stored", LOGGER_DEBUG);
1005 $image = array("page" => System::baseUrl().'/photos/'.$page_owner_nick.'/image/'.$hash,
1006 "full" => System::baseUrl()."/photo/{$hash}-0.".$ph->getExt());
1008 if ($width > 800 || $height > 800) {
1009 $image["large"] = System::baseUrl()."/photo/{$hash}-0.".$ph->getExt();
1012 if ($width > 640 || $height > 640) {
1013 $ph->scaleImage(640);
1014 $r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 1, 0, $defperm);
1016 $image["medium"] = System::baseUrl()."/photo/{$hash}-1.".$ph->getExt();
1020 if ($width > 320 || $height > 320) {
1021 $ph->scaleImage(320);
1022 $r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 2, 0, $defperm);
1024 $image["small"] = System::baseUrl()."/photo/{$hash}-2.".$ph->getExt();
1028 if ($width > 160 && $height > 160) {
1032 $min = $ph->getWidth();
1034 $x = ($min - 160) / 2;
1037 if ($ph->getHeight() < $min) {
1038 $min = $ph->getHeight();
1040 $y = ($min - 160) / 2;
1045 $ph->cropImage(160, $x, $y, $min, $min);
1047 $r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 3, 0, $defperm);
1049 $image["thumb"] = System::baseUrl()."/photo/{$hash}-3.".$ph->getExt();
1053 // Set the full image as preview image. This will be overwritten, if the picture is larger than 640.
1054 $image["preview"] = $image["full"];
1056 // Deactivated, since that would result in a cropped preview, if the picture wasn't larger than 320
1057 //if (isset($image["thumb"]))
1058 // $image["preview"] = $image["thumb"];
1060 // Unsure, if this should be activated or deactivated
1061 //if (isset($image["small"]))
1062 // $image["preview"] = $image["small"];
1064 if (isset($image["medium"])) {
1065 $image["preview"] = $image["medium"];