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);
76 public function is_imagick() {
77 return $this->imagick;
81 * @brief Maps Mime types to Imagick formats
82 * @return arr With with image formats (mime type as key)
84 public function get_FormatsMap() {
86 'image/jpeg' => 'JPG',
93 private function load_data($data) {
94 if ($this->is_imagick()) {
95 $this->image = new Imagick();
97 $this->image->readImageBlob($data);
98 } catch (Exception $e) {
99 // Imagick couldn't use the data
104 * Setup the image to the format it will be saved to
106 $map = $this->get_FormatsMap();
107 $format = $map[$type];
108 $this->image->setFormat($format);
110 // Always coalesce, if it is not a multi-frame image it won't hurt anyway
111 $this->image = $this->image->coalesceImages();
114 * setup the compression here, so we'll do it only once
116 switch($this->getType()){
118 $quality = get_config('system', 'png_quality');
119 if ((! $quality) || ($quality > 9)) {
120 $quality = PNG_QUALITY;
123 * From http://www.imagemagick.org/script/command-line-options.php#quality:
125 * 'For the MNG and PNG image formats, the quality value sets
126 * the zlib compression level (quality / 10) and filter-type (quality % 10).
127 * The default PNG "quality" is 75, which means compression level 7 with adaptive PNG filtering,
128 * unless the image has a color map, in which case it means compression level 7 with no PNG filtering'
130 $quality = $quality * 10;
131 $this->image->setCompressionQuality($quality);
134 $quality = get_config('system', 'jpeg_quality');
135 if ((! $quality) || ($quality > 100)) {
136 $quality = JPEG_QUALITY;
138 $this->image->setCompressionQuality($quality);
141 // The 'width' and 'height' properties are only used by non-Imagick routines.
142 $this->width = $this->image->getImageWidth();
143 $this->height = $this->image->getImageHeight();
149 $this->valid = false;
150 $this->image = @imagecreatefromstring($data);
151 if ($this->image !== false) {
152 $this->width = imagesx($this->image);
153 $this->height = imagesy($this->image);
155 imagealphablending($this->image, false);
156 imagesavealpha($this->image, true);
164 public function is_valid() {
165 if ($this->is_imagick()) {
166 return ($this->image !== false);
171 public function getWidth() {
172 if (!$this->is_valid()) {
176 if ($this->is_imagick()) {
177 return $this->image->getImageWidth();
182 public function getHeight() {
183 if (!$this->is_valid()) {
187 if ($this->is_imagick()) {
188 return $this->image->getImageHeight();
190 return $this->height;
193 public function getImage() {
194 if (!$this->is_valid()) {
198 if ($this->is_imagick()) {
200 $this->image = $this->image->deconstructImages();
206 public function getType() {
207 if (!$this->is_valid()) {
214 public function getExt() {
215 if (!$this->is_valid()) {
219 return $this->types[$this->getType()];
222 public function scaleImage($max) {
223 if (!$this->is_valid()) {
227 $width = $this->getWidth();
228 $height = $this->getHeight();
230 $dest_width = $dest_height = 0;
232 if ((! $width)|| (! $height)) {
236 if ($width > $max && $height > $max) {
238 // very tall image (greater than 16:9)
239 // constrain the width - let the height float.
241 if ((($height * 9) / 16) > $width) {
243 $dest_height = intval(($height * $max) / $width);
244 } elseif ($width > $height) {
245 // else constrain both dimensions
247 $dest_height = intval(($height * $max) / $width);
249 $dest_width = intval(($width * $max) / $height);
255 $dest_height = intval(($height * $max) / $width);
257 if ($height > $max) {
259 // very tall image (greater than 16:9)
260 // but width is OK - don't do anything
262 if ((($height * 9) / 16) > $width) {
263 $dest_width = $width;
264 $dest_height = $height;
266 $dest_width = intval(($width * $max) / $height);
270 $dest_width = $width;
271 $dest_height = $height;
277 if ($this->is_imagick()) {
279 * If it is not animated, there will be only one iteration here,
280 * so don't bother checking
282 // Don't forget to go back to the first frame
283 $this->image->setFirstIterator();
286 // FIXME - implement horizantal bias for scaling as in followin GD functions
287 // to allow very tall images to be constrained only horizontally.
289 $this->image->scaleImage($dest_width, $dest_height);
290 } while ($this->image->nextImage());
292 // These may not be necessary any more
293 $this->width = $this->image->getImageWidth();
294 $this->height = $this->image->getImageHeight();
300 $dest = imagecreatetruecolor($dest_width, $dest_height);
301 imagealphablending($dest, false);
302 imagesavealpha($dest, true);
303 if ($this->type=='image/png') {
304 imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha
306 imagecopyresampled($dest, $this->image, 0, 0, 0, 0, $dest_width, $dest_height, $width, $height);
308 imagedestroy($this->image);
310 $this->image = $dest;
311 $this->width = imagesx($this->image);
312 $this->height = imagesy($this->image);
315 public function rotate($degrees) {
316 if (!$this->is_valid()) {
320 if ($this->is_imagick()) {
321 $this->image->setFirstIterator();
323 $this->image->rotateImage(new ImagickPixel(), -$degrees); // ImageMagick rotates in the opposite direction of imagerotate()
324 } while ($this->image->nextImage());
328 // if script dies at this point check memory_limit setting in php.ini
329 $this->image = imagerotate($this->image,$degrees,0);
330 $this->width = imagesx($this->image);
331 $this->height = imagesy($this->image);
334 public function flip($horiz = true, $vert = false) {
335 if (!$this->is_valid()) {
339 if ($this->is_imagick()) {
340 $this->image->setFirstIterator();
343 $this->image->flipImage();
346 $this->image->flopImage();
348 } while ($this->image->nextImage());
352 $w = imagesx($this->image);
353 $h = imagesy($this->image);
354 $flipped = imagecreate($w, $h);
356 for ($x = 0; $x < $w; $x++) {
357 imagecopy($flipped, $this->image, $x, 0, $w - $x - 1, 0, 1, $h);
361 for ($y = 0; $y < $h; $y++) {
362 imagecopy($flipped, $this->image, 0, $y, 0, $h - $y - 1, $w, 1);
365 $this->image = $flipped;
368 public function orient($filename) {
369 if ($this->is_imagick()) {
370 // based off comment on http://php.net/manual/en/imagick.getimageorientation.php
371 $orientation = $this->image->getImageOrientation();
372 switch ($orientation) {
373 case imagick::ORIENTATION_BOTTOMRIGHT:
374 $this->image->rotateimage("#000", 180);
376 case imagick::ORIENTATION_RIGHTTOP:
377 $this->image->rotateimage("#000", 90);
379 case imagick::ORIENTATION_LEFTBOTTOM:
380 $this->image->rotateimage("#000", -90);
384 $this->image->setImageOrientation(imagick::ORIENTATION_TOPLEFT);
387 // based off comment on http://php.net/manual/en/function.imagerotate.php
389 if (!$this->is_valid()) {
393 if ((!function_exists('exif_read_data')) || ($this->getType() !== 'image/jpeg')) {
397 $exif = @exif_read_data($filename,null,true);
402 $ort = $exif['IFD0']['Orientation'];
409 case 2: // horizontal flip
413 case 3: // 180 rotate left
417 case 4: // vertical flip
418 $this->flip(false, true);
421 case 5: // vertical flip + 90 rotate right
422 $this->flip(false, true);
426 case 6: // 90 rotate right
430 case 7: // horizontal flip + 90 rotate right
435 case 8: // 90 rotate left
440 // logger('exif: ' . print_r($exif,true));
447 public function scaleImageUp($min) {
448 if (!$this->is_valid()) {
453 $width = $this->getWidth();
454 $height = $this->getHeight();
456 $dest_width = $dest_height = 0;
458 if ((!$width)|| (!$height)) {
462 if ($width < $min && $height < $min) {
463 if ($width > $height) {
465 $dest_height = intval(($height * $min) / $width);
467 $dest_width = intval(($width * $min) / $height);
473 $dest_height = intval(($height * $min) / $width);
475 if ($height < $min) {
476 $dest_width = intval(($width * $min) / $height);
479 $dest_width = $width;
480 $dest_height = $height;
485 if ($this->is_imagick()) {
486 return $this->scaleImage($dest_width, $dest_height);
489 $dest = imagecreatetruecolor($dest_width, $dest_height);
490 imagealphablending($dest, false);
491 imagesavealpha($dest, true);
492 if ($this->type=='image/png') {
493 imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha
495 imagecopyresampled($dest, $this->image, 0, 0, 0, 0, $dest_width, $dest_height, $width, $height);
497 imagedestroy($this->image);
499 $this->image = $dest;
500 $this->width = imagesx($this->image);
501 $this->height = imagesy($this->image);
506 public function scaleImageSquare($dim) {
507 if (!$this->is_valid()) {
511 if ($this->is_imagick()) {
512 $this->image->setFirstIterator();
514 $this->image->scaleImage($dim, $dim);
515 } while ($this->image->nextImage());
519 $dest = imagecreatetruecolor($dim, $dim);
520 imagealphablending($dest, false);
521 imagesavealpha($dest, true);
522 if ($this->type=='image/png') {
523 imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha
525 imagecopyresampled($dest, $this->image, 0, 0, 0, 0, $dim, $dim, $this->width, $this->height);
527 imagedestroy($this->image);
529 $this->image = $dest;
530 $this->width = imagesx($this->image);
531 $this->height = imagesy($this->image);
535 public function cropImage($max, $x, $y, $w, $h) {
536 if (!$this->is_valid()) {
540 if ($this->is_imagick()) {
541 $this->image->setFirstIterator();
543 $this->image->cropImage($w, $h, $x, $y);
545 * We need to remove the canva,
546 * or the image is not resized to the crop:
547 * http://php.net/manual/en/imagick.cropimage.php#97232
549 $this->image->setImagePage(0, 0, 0, 0);
550 } while ($this->image->nextImage());
551 return $this->scaleImage($max);
554 $dest = imagecreatetruecolor($max, $max);
555 imagealphablending($dest, false);
556 imagesavealpha($dest, true);
557 if ($this->type=='image/png') {
558 imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha
560 imagecopyresampled($dest, $this->image, 0, 0, $x, $y, $max, $max, $w, $h);
562 imagedestroy($this->image);
564 $this->image = $dest;
565 $this->width = imagesx($this->image);
566 $this->height = imagesy($this->image);
569 public function saveImage($path) {
570 if (!$this->is_valid()) {
574 $string = $this->imageString();
578 $stamp1 = microtime(true);
579 file_put_contents($path, $string);
580 $a->save_timestamp($stamp1, "file");
583 public function imageString() {
584 if (!$this->is_valid()) {
588 if ($this->is_imagick()) {
590 $this->image = $this->image->deconstructImages();
591 $string = $this->image->getImagesBlob();
599 // Enable interlacing
600 imageinterlace($this->image, true);
602 switch($this->getType()){
604 $quality = get_config('system', 'png_quality');
605 if ((!$quality) || ($quality > 9)) {
606 $quality = PNG_QUALITY;
608 imagepng($this->image, null, $quality);
611 $quality = get_config('system', 'jpeg_quality');
612 if ((!$quality) || ($quality > 100)) {
613 $quality = JPEG_QUALITY;
615 imagejpeg($this->image, null, $quality);
617 $string = ob_get_contents();
625 public function store($uid, $cid, $rid, $filename, $album, $scale, $profile = 0, $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '', $desc = '') {
627 $r = q("SELECT `guid` FROM `photo` WHERE `resource-id` = '%s' AND `guid` != '' LIMIT 1",
630 if (dbm::is_result($r)) {
631 $guid = $r[0]['guid'];
636 $x = q("SELECT `id` FROM `photo` WHERE `resource-id` = '%s' AND `uid` = %d AND `contact-id` = %d AND `scale` = %d LIMIT 1",
642 if (dbm::is_result($x)) {
643 $r = q("UPDATE `photo`
647 `resource-id` = '%s',
670 dbesc(datetime_convert()),
671 dbesc(datetime_convert()),
672 dbesc(basename($filename)),
673 dbesc($this->getType()),
675 intval($this->getHeight()),
676 intval($this->getWidth()),
677 dbesc(strlen($this->imageString())),
678 dbesc($this->imageString()),
689 $r = q("INSERT INTO `photo`
690 (`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`)
691 VALUES (%d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, '%s', %d, %d, '%s', '%s', '%s', '%s', '%s')",
696 dbesc(datetime_convert()),
697 dbesc(datetime_convert()),
698 dbesc(basename($filename)),
699 dbesc($this->getType()),
701 intval($this->getHeight()),
702 intval($this->getWidth()),
703 dbesc(strlen($this->imageString())),
704 dbesc($this->imageString()),
721 * Guess image mimetype from filename or from Content-Type header
723 * @arg $filename string Image filename
724 * @arg $fromcurl boolean Check Content-Type header from curl request
726 function guess_image_type($filename, $fromcurl=false) {
727 logger('Photo: guess_image_type: '.$filename . ($fromcurl?' from curl headers':''), LOGGER_DEBUG);
732 $h = explode("\n",$a->get_curl_headers());
734 list($k,$v) = array_map("trim", explode(":", trim($l), 2));
737 if (array_key_exists('Content-Type', $headers))
738 $type = $headers['Content-Type'];
741 // Guessing from extension? Isn't that... dangerous?
742 if (class_exists('Imagick') && file_exists($filename) && is_readable($filename)) {
744 * Well, this not much better,
745 * but at least it comes from the data inside the image,
746 * we won't be tricked by a manipulated extension
748 $image = new Imagick($filename);
749 $type = $image->getImageMimeType();
750 $image->setInterlaceScheme(Imagick::INTERLACE_PLANE);
752 $ext = pathinfo($filename, PATHINFO_EXTENSION);
753 $types = Photo::supportedTypes();
754 $type = "image/jpeg";
755 foreach ($types as $m => $e){
762 logger('Photo: guess_image_type: type='.$type, LOGGER_DEBUG);
768 * @brief Updates the avatar links in a contact only if needed
770 * @param string $avatar Link to avatar picture
771 * @param int $uid User id of contact owner
772 * @param int $cid Contact id
773 * @param bool $force force picture update
775 * @return array Returns array of the different avatar sizes
777 function update_contact_avatar($avatar, $uid, $cid, $force = false) {
779 $r = q("SELECT `avatar`, `photo`, `thumb`, `micro` FROM `contact` WHERE `id` = %d LIMIT 1", intval($cid));
780 if (!dbm::is_result($r)) {
783 $data = array($r[0]["photo"], $r[0]["thumb"], $r[0]["micro"]);
786 if (($r[0]["avatar"] != $avatar) OR $force) {
787 $photos = import_profile_photo($avatar, $uid, $cid, true);
790 q("UPDATE `contact` SET `avatar` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s', `avatar-date` = '%s' WHERE `id` = %d",
791 dbesc($avatar), dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]),
792 dbesc(datetime_convert()), intval($cid));
800 function import_profile_photo($photo, $uid, $cid, $quit_on_error = false) {
802 $r = q("SELECT `resource-id` FROM `photo` WHERE `uid` = %d AND `contact-id` = %d AND `scale` = 4 AND `album` = 'Contact Photos' LIMIT 1",
806 if (dbm::is_result($r) && strlen($r[0]['resource-id'])) {
807 $hash = $r[0]['resource-id'];
809 $hash = photo_new_resource();
812 $photo_failure = false;
814 $filename = basename($photo);
815 $img_str = fetch_url($photo, true);
817 if ($quit_on_error AND ($img_str == "")) {
821 $type = guess_image_type($photo, true);
822 $img = new Photo($img_str, $type);
823 if ($img->is_valid()) {
825 $img->scaleImageSquare(175);
827 $r = $img->store($uid, $cid, $hash, $filename, 'Contact Photos', 4);
830 $photo_failure = true;
832 $img->scaleImage(80);
834 $r = $img->store($uid, $cid, $hash, $filename, 'Contact Photos', 5);
837 $photo_failure = true;
839 $img->scaleImage(48);
841 $r = $img->store($uid, $cid, $hash, $filename, 'Contact Photos', 6);
844 $photo_failure = true;
847 $photo = App::get_baseurl() . '/photo/' . $hash . '-4.' . $img->getExt();
848 $thumb = App::get_baseurl() . '/photo/' . $hash . '-5.' . $img->getExt();
849 $micro = App::get_baseurl() . '/photo/' . $hash . '-6.' . $img->getExt();
851 $photo_failure = true;
854 if ($photo_failure AND $quit_on_error) {
858 if ($photo_failure) {
859 $photo = App::get_baseurl() . '/images/person-175.jpg';
860 $thumb = App::get_baseurl() . '/images/person-80.jpg';
861 $micro = App::get_baseurl() . '/images/person-48.jpg';
864 return(array($photo,$thumb,$micro));
868 function get_photo_info($url) {
871 $data = Cache::get($url);
873 if (is_null($data) OR !$data OR !is_array($data)) {
874 $img_str = fetch_url($url, true, $redirects, 4);
875 $filesize = strlen($img_str);
877 if (function_exists("getimagesizefromstring")) {
878 $data = getimagesizefromstring($img_str);
880 $tempfile = tempnam(get_temppath(), "cache");
883 $stamp1 = microtime(true);
884 file_put_contents($tempfile, $img_str);
885 $a->save_timestamp($stamp1, "file");
887 $data = getimagesize($tempfile);
892 $data["size"] = $filesize;
895 Cache::set($url, $data);
901 function scale_image($width, $height, $max) {
903 $dest_width = $dest_height = 0;
905 if ((!$width) || (!$height)) {
909 if ($width > $max && $height > $max) {
911 // very tall image (greater than 16:9)
912 // constrain the width - let the height float.
914 if ((($height * 9) / 16) > $width) {
916 $dest_height = intval(($height * $max) / $width);
917 } elseif ($width > $height) {
918 // else constrain both dimensions
920 $dest_height = intval(($height * $max) / $width);
922 $dest_width = intval(($width * $max) / $height);
928 $dest_height = intval(($height * $max) / $width);
930 if ($height > $max) {
932 // very tall image (greater than 16:9)
933 // but width is OK - don't do anything
935 if ((($height * 9) / 16) > $width) {
936 $dest_width = $width;
937 $dest_height = $height;
939 $dest_width = intval(($width * $max) / $height);
943 $dest_width = $width;
944 $dest_height = $height;
948 return array("width" => $dest_width, "height" => $dest_height);
951 function store_photo(App $a, $uid, $imagedata = "", $url = "") {
952 $r = q("SELECT `user`.`nickname`, `user`.`page-flags`, `contact`.`id` FROM `user` INNER JOIN `contact` on `user`.`uid` = `contact`.`uid`
953 WHERE `user`.`uid` = %d AND `user`.`blocked` = 0 AND `contact`.`self` = 1 LIMIT 1",
956 if (!dbm::is_result($r)) {
957 logger("Can't detect user data for uid ".$uid, LOGGER_DEBUG);
961 $page_owner_nick = $r[0]['nickname'];
964 /// $default_cid = $r[0]['id'];
965 /// $community_page = (($r[0]['page-flags'] == PAGE_COMMUNITY) ? true : false);
967 if ((strlen($imagedata) == 0) AND ($url == "")) {
968 logger("No image data and no url provided", LOGGER_DEBUG);
970 } elseif (strlen($imagedata) == 0) {
971 logger("Uploading picture from ".$url, LOGGER_DEBUG);
973 $stamp1 = microtime(true);
974 $imagedata = @file_get_contents($url);
975 $a->save_timestamp($stamp1, "file");
978 $maximagesize = get_config('system', 'maximagesize');
980 if (($maximagesize) && (strlen($imagedata) > $maximagesize)) {
981 logger("Image exceeds size limit of ".$maximagesize, LOGGER_DEBUG);
986 $r = q("select sum(octet_length(data)) as total from photo where uid = %d and scale = 0 and album != 'Contact Photos' ",
990 $limit = service_class_fetch($uid,'photo_upload_limit');
992 if (($limit !== false) && (($r[0]['total'] + strlen($imagedata)) > $limit)) {
993 logger("Image exceeds personal limit of uid ".$uid, LOGGER_DEBUG);
998 $tempfile = tempnam(get_temppath(), "cache");
1000 $stamp1 = microtime(true);
1001 file_put_contents($tempfile, $imagedata);
1002 $a->save_timestamp($stamp1, "file");
1004 $data = getimagesize($tempfile);
1006 if (!isset($data["mime"])) {
1008 logger("File is no picture", LOGGER_DEBUG);
1012 $ph = new Photo($imagedata, $data["mime"]);
1014 if (!$ph->is_valid()) {
1016 logger("Picture is no valid picture", LOGGER_DEBUG);
1020 $ph->orient($tempfile);
1023 $max_length = get_config('system', 'max_image_length');
1024 if (! $max_length) {
1025 $max_length = MAX_IMAGE_LENGTH;
1027 if ($max_length > 0) {
1028 $ph->scaleImage($max_length);
1031 $width = $ph->getWidth();
1032 $height = $ph->getHeight();
1034 $hash = photo_new_resource();
1038 // Pictures are always public by now
1039 //$defperm = '<'.$default_cid.'>';
1043 $r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 0, 0, $defperm);
1046 logger("Picture couldn't be stored", LOGGER_DEBUG);
1050 $image = array("page" => App::get_baseurl().'/photos/'.$page_owner_nick.'/image/'.$hash,
1051 "full" => App::get_baseurl()."/photo/{$hash}-0.".$ph->getExt());
1053 if ($width > 800 || $height > 800) {
1054 $image["large"] = App::get_baseurl()."/photo/{$hash}-0.".$ph->getExt();
1057 if ($width > 640 || $height > 640) {
1058 $ph->scaleImage(640);
1059 $r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 1, 0, $defperm);
1061 $image["medium"] = App::get_baseurl()."/photo/{$hash}-1.".$ph->getExt();
1065 if ($width > 320 || $height > 320) {
1066 $ph->scaleImage(320);
1067 $r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 2, 0, $defperm);
1069 $image["small"] = App::get_baseurl()."/photo/{$hash}-2.".$ph->getExt();
1073 if ($width > 160 AND $height > 160) {
1077 $min = $ph->getWidth();
1079 $x = ($min - 160) / 2;
1082 if ($ph->getHeight() < $min) {
1083 $min = $ph->getHeight();
1085 $y = ($min - 160) / 2;
1090 $ph->cropImage(160, $x, $y, $min, $min);
1092 $r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 3, 0, $defperm);
1094 $image["thumb"] = App::get_baseurl()."/photo/{$hash}-3.".$ph->getExt();
1098 // Set the full image as preview image. This will be overwritten, if the picture is larger than 640.
1099 $image["preview"] = $image["full"];
1101 // Deactivated, since that would result in a cropped preview, if the picture wasn't larger than 320
1102 //if (isset($image["thumb"]))
1103 // $image["preview"] = $image["thumb"];
1105 // Unsure, if this should be activated or deactivated
1106 //if (isset($image["small"]))
1107 // $image["preview"] = $image["small"];
1109 if (isset($image["medium"])) {
1110 $image["preview"] = $image["medium"];