3 * @file include/Photo.php
4 * @brief This file contains the Photo class for image processing
9 require_once("include/photos.php");
16 * Put back gd stuff, not everybody have Imagick
26 * @brief supported mimetypes and corresponding file extensions
28 static function supportedTypes() {
29 if (class_exists('Imagick')) {
31 // Imagick::queryFormats won't help us a lot there...
32 // At least, not yet, other parts of friendica uses this array
34 'image/jpeg' => 'jpg',
40 $t['image/jpeg'] ='jpg';
41 if (imagetypes() & IMG_PNG) {
42 $t['image/png'] = 'png';
49 public function __construct($data, $type=null) {
50 $this->imagick = class_exists('Imagick');
51 $this->types = $this->supportedTypes();
52 if (!array_key_exists($type, $this->types)){
57 if ($this->is_imagick() && $this->load_data($data)) {
60 // Failed to load with Imagick, fallback
61 $this->imagick = false;
63 return $this->load_data($data);
66 public function __destruct() {
68 if ($this->is_imagick()) {
69 $this->image->clear();
70 $this->image->destroy();
73 if (is_resource($this->image)) {
74 imagedestroy($this->image);
79 public function is_imagick() {
80 return $this->imagick;
84 * @brief Maps Mime types to Imagick formats
85 * @return arr With with image formats (mime type as key)
87 public function get_FormatsMap() {
89 'image/jpeg' => 'JPG',
96 private function load_data($data) {
97 if ($this->is_imagick()) {
98 $this->image = new Imagick();
100 $this->image->readImageBlob($data);
101 } catch (Exception $e) {
102 // Imagick couldn't use the data
107 * Setup the image to the format it will be saved to
109 $map = $this->get_FormatsMap();
110 $format = $map[$type];
111 $this->image->setFormat($format);
113 // Always coalesce, if it is not a multi-frame image it won't hurt anyway
114 $this->image = $this->image->coalesceImages();
117 * setup the compression here, so we'll do it only once
119 switch($this->getType()){
121 $quality = get_config('system', 'png_quality');
122 if ((! $quality) || ($quality > 9)) {
123 $quality = PNG_QUALITY;
126 * From http://www.imagemagick.org/script/command-line-options.php#quality:
128 * 'For the MNG and PNG image formats, the quality value sets
129 * the zlib compression level (quality / 10) and filter-type (quality % 10).
130 * The default PNG "quality" is 75, which means compression level 7 with adaptive PNG filtering,
131 * unless the image has a color map, in which case it means compression level 7 with no PNG filtering'
133 $quality = $quality * 10;
134 $this->image->setCompressionQuality($quality);
137 $quality = get_config('system', 'jpeg_quality');
138 if ((! $quality) || ($quality > 100)) {
139 $quality = JPEG_QUALITY;
141 $this->image->setCompressionQuality($quality);
144 // The 'width' and 'height' properties are only used by non-Imagick routines.
145 $this->width = $this->image->getImageWidth();
146 $this->height = $this->image->getImageHeight();
152 $this->valid = false;
153 $this->image = @imagecreatefromstring($data);
154 if ($this->image !== false) {
155 $this->width = imagesx($this->image);
156 $this->height = imagesy($this->image);
158 imagealphablending($this->image, false);
159 imagesavealpha($this->image, true);
167 public function is_valid() {
168 if ($this->is_imagick()) {
169 return ($this->image !== false);
174 public function getWidth() {
175 if (!$this->is_valid()) {
179 if ($this->is_imagick()) {
180 return $this->image->getImageWidth();
185 public function getHeight() {
186 if (!$this->is_valid()) {
190 if ($this->is_imagick()) {
191 return $this->image->getImageHeight();
193 return $this->height;
196 public function getImage() {
197 if (!$this->is_valid()) {
201 if ($this->is_imagick()) {
203 $this->image = $this->image->deconstructImages();
209 public function getType() {
210 if (!$this->is_valid()) {
217 public function getExt() {
218 if (!$this->is_valid()) {
222 return $this->types[$this->getType()];
225 public function scaleImage($max) {
226 if (!$this->is_valid()) {
230 $width = $this->getWidth();
231 $height = $this->getHeight();
233 $dest_width = $dest_height = 0;
235 if ((! $width)|| (! $height)) {
239 if ($width > $max && $height > $max) {
241 // very tall image (greater than 16:9)
242 // constrain the width - let the height float.
244 if ((($height * 9) / 16) > $width) {
246 $dest_height = intval(($height * $max) / $width);
247 } elseif ($width > $height) {
248 // else constrain both dimensions
250 $dest_height = intval(($height * $max) / $width);
252 $dest_width = intval(($width * $max) / $height);
258 $dest_height = intval(($height * $max) / $width);
260 if ($height > $max) {
262 // very tall image (greater than 16:9)
263 // but width is OK - don't do anything
265 if ((($height * 9) / 16) > $width) {
266 $dest_width = $width;
267 $dest_height = $height;
269 $dest_width = intval(($width * $max) / $height);
273 $dest_width = $width;
274 $dest_height = $height;
280 if ($this->is_imagick()) {
282 * If it is not animated, there will be only one iteration here,
283 * so don't bother checking
285 // Don't forget to go back to the first frame
286 $this->image->setFirstIterator();
289 // FIXME - implement horizantal bias for scaling as in followin GD functions
290 // to allow very tall images to be constrained only horizontally.
292 $this->image->scaleImage($dest_width, $dest_height);
293 } while ($this->image->nextImage());
295 // These may not be necessary any more
296 $this->width = $this->image->getImageWidth();
297 $this->height = $this->image->getImageHeight();
303 $dest = imagecreatetruecolor($dest_width, $dest_height);
304 imagealphablending($dest, false);
305 imagesavealpha($dest, true);
306 if ($this->type=='image/png') {
307 imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha
309 imagecopyresampled($dest, $this->image, 0, 0, 0, 0, $dest_width, $dest_height, $width, $height);
311 imagedestroy($this->image);
313 $this->image = $dest;
314 $this->width = imagesx($this->image);
315 $this->height = imagesy($this->image);
318 public function rotate($degrees) {
319 if (!$this->is_valid()) {
323 if ($this->is_imagick()) {
324 $this->image->setFirstIterator();
326 $this->image->rotateImage(new ImagickPixel(), -$degrees); // ImageMagick rotates in the opposite direction of imagerotate()
327 } while ($this->image->nextImage());
331 // if script dies at this point check memory_limit setting in php.ini
332 $this->image = imagerotate($this->image,$degrees,0);
333 $this->width = imagesx($this->image);
334 $this->height = imagesy($this->image);
337 public function flip($horiz = true, $vert = false) {
338 if (!$this->is_valid()) {
342 if ($this->is_imagick()) {
343 $this->image->setFirstIterator();
346 $this->image->flipImage();
349 $this->image->flopImage();
351 } while ($this->image->nextImage());
355 $w = imagesx($this->image);
356 $h = imagesy($this->image);
357 $flipped = imagecreate($w, $h);
359 for ($x = 0; $x < $w; $x++) {
360 imagecopy($flipped, $this->image, $x, 0, $w - $x - 1, 0, 1, $h);
364 for ($y = 0; $y < $h; $y++) {
365 imagecopy($flipped, $this->image, 0, $y, 0, $h - $y - 1, $w, 1);
368 $this->image = $flipped;
371 public function orient($filename) {
372 if ($this->is_imagick()) {
373 // based off comment on http://php.net/manual/en/imagick.getimageorientation.php
374 $orientation = $this->image->getImageOrientation();
375 switch ($orientation) {
376 case imagick::ORIENTATION_BOTTOMRIGHT:
377 $this->image->rotateimage("#000", 180);
379 case imagick::ORIENTATION_RIGHTTOP:
380 $this->image->rotateimage("#000", 90);
382 case imagick::ORIENTATION_LEFTBOTTOM:
383 $this->image->rotateimage("#000", -90);
387 $this->image->setImageOrientation(imagick::ORIENTATION_TOPLEFT);
390 // based off comment on http://php.net/manual/en/function.imagerotate.php
392 if (!$this->is_valid()) {
396 if ((!function_exists('exif_read_data')) || ($this->getType() !== 'image/jpeg')) {
400 $exif = @exif_read_data($filename,null,true);
405 $ort = $exif['IFD0']['Orientation'];
412 case 2: // horizontal flip
416 case 3: // 180 rotate left
420 case 4: // vertical flip
421 $this->flip(false, true);
424 case 5: // vertical flip + 90 rotate right
425 $this->flip(false, true);
429 case 6: // 90 rotate right
433 case 7: // horizontal flip + 90 rotate right
438 case 8: // 90 rotate left
443 // logger('exif: ' . print_r($exif,true));
450 public function scaleImageUp($min) {
451 if (!$this->is_valid()) {
456 $width = $this->getWidth();
457 $height = $this->getHeight();
459 $dest_width = $dest_height = 0;
461 if ((!$width)|| (!$height)) {
465 if ($width < $min && $height < $min) {
466 if ($width > $height) {
468 $dest_height = intval(($height * $min) / $width);
470 $dest_width = intval(($width * $min) / $height);
476 $dest_height = intval(($height * $min) / $width);
478 if ($height < $min) {
479 $dest_width = intval(($width * $min) / $height);
482 $dest_width = $width;
483 $dest_height = $height;
488 if ($this->is_imagick()) {
489 return $this->scaleImage($dest_width, $dest_height);
492 $dest = imagecreatetruecolor($dest_width, $dest_height);
493 imagealphablending($dest, false);
494 imagesavealpha($dest, true);
495 if ($this->type=='image/png') {
496 imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha
498 imagecopyresampled($dest, $this->image, 0, 0, 0, 0, $dest_width, $dest_height, $width, $height);
500 imagedestroy($this->image);
502 $this->image = $dest;
503 $this->width = imagesx($this->image);
504 $this->height = imagesy($this->image);
509 public function scaleImageSquare($dim) {
510 if (!$this->is_valid()) {
514 if ($this->is_imagick()) {
515 $this->image->setFirstIterator();
517 $this->image->scaleImage($dim, $dim);
518 } while ($this->image->nextImage());
522 $dest = imagecreatetruecolor($dim, $dim);
523 imagealphablending($dest, false);
524 imagesavealpha($dest, true);
525 if ($this->type=='image/png') {
526 imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha
528 imagecopyresampled($dest, $this->image, 0, 0, 0, 0, $dim, $dim, $this->width, $this->height);
530 imagedestroy($this->image);
532 $this->image = $dest;
533 $this->width = imagesx($this->image);
534 $this->height = imagesy($this->image);
538 public function cropImage($max, $x, $y, $w, $h) {
539 if (!$this->is_valid()) {
543 if ($this->is_imagick()) {
544 $this->image->setFirstIterator();
546 $this->image->cropImage($w, $h, $x, $y);
548 * We need to remove the canva,
549 * or the image is not resized to the crop:
550 * http://php.net/manual/en/imagick.cropimage.php#97232
552 $this->image->setImagePage(0, 0, 0, 0);
553 } while ($this->image->nextImage());
554 return $this->scaleImage($max);
557 $dest = imagecreatetruecolor($max, $max);
558 imagealphablending($dest, false);
559 imagesavealpha($dest, true);
560 if ($this->type=='image/png') {
561 imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha
563 imagecopyresampled($dest, $this->image, 0, 0, $x, $y, $max, $max, $w, $h);
565 imagedestroy($this->image);
567 $this->image = $dest;
568 $this->width = imagesx($this->image);
569 $this->height = imagesy($this->image);
572 public function saveImage($path) {
573 if (!$this->is_valid()) {
577 $string = $this->imageString();
581 $stamp1 = microtime(true);
582 file_put_contents($path, $string);
583 $a->save_timestamp($stamp1, "file");
586 public function imageString() {
587 if (!$this->is_valid()) {
591 if ($this->is_imagick()) {
593 $this->image = $this->image->deconstructImages();
594 $string = $this->image->getImagesBlob();
602 // Enable interlacing
603 imageinterlace($this->image, true);
605 switch($this->getType()){
607 $quality = get_config('system', 'png_quality');
608 if ((!$quality) || ($quality > 9)) {
609 $quality = PNG_QUALITY;
611 imagepng($this->image, null, $quality);
614 $quality = get_config('system', 'jpeg_quality');
615 if ((!$quality) || ($quality > 100)) {
616 $quality = JPEG_QUALITY;
618 imagejpeg($this->image, null, $quality);
620 $string = ob_get_contents();
628 public function store($uid, $cid, $rid, $filename, $album, $scale, $profile = 0, $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '', $desc = '') {
630 $r = q("SELECT `guid` FROM `photo` WHERE `resource-id` = '%s' AND `guid` != '' LIMIT 1",
633 if (dbm::is_result($r)) {
634 $guid = $r[0]['guid'];
639 $x = q("SELECT `id` FROM `photo` WHERE `resource-id` = '%s' AND `uid` = %d AND `contact-id` = %d AND `scale` = %d LIMIT 1",
645 if (dbm::is_result($x)) {
646 $r = q("UPDATE `photo`
650 `resource-id` = '%s',
673 dbesc(datetime_convert()),
674 dbesc(datetime_convert()),
675 dbesc(basename($filename)),
676 dbesc($this->getType()),
678 intval($this->getHeight()),
679 intval($this->getWidth()),
680 dbesc(strlen($this->imageString())),
681 dbesc($this->imageString()),
692 $r = q("INSERT INTO `photo`
693 (`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`)
694 VALUES (%d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, '%s', %d, %d, '%s', '%s', '%s', '%s', '%s')",
699 dbesc(datetime_convert()),
700 dbesc(datetime_convert()),
701 dbesc(basename($filename)),
702 dbesc($this->getType()),
704 intval($this->getHeight()),
705 intval($this->getWidth()),
706 dbesc(strlen($this->imageString())),
707 dbesc($this->imageString()),
724 * Guess image mimetype from filename or from Content-Type header
726 * @arg $filename string Image filename
727 * @arg $fromcurl boolean Check Content-Type header from curl request
729 function guess_image_type($filename, $fromcurl=false) {
730 logger('Photo: guess_image_type: '.$filename . ($fromcurl?' from curl headers':''), LOGGER_DEBUG);
735 $h = explode("\n",$a->get_curl_headers());
737 list($k,$v) = array_map("trim", explode(":", trim($l), 2));
740 if (array_key_exists('Content-Type', $headers))
741 $type = $headers['Content-Type'];
744 // Guessing from extension? Isn't that... dangerous?
745 if (class_exists('Imagick') && file_exists($filename) && is_readable($filename)) {
747 * Well, this not much better,
748 * but at least it comes from the data inside the image,
749 * we won't be tricked by a manipulated extension
751 $image = new Imagick($filename);
752 $type = $image->getImageMimeType();
753 $image->setInterlaceScheme(Imagick::INTERLACE_PLANE);
755 $ext = pathinfo($filename, PATHINFO_EXTENSION);
756 $types = Photo::supportedTypes();
757 $type = "image/jpeg";
758 foreach ($types as $m => $e){
765 logger('Photo: guess_image_type: type='.$type, LOGGER_DEBUG);
771 * @brief Updates the avatar links in a contact only if needed
773 * @param string $avatar Link to avatar picture
774 * @param int $uid User id of contact owner
775 * @param int $cid Contact id
776 * @param bool $force force picture update
778 * @return array Returns array of the different avatar sizes
780 function update_contact_avatar($avatar, $uid, $cid, $force = false) {
782 $r = q("SELECT `avatar`, `photo`, `thumb`, `micro` FROM `contact` WHERE `id` = %d LIMIT 1", intval($cid));
783 if (!dbm::is_result($r)) {
786 $data = array($r[0]["photo"], $r[0]["thumb"], $r[0]["micro"]);
789 if (($r[0]["avatar"] != $avatar) OR $force) {
790 $photos = import_profile_photo($avatar, $uid, $cid, true);
793 q("UPDATE `contact` SET `avatar` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s', `avatar-date` = '%s' WHERE `id` = %d",
794 dbesc($avatar), dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]),
795 dbesc(datetime_convert()), intval($cid));
803 function import_profile_photo($photo, $uid, $cid, $quit_on_error = false) {
805 $r = q("SELECT `resource-id` FROM `photo` WHERE `uid` = %d AND `contact-id` = %d AND `scale` = 4 AND `album` = 'Contact Photos' LIMIT 1",
809 if (dbm::is_result($r) && strlen($r[0]['resource-id'])) {
810 $hash = $r[0]['resource-id'];
812 $hash = photo_new_resource();
815 $photo_failure = false;
817 $filename = basename($photo);
818 $img_str = fetch_url($photo, true);
820 if ($quit_on_error AND ($img_str == "")) {
824 $type = guess_image_type($photo, true);
825 $img = new Photo($img_str, $type);
826 if ($img->is_valid()) {
828 $img->scaleImageSquare(175);
830 $r = $img->store($uid, $cid, $hash, $filename, 'Contact Photos', 4);
833 $photo_failure = true;
835 $img->scaleImage(80);
837 $r = $img->store($uid, $cid, $hash, $filename, 'Contact Photos', 5);
840 $photo_failure = true;
842 $img->scaleImage(48);
844 $r = $img->store($uid, $cid, $hash, $filename, 'Contact Photos', 6);
847 $photo_failure = true;
850 $photo = App::get_baseurl() . '/photo/' . $hash . '-4.' . $img->getExt();
851 $thumb = App::get_baseurl() . '/photo/' . $hash . '-5.' . $img->getExt();
852 $micro = App::get_baseurl() . '/photo/' . $hash . '-6.' . $img->getExt();
854 $photo_failure = true;
857 if ($photo_failure AND $quit_on_error) {
861 if ($photo_failure) {
862 $photo = App::get_baseurl() . '/images/person-175.jpg';
863 $thumb = App::get_baseurl() . '/images/person-80.jpg';
864 $micro = App::get_baseurl() . '/images/person-48.jpg';
867 return(array($photo,$thumb,$micro));
871 function get_photo_info($url) {
874 $data = Cache::get($url);
876 if (is_null($data) OR !$data OR !is_array($data)) {
877 $img_str = fetch_url($url, true, $redirects, 4);
878 $filesize = strlen($img_str);
880 if (function_exists("getimagesizefromstring")) {
881 $data = getimagesizefromstring($img_str);
883 $tempfile = tempnam(get_temppath(), "cache");
886 $stamp1 = microtime(true);
887 file_put_contents($tempfile, $img_str);
888 $a->save_timestamp($stamp1, "file");
890 $data = getimagesize($tempfile);
895 $data["size"] = $filesize;
898 Cache::set($url, $data);
904 function scale_image($width, $height, $max) {
906 $dest_width = $dest_height = 0;
908 if ((!$width) || (!$height)) {
912 if ($width > $max && $height > $max) {
914 // very tall image (greater than 16:9)
915 // constrain the width - let the height float.
917 if ((($height * 9) / 16) > $width) {
919 $dest_height = intval(($height * $max) / $width);
920 } elseif ($width > $height) {
921 // else constrain both dimensions
923 $dest_height = intval(($height * $max) / $width);
925 $dest_width = intval(($width * $max) / $height);
931 $dest_height = intval(($height * $max) / $width);
933 if ($height > $max) {
935 // very tall image (greater than 16:9)
936 // but width is OK - don't do anything
938 if ((($height * 9) / 16) > $width) {
939 $dest_width = $width;
940 $dest_height = $height;
942 $dest_width = intval(($width * $max) / $height);
946 $dest_width = $width;
947 $dest_height = $height;
951 return array("width" => $dest_width, "height" => $dest_height);
954 function store_photo(App $a, $uid, $imagedata = "", $url = "") {
955 $r = q("SELECT `user`.`nickname`, `user`.`page-flags`, `contact`.`id` FROM `user` INNER JOIN `contact` on `user`.`uid` = `contact`.`uid`
956 WHERE `user`.`uid` = %d AND `user`.`blocked` = 0 AND `contact`.`self` = 1 LIMIT 1",
959 if (!dbm::is_result($r)) {
960 logger("Can't detect user data for uid ".$uid, LOGGER_DEBUG);
964 $page_owner_nick = $r[0]['nickname'];
967 /// $default_cid = $r[0]['id'];
968 /// $community_page = (($r[0]['page-flags'] == PAGE_COMMUNITY) ? true : false);
970 if ((strlen($imagedata) == 0) AND ($url == "")) {
971 logger("No image data and no url provided", LOGGER_DEBUG);
973 } elseif (strlen($imagedata) == 0) {
974 logger("Uploading picture from ".$url, LOGGER_DEBUG);
976 $stamp1 = microtime(true);
977 $imagedata = @file_get_contents($url);
978 $a->save_timestamp($stamp1, "file");
981 $maximagesize = get_config('system', 'maximagesize');
983 if (($maximagesize) && (strlen($imagedata) > $maximagesize)) {
984 logger("Image exceeds size limit of ".$maximagesize, LOGGER_DEBUG);
989 $r = q("select sum(octet_length(data)) as total from photo where uid = %d and scale = 0 and album != 'Contact Photos' ",
993 $limit = service_class_fetch($uid,'photo_upload_limit');
995 if (($limit !== false) && (($r[0]['total'] + strlen($imagedata)) > $limit)) {
996 logger("Image exceeds personal limit of uid ".$uid, LOGGER_DEBUG);
1001 $tempfile = tempnam(get_temppath(), "cache");
1003 $stamp1 = microtime(true);
1004 file_put_contents($tempfile, $imagedata);
1005 $a->save_timestamp($stamp1, "file");
1007 $data = getimagesize($tempfile);
1009 if (!isset($data["mime"])) {
1011 logger("File is no picture", LOGGER_DEBUG);
1015 $ph = new Photo($imagedata, $data["mime"]);
1017 if (!$ph->is_valid()) {
1019 logger("Picture is no valid picture", LOGGER_DEBUG);
1023 $ph->orient($tempfile);
1026 $max_length = get_config('system', 'max_image_length');
1027 if (! $max_length) {
1028 $max_length = MAX_IMAGE_LENGTH;
1030 if ($max_length > 0) {
1031 $ph->scaleImage($max_length);
1034 $width = $ph->getWidth();
1035 $height = $ph->getHeight();
1037 $hash = photo_new_resource();
1041 // Pictures are always public by now
1042 //$defperm = '<'.$default_cid.'>';
1046 $r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 0, 0, $defperm);
1049 logger("Picture couldn't be stored", LOGGER_DEBUG);
1053 $image = array("page" => App::get_baseurl().'/photos/'.$page_owner_nick.'/image/'.$hash,
1054 "full" => App::get_baseurl()."/photo/{$hash}-0.".$ph->getExt());
1056 if ($width > 800 || $height > 800) {
1057 $image["large"] = App::get_baseurl()."/photo/{$hash}-0.".$ph->getExt();
1060 if ($width > 640 || $height > 640) {
1061 $ph->scaleImage(640);
1062 $r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 1, 0, $defperm);
1064 $image["medium"] = App::get_baseurl()."/photo/{$hash}-1.".$ph->getExt();
1068 if ($width > 320 || $height > 320) {
1069 $ph->scaleImage(320);
1070 $r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 2, 0, $defperm);
1072 $image["small"] = App::get_baseurl()."/photo/{$hash}-2.".$ph->getExt();
1076 if ($width > 160 AND $height > 160) {
1080 $min = $ph->getWidth();
1082 $x = ($min - 160) / 2;
1085 if ($ph->getHeight() < $min) {
1086 $min = $ph->getHeight();
1088 $y = ($min - 160) / 2;
1093 $ph->cropImage(160, $x, $y, $min, $min);
1095 $r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 3, 0, $defperm);
1097 $image["thumb"] = App::get_baseurl()."/photo/{$hash}-3.".$ph->getExt();
1101 // Set the full image as preview image. This will be overwritten, if the picture is larger than 640.
1102 $image["preview"] = $image["full"];
1104 // Deactivated, since that would result in a cropped preview, if the picture wasn't larger than 320
1105 //if (isset($image["thumb"]))
1106 // $image["preview"] = $image["thumb"];
1108 // Unsure, if this should be activated or deactivated
1109 //if (isset($image["small"]))
1110 // $image["preview"] = $image["small"];
1112 if (isset($image["medium"])) {
1113 $image["preview"] = $image["medium"];