3 * @file include/Photo.php
4 * @brief This file contains the Photo class for image processing
7 require_once("include/photos.php");
14 * Put back gd stuff, not everybody have Imagick
24 * @brief supported mimetypes and corresponding file extensions
26 static function supportedTypes() {
27 if (class_exists('Imagick')) {
29 // Imagick::queryFormats won't help us a lot there...
30 // At least, not yet, other parts of friendica uses this array
32 'image/jpeg' => 'jpg',
38 $t['image/jpeg'] ='jpg';
39 if (imagetypes() & IMG_PNG) {
40 $t['image/png'] = 'png';
47 public function __construct($data, $type=null) {
48 $this->imagick = class_exists('Imagick');
49 $this->types = $this->supportedTypes();
50 if (!array_key_exists($type, $this->types)){
55 if ($this->is_imagick() && $this->load_data($data)) {
58 // Failed to load with Imagick, fallback
59 $this->imagick = false;
61 return $this->load_data($data);
64 public function __destruct() {
66 if ($this->is_imagick()) {
67 $this->image->clear();
68 $this->image->destroy();
71 if (is_resource($this->image)) {
72 imagedestroy($this->image);
77 public function is_imagick() {
78 return $this->imagick;
82 * @brief Maps Mime types to Imagick formats
83 * @return arr With with image formats (mime type as key)
85 public function get_FormatsMap() {
87 'image/jpeg' => 'JPG',
94 private function load_data($data) {
95 if ($this->is_imagick()) {
96 $this->image = new Imagick();
98 $this->image->readImageBlob($data);
99 } catch (Exception $e) {
100 // Imagick couldn't use the data
105 * Setup the image to the format it will be saved to
107 $map = $this->get_FormatsMap();
108 $format = $map[$type];
109 $this->image->setFormat($format);
111 // Always coalesce, if it is not a multi-frame image it won't hurt anyway
112 $this->image = $this->image->coalesceImages();
115 * setup the compression here, so we'll do it only once
117 switch($this->getType()){
119 $quality = get_config('system', 'png_quality');
120 if ((! $quality) || ($quality > 9)) {
121 $quality = PNG_QUALITY;
124 * From http://www.imagemagick.org/script/command-line-options.php#quality:
126 * 'For the MNG and PNG image formats, the quality value sets
127 * the zlib compression level (quality / 10) and filter-type (quality % 10).
128 * The default PNG "quality" is 75, which means compression level 7 with adaptive PNG filtering,
129 * unless the image has a color map, in which case it means compression level 7 with no PNG filtering'
131 $quality = $quality * 10;
132 $this->image->setCompressionQuality($quality);
135 $quality = get_config('system', 'jpeg_quality');
136 if ((! $quality) || ($quality > 100)) {
137 $quality = JPEG_QUALITY;
139 $this->image->setCompressionQuality($quality);
142 // The 'width' and 'height' properties are only used by non-Imagick routines.
143 $this->width = $this->image->getImageWidth();
144 $this->height = $this->image->getImageHeight();
150 $this->valid = false;
151 $this->image = @imagecreatefromstring($data);
152 if ($this->image !== false) {
153 $this->width = imagesx($this->image);
154 $this->height = imagesy($this->image);
156 imagealphablending($this->image, false);
157 imagesavealpha($this->image, true);
165 public function is_valid() {
166 if ($this->is_imagick()) {
167 return ($this->image !== false);
172 public function getWidth() {
173 if (!$this->is_valid()) {
177 if ($this->is_imagick()) {
178 return $this->image->getImageWidth();
183 public function getHeight() {
184 if (!$this->is_valid()) {
188 if ($this->is_imagick()) {
189 return $this->image->getImageHeight();
191 return $this->height;
194 public function getImage() {
195 if (!$this->is_valid()) {
199 if ($this->is_imagick()) {
201 $this->image = $this->image->deconstructImages();
207 public function getType() {
208 if (!$this->is_valid()) {
215 public function getExt() {
216 if (!$this->is_valid()) {
220 return $this->types[$this->getType()];
223 public function scaleImage($max) {
224 if (!$this->is_valid()) {
228 $width = $this->getWidth();
229 $height = $this->getHeight();
231 $dest_width = $dest_height = 0;
233 if ((! $width)|| (! $height)) {
237 if ($width > $max && $height > $max) {
239 // very tall image (greater than 16:9)
240 // constrain the width - let the height float.
242 if ((($height * 9) / 16) > $width) {
244 $dest_height = intval(($height * $max) / $width);
245 } elseif ($width > $height) {
246 // else constrain both dimensions
248 $dest_height = intval(($height * $max) / $width);
250 $dest_width = intval(($width * $max) / $height);
256 $dest_height = intval(($height * $max) / $width);
258 if ($height > $max) {
260 // very tall image (greater than 16:9)
261 // but width is OK - don't do anything
263 if ((($height * 9) / 16) > $width) {
264 $dest_width = $width;
265 $dest_height = $height;
267 $dest_width = intval(($width * $max) / $height);
271 $dest_width = $width;
272 $dest_height = $height;
278 if ($this->is_imagick()) {
280 * If it is not animated, there will be only one iteration here,
281 * so don't bother checking
283 // Don't forget to go back to the first frame
284 $this->image->setFirstIterator();
287 // FIXME - implement horizantal bias for scaling as in followin GD functions
288 // to allow very tall images to be constrained only horizontally.
290 $this->image->scaleImage($dest_width, $dest_height);
291 } while ($this->image->nextImage());
293 // These may not be necessary any more
294 $this->width = $this->image->getImageWidth();
295 $this->height = $this->image->getImageHeight();
301 $dest = imagecreatetruecolor($dest_width, $dest_height);
302 imagealphablending($dest, false);
303 imagesavealpha($dest, true);
304 if ($this->type=='image/png') {
305 imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha
307 imagecopyresampled($dest, $this->image, 0, 0, 0, 0, $dest_width, $dest_height, $width, $height);
309 imagedestroy($this->image);
311 $this->image = $dest;
312 $this->width = imagesx($this->image);
313 $this->height = imagesy($this->image);
316 public function rotate($degrees) {
317 if (!$this->is_valid()) {
321 if ($this->is_imagick()) {
322 $this->image->setFirstIterator();
324 $this->image->rotateImage(new ImagickPixel(), -$degrees); // ImageMagick rotates in the opposite direction of imagerotate()
325 } while ($this->image->nextImage());
329 // if script dies at this point check memory_limit setting in php.ini
330 $this->image = imagerotate($this->image,$degrees,0);
331 $this->width = imagesx($this->image);
332 $this->height = imagesy($this->image);
335 public function flip($horiz = true, $vert = false) {
336 if (!$this->is_valid()) {
340 if ($this->is_imagick()) {
341 $this->image->setFirstIterator();
344 $this->image->flipImage();
347 $this->image->flopImage();
349 } while ($this->image->nextImage());
353 $w = imagesx($this->image);
354 $h = imagesy($this->image);
355 $flipped = imagecreate($w, $h);
357 for ($x = 0; $x < $w; $x++) {
358 imagecopy($flipped, $this->image, $x, 0, $w - $x - 1, 0, 1, $h);
362 for ($y = 0; $y < $h; $y++) {
363 imagecopy($flipped, $this->image, 0, $y, 0, $h - $y - 1, $w, 1);
366 $this->image = $flipped;
369 public function orient($filename) {
370 if ($this->is_imagick()) {
371 // based off comment on http://php.net/manual/en/imagick.getimageorientation.php
372 $orientation = $this->image->getImageOrientation();
373 switch ($orientation) {
374 case imagick::ORIENTATION_BOTTOMRIGHT:
375 $this->image->rotateimage("#000", 180);
377 case imagick::ORIENTATION_RIGHTTOP:
378 $this->image->rotateimage("#000", 90);
380 case imagick::ORIENTATION_LEFTBOTTOM:
381 $this->image->rotateimage("#000", -90);
385 $this->image->setImageOrientation(imagick::ORIENTATION_TOPLEFT);
388 // based off comment on http://php.net/manual/en/function.imagerotate.php
390 if (!$this->is_valid()) {
394 if ((!function_exists('exif_read_data')) || ($this->getType() !== 'image/jpeg')) {
398 $exif = @exif_read_data($filename,null,true);
403 $ort = $exif['IFD0']['Orientation'];
410 case 2: // horizontal flip
414 case 3: // 180 rotate left
418 case 4: // vertical flip
419 $this->flip(false, true);
422 case 5: // vertical flip + 90 rotate right
423 $this->flip(false, true);
427 case 6: // 90 rotate right
431 case 7: // horizontal flip + 90 rotate right
436 case 8: // 90 rotate left
441 // logger('exif: ' . print_r($exif,true));
448 public function scaleImageUp($min) {
449 if (!$this->is_valid()) {
454 $width = $this->getWidth();
455 $height = $this->getHeight();
457 $dest_width = $dest_height = 0;
459 if ((!$width)|| (!$height)) {
463 if ($width < $min && $height < $min) {
464 if ($width > $height) {
466 $dest_height = intval(($height * $min) / $width);
468 $dest_width = intval(($width * $min) / $height);
474 $dest_height = intval(($height * $min) / $width);
476 if ($height < $min) {
477 $dest_width = intval(($width * $min) / $height);
480 $dest_width = $width;
481 $dest_height = $height;
486 if ($this->is_imagick()) {
487 return $this->scaleImage($dest_width, $dest_height);
490 $dest = imagecreatetruecolor($dest_width, $dest_height);
491 imagealphablending($dest, false);
492 imagesavealpha($dest, true);
493 if ($this->type=='image/png') {
494 imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha
496 imagecopyresampled($dest, $this->image, 0, 0, 0, 0, $dest_width, $dest_height, $width, $height);
498 imagedestroy($this->image);
500 $this->image = $dest;
501 $this->width = imagesx($this->image);
502 $this->height = imagesy($this->image);
507 public function scaleImageSquare($dim) {
508 if (!$this->is_valid()) {
512 if ($this->is_imagick()) {
513 $this->image->setFirstIterator();
515 $this->image->scaleImage($dim, $dim);
516 } while ($this->image->nextImage());
520 $dest = imagecreatetruecolor($dim, $dim);
521 imagealphablending($dest, false);
522 imagesavealpha($dest, true);
523 if ($this->type=='image/png') {
524 imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha
526 imagecopyresampled($dest, $this->image, 0, 0, 0, 0, $dim, $dim, $this->width, $this->height);
528 imagedestroy($this->image);
530 $this->image = $dest;
531 $this->width = imagesx($this->image);
532 $this->height = imagesy($this->image);
536 public function cropImage($max, $x, $y, $w, $h) {
537 if (!$this->is_valid()) {
541 if ($this->is_imagick()) {
542 $this->image->setFirstIterator();
544 $this->image->cropImage($w, $h, $x, $y);
546 * We need to remove the canva,
547 * or the image is not resized to the crop:
548 * http://php.net/manual/en/imagick.cropimage.php#97232
550 $this->image->setImagePage(0, 0, 0, 0);
551 } while ($this->image->nextImage());
552 return $this->scaleImage($max);
555 $dest = imagecreatetruecolor($max, $max);
556 imagealphablending($dest, false);
557 imagesavealpha($dest, true);
558 if ($this->type=='image/png') {
559 imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha
561 imagecopyresampled($dest, $this->image, 0, 0, $x, $y, $max, $max, $w, $h);
563 imagedestroy($this->image);
565 $this->image = $dest;
566 $this->width = imagesx($this->image);
567 $this->height = imagesy($this->image);
570 public function saveImage($path) {
571 if (!$this->is_valid()) {
575 $string = $this->imageString();
579 $stamp1 = microtime(true);
580 file_put_contents($path, $string);
581 $a->save_timestamp($stamp1, "file");
584 public function imageString() {
585 if (!$this->is_valid()) {
589 if ($this->is_imagick()) {
591 $this->image = $this->image->deconstructImages();
592 $string = $this->image->getImagesBlob();
600 // Enable interlacing
601 imageinterlace($this->image, true);
603 switch($this->getType()){
605 $quality = get_config('system', 'png_quality');
606 if ((!$quality) || ($quality > 9)) {
607 $quality = PNG_QUALITY;
609 imagepng($this->image, null, $quality);
612 $quality = get_config('system', 'jpeg_quality');
613 if ((!$quality) || ($quality > 100)) {
614 $quality = JPEG_QUALITY;
616 imagejpeg($this->image, null, $quality);
618 $string = ob_get_contents();
626 public function store($uid, $cid, $rid, $filename, $album, $scale, $profile = 0, $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '', $desc = '') {
628 $r = q("SELECT `guid` FROM `photo` WHERE `resource-id` = '%s' AND `guid` != '' LIMIT 1",
631 if (dbm::is_result($r)) {
632 $guid = $r[0]['guid'];
637 $x = q("SELECT `id` FROM `photo` WHERE `resource-id` = '%s' AND `uid` = %d AND `contact-id` = %d AND `scale` = %d LIMIT 1",
643 if (dbm::is_result($x)) {
644 $r = q("UPDATE `photo`
648 `resource-id` = '%s',
671 dbesc(datetime_convert()),
672 dbesc(datetime_convert()),
673 dbesc(basename($filename)),
674 dbesc($this->getType()),
676 intval($this->getHeight()),
677 intval($this->getWidth()),
678 dbesc(strlen($this->imageString())),
679 dbesc($this->imageString()),
690 $r = q("INSERT INTO `photo`
691 (`uid`, `contact-id`, `guid`, `resource-id`, `created`, `edited`, `filename`, type, `album`, `height`, `width`, `datasize`, `data`, `scale`, `profile`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `desc`)
692 VALUES (%d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, '%s', %d, %d, '%s', '%s', '%s', '%s', '%s')",
697 dbesc(datetime_convert()),
698 dbesc(datetime_convert()),
699 dbesc(basename($filename)),
700 dbesc($this->getType()),
702 intval($this->getHeight()),
703 intval($this->getWidth()),
704 dbesc(strlen($this->imageString())),
705 dbesc($this->imageString()),
722 * Guess image mimetype from filename or from Content-Type header
724 * @arg $filename string Image filename
725 * @arg $fromcurl boolean Check Content-Type header from curl request
727 function guess_image_type($filename, $fromcurl=false) {
728 logger('Photo: guess_image_type: '.$filename . ($fromcurl?' from curl headers':''), LOGGER_DEBUG);
733 $h = explode("\n",$a->get_curl_headers());
735 list($k,$v) = array_map("trim", explode(":", trim($l), 2));
738 if (array_key_exists('Content-Type', $headers))
739 $type = $headers['Content-Type'];
742 // Guessing from extension? Isn't that... dangerous?
743 if (class_exists('Imagick') && file_exists($filename) && is_readable($filename)) {
745 * Well, this not much better,
746 * but at least it comes from the data inside the image,
747 * we won't be tricked by a manipulated extension
749 $image = new Imagick($filename);
750 $type = $image->getImageMimeType();
751 $image->setInterlaceScheme(Imagick::INTERLACE_PLANE);
753 $ext = pathinfo($filename, PATHINFO_EXTENSION);
754 $types = Photo::supportedTypes();
755 $type = "image/jpeg";
756 foreach ($types as $m => $e){
763 logger('Photo: guess_image_type: type='.$type, LOGGER_DEBUG);
769 * @brief Updates the avatar links in a contact only if needed
771 * @param string $avatar Link to avatar picture
772 * @param int $uid User id of contact owner
773 * @param int $cid Contact id
774 * @param bool $force force picture update
776 * @return array Returns array of the different avatar sizes
778 function update_contact_avatar($avatar, $uid, $cid, $force = false) {
780 $r = q("SELECT `avatar`, `photo`, `thumb`, `micro` FROM `contact` WHERE `id` = %d LIMIT 1", intval($cid));
781 if (!dbm::is_result($r)) {
784 $data = array($r[0]["photo"], $r[0]["thumb"], $r[0]["micro"]);
787 if (($r[0]["avatar"] != $avatar) OR $force) {
788 $photos = import_profile_photo($avatar, $uid, $cid, true);
791 q("UPDATE `contact` SET `avatar` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s', `avatar-date` = '%s' WHERE `id` = %d",
792 dbesc($avatar), dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]),
793 dbesc(datetime_convert()), intval($cid));
801 function import_profile_photo($photo, $uid, $cid, $quit_on_error = false) {
803 $r = q("SELECT `resource-id` FROM `photo` WHERE `uid` = %d AND `contact-id` = %d AND `scale` = 4 AND `album` = 'Contact Photos' LIMIT 1",
807 if (dbm::is_result($r) && strlen($r[0]['resource-id'])) {
808 $hash = $r[0]['resource-id'];
810 $hash = photo_new_resource();
813 $photo_failure = false;
815 $filename = basename($photo);
816 $img_str = fetch_url($photo, true);
818 if ($quit_on_error AND ($img_str == "")) {
822 $type = guess_image_type($photo, true);
823 $img = new Photo($img_str, $type);
824 if ($img->is_valid()) {
826 $img->scaleImageSquare(175);
828 $r = $img->store($uid, $cid, $hash, $filename, 'Contact Photos', 4);
831 $photo_failure = true;
833 $img->scaleImage(80);
835 $r = $img->store($uid, $cid, $hash, $filename, 'Contact Photos', 5);
838 $photo_failure = true;
840 $img->scaleImage(48);
842 $r = $img->store($uid, $cid, $hash, $filename, 'Contact Photos', 6);
845 $photo_failure = true;
848 $photo = App::get_baseurl() . '/photo/' . $hash . '-4.' . $img->getExt();
849 $thumb = App::get_baseurl() . '/photo/' . $hash . '-5.' . $img->getExt();
850 $micro = App::get_baseurl() . '/photo/' . $hash . '-6.' . $img->getExt();
852 $photo_failure = true;
855 if ($photo_failure AND $quit_on_error) {
859 if ($photo_failure) {
860 $photo = App::get_baseurl() . '/images/person-175.jpg';
861 $thumb = App::get_baseurl() . '/images/person-80.jpg';
862 $micro = App::get_baseurl() . '/images/person-48.jpg';
865 return(array($photo,$thumb,$micro));
869 function get_photo_info($url) {
872 $data = Cache::get($url);
874 if (is_null($data) OR !$data OR !is_array($data)) {
875 $img_str = fetch_url($url, true, $redirects, 4);
876 $filesize = strlen($img_str);
878 if (function_exists("getimagesizefromstring")) {
879 $data = getimagesizefromstring($img_str);
881 $tempfile = tempnam(get_temppath(), "cache");
884 $stamp1 = microtime(true);
885 file_put_contents($tempfile, $img_str);
886 $a->save_timestamp($stamp1, "file");
888 $data = getimagesize($tempfile);
893 $data["size"] = $filesize;
896 Cache::set($url, $data);
902 function scale_image($width, $height, $max) {
904 $dest_width = $dest_height = 0;
906 if ((!$width) || (!$height)) {
910 if ($width > $max && $height > $max) {
912 // very tall image (greater than 16:9)
913 // constrain the width - let the height float.
915 if ((($height * 9) / 16) > $width) {
917 $dest_height = intval(($height * $max) / $width);
918 } elseif ($width > $height) {
919 // else constrain both dimensions
921 $dest_height = intval(($height * $max) / $width);
923 $dest_width = intval(($width * $max) / $height);
929 $dest_height = intval(($height * $max) / $width);
931 if ($height > $max) {
933 // very tall image (greater than 16:9)
934 // but width is OK - don't do anything
936 if ((($height * 9) / 16) > $width) {
937 $dest_width = $width;
938 $dest_height = $height;
940 $dest_width = intval(($width * $max) / $height);
944 $dest_width = $width;
945 $dest_height = $height;
949 return array("width" => $dest_width, "height" => $dest_height);
952 function store_photo(App $a, $uid, $imagedata = "", $url = "") {
953 $r = q("SELECT `user`.`nickname`, `user`.`page-flags`, `contact`.`id` FROM `user` INNER JOIN `contact` on `user`.`uid` = `contact`.`uid`
954 WHERE `user`.`uid` = %d AND `user`.`blocked` = 0 AND `contact`.`self` = 1 LIMIT 1",
957 if (!dbm::is_result($r)) {
958 logger("Can't detect user data for uid ".$uid, LOGGER_DEBUG);
962 $page_owner_nick = $r[0]['nickname'];
965 /// $default_cid = $r[0]['id'];
966 /// $community_page = (($r[0]['page-flags'] == PAGE_COMMUNITY) ? true : false);
968 if ((strlen($imagedata) == 0) AND ($url == "")) {
969 logger("No image data and no url provided", LOGGER_DEBUG);
971 } elseif (strlen($imagedata) == 0) {
972 logger("Uploading picture from ".$url, LOGGER_DEBUG);
974 $stamp1 = microtime(true);
975 $imagedata = @file_get_contents($url);
976 $a->save_timestamp($stamp1, "file");
979 $maximagesize = get_config('system', 'maximagesize');
981 if (($maximagesize) && (strlen($imagedata) > $maximagesize)) {
982 logger("Image exceeds size limit of ".$maximagesize, LOGGER_DEBUG);
987 $r = q("select sum(octet_length(data)) as total from photo where uid = %d and scale = 0 and album != 'Contact Photos' ",
991 $limit = service_class_fetch($uid,'photo_upload_limit');
993 if (($limit !== false) && (($r[0]['total'] + strlen($imagedata)) > $limit)) {
994 logger("Image exceeds personal limit of uid ".$uid, LOGGER_DEBUG);
999 $tempfile = tempnam(get_temppath(), "cache");
1001 $stamp1 = microtime(true);
1002 file_put_contents($tempfile, $imagedata);
1003 $a->save_timestamp($stamp1, "file");
1005 $data = getimagesize($tempfile);
1007 if (!isset($data["mime"])) {
1009 logger("File is no picture", LOGGER_DEBUG);
1013 $ph = new Photo($imagedata, $data["mime"]);
1015 if (!$ph->is_valid()) {
1017 logger("Picture is no valid picture", LOGGER_DEBUG);
1021 $ph->orient($tempfile);
1024 $max_length = get_config('system', 'max_image_length');
1025 if (! $max_length) {
1026 $max_length = MAX_IMAGE_LENGTH;
1028 if ($max_length > 0) {
1029 $ph->scaleImage($max_length);
1032 $width = $ph->getWidth();
1033 $height = $ph->getHeight();
1035 $hash = photo_new_resource();
1039 // Pictures are always public by now
1040 //$defperm = '<'.$default_cid.'>';
1044 $r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 0, 0, $defperm);
1047 logger("Picture couldn't be stored", LOGGER_DEBUG);
1051 $image = array("page" => App::get_baseurl().'/photos/'.$page_owner_nick.'/image/'.$hash,
1052 "full" => App::get_baseurl()."/photo/{$hash}-0.".$ph->getExt());
1054 if ($width > 800 || $height > 800) {
1055 $image["large"] = App::get_baseurl()."/photo/{$hash}-0.".$ph->getExt();
1058 if ($width > 640 || $height > 640) {
1059 $ph->scaleImage(640);
1060 $r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 1, 0, $defperm);
1062 $image["medium"] = App::get_baseurl()."/photo/{$hash}-1.".$ph->getExt();
1066 if ($width > 320 || $height > 320) {
1067 $ph->scaleImage(320);
1068 $r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 2, 0, $defperm);
1070 $image["small"] = App::get_baseurl()."/photo/{$hash}-2.".$ph->getExt();
1074 if ($width > 160 AND $height > 160) {
1078 $min = $ph->getWidth();
1080 $x = ($min - 160) / 2;
1083 if ($ph->getHeight() < $min) {
1084 $min = $ph->getHeight();
1086 $y = ($min - 160) / 2;
1091 $ph->cropImage(160, $x, $y, $min, $min);
1093 $r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 3, 0, $defperm);
1095 $image["thumb"] = App::get_baseurl()."/photo/{$hash}-3.".$ph->getExt();
1099 // Set the full image as preview image. This will be overwritten, if the picture is larger than 640.
1100 $image["preview"] = $image["full"];
1102 // Deactivated, since that would result in a cropped preview, if the picture wasn't larger than 320
1103 //if (isset($image["thumb"]))
1104 // $image["preview"] = $image["thumb"];
1106 // Unsure, if this should be activated or deactivated
1107 //if (isset($image["small"]))
1108 // $image["preview"] = $image["small"];
1110 if (isset($image["medium"])) {
1111 $image["preview"] = $image["medium"];