3 * @file include/Photo.php
4 * @brief This file contains the Photo class for image processing
8 use Friendica\Core\Config;
9 use Friendica\Core\System;
11 require_once("include/photos.php");
18 * Put back gd stuff, not everybody have Imagick
28 * @brief supported mimetypes and corresponding file extensions
30 public static function supportedTypes() {
31 if (class_exists('Imagick')) {
33 // Imagick::queryFormats won't help us a lot there...
34 // At least, not yet, other parts of friendica uses this array
36 'image/jpeg' => 'jpg',
42 $t['image/jpeg'] ='jpg';
43 if (imagetypes() & IMG_PNG) {
44 $t['image/png'] = 'png';
51 public function __construct($data, $type=null) {
52 $this->imagick = class_exists('Imagick');
53 $this->types = static::supportedTypes();
54 if (!array_key_exists($type, $this->types)){
59 if ($this->is_imagick() && $this->load_data($data)) {
62 // Failed to load with Imagick, fallback
63 $this->imagick = false;
65 return $this->load_data($data);
68 public function __destruct() {
70 if ($this->is_imagick()) {
71 $this->image->clear();
72 $this->image->destroy();
75 if (is_resource($this->image)) {
76 imagedestroy($this->image);
81 public function is_imagick() {
82 return $this->imagick;
86 * @brief Maps Mime types to Imagick formats
87 * @return arr With with image formats (mime type as key)
89 public function get_FormatsMap() {
91 'image/jpeg' => 'JPG',
98 private function load_data($data) {
99 if ($this->is_imagick()) {
100 $this->image = new Imagick();
102 $this->image->readImageBlob($data);
103 } catch (Exception $e) {
104 // Imagick couldn't use the data
109 * Setup the image to the format it will be saved to
111 $map = $this->get_FormatsMap();
112 $format = $map[$type];
113 $this->image->setFormat($format);
115 // Always coalesce, if it is not a multi-frame image it won't hurt anyway
116 $this->image = $this->image->coalesceImages();
119 * setup the compression here, so we'll do it only once
121 switch($this->getType()){
123 $quality = Config::get('system', 'png_quality');
124 if ((! $quality) || ($quality > 9)) {
125 $quality = PNG_QUALITY;
128 * From http://www.imagemagick.org/script/command-line-options.php#quality:
130 * 'For the MNG and PNG image formats, the quality value sets
131 * the zlib compression level (quality / 10) and filter-type (quality % 10).
132 * The default PNG "quality" is 75, which means compression level 7 with adaptive PNG filtering,
133 * unless the image has a color map, in which case it means compression level 7 with no PNG filtering'
135 $quality = $quality * 10;
136 $this->image->setCompressionQuality($quality);
139 $quality = Config::get('system', 'jpeg_quality');
140 if ((! $quality) || ($quality > 100)) {
141 $quality = JPEG_QUALITY;
143 $this->image->setCompressionQuality($quality);
146 // The 'width' and 'height' properties are only used by non-Imagick routines.
147 $this->width = $this->image->getImageWidth();
148 $this->height = $this->image->getImageHeight();
154 $this->valid = false;
155 $this->image = @imagecreatefromstring($data);
156 if ($this->image !== false) {
157 $this->width = imagesx($this->image);
158 $this->height = imagesy($this->image);
160 imagealphablending($this->image, false);
161 imagesavealpha($this->image, true);
169 public function is_valid() {
170 if ($this->is_imagick()) {
171 return ($this->image !== false);
176 public function getWidth() {
177 if (!$this->is_valid()) {
181 if ($this->is_imagick()) {
182 return $this->image->getImageWidth();
187 public function getHeight() {
188 if (!$this->is_valid()) {
192 if ($this->is_imagick()) {
193 return $this->image->getImageHeight();
195 return $this->height;
198 public function getImage() {
199 if (!$this->is_valid()) {
203 if ($this->is_imagick()) {
205 $this->image = $this->image->deconstructImages();
211 public function getType() {
212 if (!$this->is_valid()) {
219 public function getExt() {
220 if (!$this->is_valid()) {
224 return $this->types[$this->getType()];
227 public function scaleImage($max) {
228 if (!$this->is_valid()) {
232 $width = $this->getWidth();
233 $height = $this->getHeight();
235 $dest_width = $dest_height = 0;
237 if ((! $width)|| (! $height)) {
241 if ($width > $max && $height > $max) {
243 // very tall image (greater than 16:9)
244 // constrain the width - let the height float.
246 if ((($height * 9) / 16) > $width) {
248 $dest_height = intval(($height * $max) / $width);
249 } elseif ($width > $height) {
250 // else constrain both dimensions
252 $dest_height = intval(($height * $max) / $width);
254 $dest_width = intval(($width * $max) / $height);
260 $dest_height = intval(($height * $max) / $width);
262 if ($height > $max) {
264 // very tall image (greater than 16:9)
265 // but width is OK - don't do anything
267 if ((($height * 9) / 16) > $width) {
268 $dest_width = $width;
269 $dest_height = $height;
271 $dest_width = intval(($width * $max) / $height);
275 $dest_width = $width;
276 $dest_height = $height;
282 if ($this->is_imagick()) {
284 * If it is not animated, there will be only one iteration here,
285 * so don't bother checking
287 // Don't forget to go back to the first frame
288 $this->image->setFirstIterator();
291 // FIXME - implement horizantal bias for scaling as in followin GD functions
292 // to allow very tall images to be constrained only horizontally.
294 $this->image->scaleImage($dest_width, $dest_height);
295 } while ($this->image->nextImage());
297 // These may not be necessary any more
298 $this->width = $this->image->getImageWidth();
299 $this->height = $this->image->getImageHeight();
305 $dest = imagecreatetruecolor($dest_width, $dest_height);
306 imagealphablending($dest, false);
307 imagesavealpha($dest, true);
308 if ($this->type=='image/png') {
309 imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha
311 imagecopyresampled($dest, $this->image, 0, 0, 0, 0, $dest_width, $dest_height, $width, $height);
313 imagedestroy($this->image);
315 $this->image = $dest;
316 $this->width = imagesx($this->image);
317 $this->height = imagesy($this->image);
320 public function rotate($degrees) {
321 if (!$this->is_valid()) {
325 if ($this->is_imagick()) {
326 $this->image->setFirstIterator();
328 $this->image->rotateImage(new ImagickPixel(), -$degrees); // ImageMagick rotates in the opposite direction of imagerotate()
329 } while ($this->image->nextImage());
333 // if script dies at this point check memory_limit setting in php.ini
334 $this->image = imagerotate($this->image,$degrees,0);
335 $this->width = imagesx($this->image);
336 $this->height = imagesy($this->image);
339 public function flip($horiz = true, $vert = false) {
340 if (!$this->is_valid()) {
344 if ($this->is_imagick()) {
345 $this->image->setFirstIterator();
348 $this->image->flipImage();
351 $this->image->flopImage();
353 } while ($this->image->nextImage());
357 $w = imagesx($this->image);
358 $h = imagesy($this->image);
359 $flipped = imagecreate($w, $h);
361 for ($x = 0; $x < $w; $x++) {
362 imagecopy($flipped, $this->image, $x, 0, $w - $x - 1, 0, 1, $h);
366 for ($y = 0; $y < $h; $y++) {
367 imagecopy($flipped, $this->image, 0, $y, 0, $h - $y - 1, $w, 1);
370 $this->image = $flipped;
373 public function orient($filename) {
374 if ($this->is_imagick()) {
375 // based off comment on http://php.net/manual/en/imagick.getimageorientation.php
376 $orientation = $this->image->getImageOrientation();
377 switch ($orientation) {
378 case imagick::ORIENTATION_BOTTOMRIGHT:
379 $this->image->rotateimage("#000", 180);
381 case imagick::ORIENTATION_RIGHTTOP:
382 $this->image->rotateimage("#000", 90);
384 case imagick::ORIENTATION_LEFTBOTTOM:
385 $this->image->rotateimage("#000", -90);
389 $this->image->setImageOrientation(imagick::ORIENTATION_TOPLEFT);
392 // based off comment on http://php.net/manual/en/function.imagerotate.php
394 if (!$this->is_valid()) {
398 if ((!function_exists('exif_read_data')) || ($this->getType() !== 'image/jpeg')) {
402 $exif = @exif_read_data($filename,null,true);
407 $ort = $exif['IFD0']['Orientation'];
414 case 2: // horizontal flip
418 case 3: // 180 rotate left
422 case 4: // vertical flip
423 $this->flip(false, true);
426 case 5: // vertical flip + 90 rotate right
427 $this->flip(false, true);
431 case 6: // 90 rotate right
435 case 7: // horizontal flip + 90 rotate right
440 case 8: // 90 rotate left
445 // logger('exif: ' . print_r($exif,true));
452 public function scaleImageUp($min) {
453 if (!$this->is_valid()) {
458 $width = $this->getWidth();
459 $height = $this->getHeight();
461 $dest_width = $dest_height = 0;
463 if ((!$width)|| (!$height)) {
467 if ($width < $min && $height < $min) {
468 if ($width > $height) {
470 $dest_height = intval(($height * $min) / $width);
472 $dest_width = intval(($width * $min) / $height);
478 $dest_height = intval(($height * $min) / $width);
480 if ($height < $min) {
481 $dest_width = intval(($width * $min) / $height);
484 $dest_width = $width;
485 $dest_height = $height;
490 if ($this->is_imagick()) {
491 return $this->scaleImage($dest_width, $dest_height);
494 $dest = imagecreatetruecolor($dest_width, $dest_height);
495 imagealphablending($dest, false);
496 imagesavealpha($dest, true);
497 if ($this->type=='image/png') {
498 imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha
500 imagecopyresampled($dest, $this->image, 0, 0, 0, 0, $dest_width, $dest_height, $width, $height);
502 imagedestroy($this->image);
504 $this->image = $dest;
505 $this->width = imagesx($this->image);
506 $this->height = imagesy($this->image);
511 public function scaleImageSquare($dim) {
512 if (!$this->is_valid()) {
516 if ($this->is_imagick()) {
517 $this->image->setFirstIterator();
519 $this->image->scaleImage($dim, $dim);
520 } while ($this->image->nextImage());
524 $dest = imagecreatetruecolor($dim, $dim);
525 imagealphablending($dest, false);
526 imagesavealpha($dest, true);
527 if ($this->type=='image/png') {
528 imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha
530 imagecopyresampled($dest, $this->image, 0, 0, 0, 0, $dim, $dim, $this->width, $this->height);
532 imagedestroy($this->image);
534 $this->image = $dest;
535 $this->width = imagesx($this->image);
536 $this->height = imagesy($this->image);
540 public function cropImage($max, $x, $y, $w, $h) {
541 if (!$this->is_valid()) {
545 if ($this->is_imagick()) {
546 $this->image->setFirstIterator();
548 $this->image->cropImage($w, $h, $x, $y);
550 * We need to remove the canva,
551 * or the image is not resized to the crop:
552 * http://php.net/manual/en/imagick.cropimage.php#97232
554 $this->image->setImagePage(0, 0, 0, 0);
555 } while ($this->image->nextImage());
556 return $this->scaleImage($max);
559 $dest = imagecreatetruecolor($max, $max);
560 imagealphablending($dest, false);
561 imagesavealpha($dest, true);
562 if ($this->type=='image/png') {
563 imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha
565 imagecopyresampled($dest, $this->image, 0, 0, $x, $y, $max, $max, $w, $h);
567 imagedestroy($this->image);
569 $this->image = $dest;
570 $this->width = imagesx($this->image);
571 $this->height = imagesy($this->image);
574 public function saveImage($path) {
575 if (!$this->is_valid()) {
579 $string = $this->imageString();
583 $stamp1 = microtime(true);
584 file_put_contents($path, $string);
585 $a->save_timestamp($stamp1, "file");
588 public function imageString() {
589 if (!$this->is_valid()) {
593 if ($this->is_imagick()) {
595 $this->image = $this->image->deconstructImages();
596 $string = $this->image->getImagesBlob();
604 // Enable interlacing
605 imageinterlace($this->image, true);
607 switch($this->getType()){
609 $quality = Config::get('system', 'png_quality');
610 if ((!$quality) || ($quality > 9)) {
611 $quality = PNG_QUALITY;
613 imagepng($this->image, null, $quality);
616 $quality = Config::get('system', 'jpeg_quality');
617 if ((!$quality) || ($quality > 100)) {
618 $quality = JPEG_QUALITY;
620 imagejpeg($this->image, null, $quality);
622 $string = ob_get_contents();
630 public function store($uid, $cid, $rid, $filename, $album, $scale, $profile = 0, $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '', $desc = '') {
632 $r = dba::select('photo', array('guid'), array("`resource-id` = ? AND `guid` != ?", $rid, ''), array('limit' => 1));
633 if (dbm::is_result($r)) {
639 $x = dba::select('photo', array('id'), array('resource-id' => $rid, 'uid' => $uid, 'contact-id' => $cid, 'scale' => $scale), array('limit' => 1));
641 $fields = array('uid' => $uid, 'contact-id' => $cid, 'guid' => $guid, 'resource-id' => $rid, 'created' => datetime_convert(), 'edited' => datetime_convert(),
642 'filename' => basename($filename), 'type' => $this->getType(), 'album' => $album, 'height' => $this->getHeight(), 'width' => $this->getWidth(),
643 'datasize' => strlen($this->imageString()), 'data' => $this->imageString(), 'scale' => $scale, 'profile' => $profile,
644 'allow_cid' => $allow_cid, 'allow_gid' => $allow_gid, 'deny_cid' => $deny_cid, 'deny_gid' => $deny_gid, 'desc' => $desc);
646 if (dbm::is_result($x)) {
647 $r = dba::update('photo', $fields, array('id' => $x['id']));
649 $r = dba::insert('photo', $fields);
658 * Guess image mimetype from filename or from Content-Type header
660 * @arg $filename string Image filename
661 * @arg $fromcurl boolean Check Content-Type header from curl request
663 function guess_image_type($filename, $fromcurl=false) {
664 logger('Photo: guess_image_type: '.$filename . ($fromcurl?' from curl headers':''), LOGGER_DEBUG);
669 $h = explode("\n",$a->get_curl_headers());
671 list($k,$v) = array_map("trim", explode(":", trim($l), 2));
674 if (array_key_exists('Content-Type', $headers))
675 $type = $headers['Content-Type'];
678 // Guessing from extension? Isn't that... dangerous?
679 if (class_exists('Imagick') && file_exists($filename) && is_readable($filename)) {
681 * Well, this not much better,
682 * but at least it comes from the data inside the image,
683 * we won't be tricked by a manipulated extension
685 $image = new Imagick($filename);
686 $type = $image->getImageMimeType();
687 $image->setInterlaceScheme(Imagick::INTERLACE_PLANE);
689 $ext = pathinfo($filename, PATHINFO_EXTENSION);
690 $types = Photo::supportedTypes();
691 $type = "image/jpeg";
692 foreach ($types as $m => $e){
699 logger('Photo: guess_image_type: type='.$type, LOGGER_DEBUG);
705 * @brief Updates the avatar links in a contact only if needed
707 * @param string $avatar Link to avatar picture
708 * @param int $uid User id of contact owner
709 * @param int $cid Contact id
710 * @param bool $force force picture update
712 * @return array Returns array of the different avatar sizes
714 function update_contact_avatar($avatar, $uid, $cid, $force = false) {
715 $r = q("SELECT `avatar`, `photo`, `thumb`, `micro`, `nurl` FROM `contact` WHERE `id` = %d LIMIT 1", intval($cid));
716 if (!dbm::is_result($r)) {
719 $data = array($r[0]["photo"], $r[0]["thumb"], $r[0]["micro"]);
722 if (($r[0]["avatar"] != $avatar) || $force) {
723 $photos = import_profile_photo($avatar, $uid, $cid, true);
726 q("UPDATE `contact` SET `avatar` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s', `avatar-date` = '%s' WHERE `id` = %d",
727 dbesc($avatar), dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]),
728 dbesc(datetime_convert()), intval($cid));
730 // Update the public contact (contact id = 0)
732 $pcontact = dba::select('contact', array('id'), array('nurl' => $r[0]['nurl']), array('limit' => 1));
733 if (dbm::is_result($pcontact)) {
734 update_contact_avatar($avatar, 0, $pcontact['id'], $force);
745 function import_profile_photo($photo, $uid, $cid, $quit_on_error = false) {
747 $r = q("SELECT `resource-id` FROM `photo` WHERE `uid` = %d AND `contact-id` = %d AND `scale` = 4 AND `album` = 'Contact Photos' LIMIT 1",
751 if (dbm::is_result($r) && strlen($r[0]['resource-id'])) {
752 $hash = $r[0]['resource-id'];
754 $hash = photo_new_resource();
757 $photo_failure = false;
759 $filename = basename($photo);
760 $img_str = fetch_url($photo, true);
762 if ($quit_on_error && ($img_str == "")) {
766 $type = guess_image_type($photo, true);
767 $img = new Photo($img_str, $type);
768 if ($img->is_valid()) {
770 $img->scaleImageSquare(175);
772 $r = $img->store($uid, $cid, $hash, $filename, 'Contact Photos', 4);
775 $photo_failure = true;
777 $img->scaleImage(80);
779 $r = $img->store($uid, $cid, $hash, $filename, 'Contact Photos', 5);
782 $photo_failure = true;
784 $img->scaleImage(48);
786 $r = $img->store($uid, $cid, $hash, $filename, 'Contact Photos', 6);
789 $photo_failure = true;
792 $suffix = '?ts='.time();
794 $photo = System::baseUrl() . '/photo/' . $hash . '-4.' . $img->getExt() . $suffix;
795 $thumb = System::baseUrl() . '/photo/' . $hash . '-5.' . $img->getExt() . $suffix;
796 $micro = System::baseUrl() . '/photo/' . $hash . '-6.' . $img->getExt() . $suffix;
798 // Remove the cached photo
800 $basepath = $a->get_basepath();
802 if (is_dir($basepath."/photo")) {
803 $filename = $basepath.'/photo/'.$hash.'-4.'.$img->getExt();
804 if (file_exists($filename)) {
807 $filename = $basepath.'/photo/'.$hash.'-5.'.$img->getExt();
808 if (file_exists($filename)) {
811 $filename = $basepath.'/photo/'.$hash.'-6.'.$img->getExt();
812 if (file_exists($filename)) {
817 $photo_failure = true;
820 if ($photo_failure && $quit_on_error) {
824 if ($photo_failure) {
825 $photo = System::baseUrl() . '/images/person-175.jpg';
826 $thumb = System::baseUrl() . '/images/person-80.jpg';
827 $micro = System::baseUrl() . '/images/person-48.jpg';
830 return(array($photo,$thumb,$micro));
834 function get_photo_info($url) {
837 $data = Cache::get($url);
839 if (is_null($data) || !$data || !is_array($data)) {
840 $img_str = fetch_url($url, true, $redirects, 4);
841 $filesize = strlen($img_str);
843 if (function_exists("getimagesizefromstring")) {
844 $data = getimagesizefromstring($img_str);
846 $tempfile = tempnam(get_temppath(), "cache");
849 $stamp1 = microtime(true);
850 file_put_contents($tempfile, $img_str);
851 $a->save_timestamp($stamp1, "file");
853 $data = getimagesize($tempfile);
858 $data["size"] = $filesize;
861 Cache::set($url, $data);
867 function scale_image($width, $height, $max) {
869 $dest_width = $dest_height = 0;
871 if ((!$width) || (!$height)) {
875 if ($width > $max && $height > $max) {
877 // very tall image (greater than 16:9)
878 // constrain the width - let the height float.
880 if ((($height * 9) / 16) > $width) {
882 $dest_height = intval(($height * $max) / $width);
883 } elseif ($width > $height) {
884 // else constrain both dimensions
886 $dest_height = intval(($height * $max) / $width);
888 $dest_width = intval(($width * $max) / $height);
894 $dest_height = intval(($height * $max) / $width);
896 if ($height > $max) {
898 // very tall image (greater than 16:9)
899 // but width is OK - don't do anything
901 if ((($height * 9) / 16) > $width) {
902 $dest_width = $width;
903 $dest_height = $height;
905 $dest_width = intval(($width * $max) / $height);
909 $dest_width = $width;
910 $dest_height = $height;
914 return array("width" => $dest_width, "height" => $dest_height);
917 function store_photo(App $a, $uid, $imagedata = "", $url = "") {
918 $r = q("SELECT `user`.`nickname`, `user`.`page-flags`, `contact`.`id` FROM `user` INNER JOIN `contact` on `user`.`uid` = `contact`.`uid`
919 WHERE `user`.`uid` = %d AND `user`.`blocked` = 0 AND `contact`.`self` = 1 LIMIT 1",
922 if (!dbm::is_result($r)) {
923 logger("Can't detect user data for uid ".$uid, LOGGER_DEBUG);
927 $page_owner_nick = $r[0]['nickname'];
930 /// $default_cid = $r[0]['id'];
931 /// $community_page = (($r[0]['page-flags'] == PAGE_COMMUNITY) ? true : false);
933 if ((strlen($imagedata) == 0) && ($url == "")) {
934 logger("No image data and no url provided", LOGGER_DEBUG);
936 } elseif (strlen($imagedata) == 0) {
937 logger("Uploading picture from ".$url, LOGGER_DEBUG);
939 $stamp1 = microtime(true);
940 $imagedata = @file_get_contents($url);
941 $a->save_timestamp($stamp1, "file");
944 $maximagesize = Config::get('system', 'maximagesize');
946 if (($maximagesize) && (strlen($imagedata) > $maximagesize)) {
947 logger("Image exceeds size limit of ".$maximagesize, LOGGER_DEBUG);
951 $tempfile = tempnam(get_temppath(), "cache");
953 $stamp1 = microtime(true);
954 file_put_contents($tempfile, $imagedata);
955 $a->save_timestamp($stamp1, "file");
957 $data = getimagesize($tempfile);
959 if (!isset($data["mime"])) {
961 logger("File is no picture", LOGGER_DEBUG);
965 $ph = new Photo($imagedata, $data["mime"]);
967 if (!$ph->is_valid()) {
969 logger("Picture is no valid picture", LOGGER_DEBUG);
973 $ph->orient($tempfile);
976 $max_length = Config::get('system', 'max_image_length');
978 $max_length = MAX_IMAGE_LENGTH;
980 if ($max_length > 0) {
981 $ph->scaleImage($max_length);
984 $width = $ph->getWidth();
985 $height = $ph->getHeight();
987 $hash = photo_new_resource();
991 // Pictures are always public by now
992 //$defperm = '<'.$default_cid.'>';
996 $r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 0, 0, $defperm);
999 logger("Picture couldn't be stored", LOGGER_DEBUG);
1003 $image = array("page" => System::baseUrl().'/photos/'.$page_owner_nick.'/image/'.$hash,
1004 "full" => System::baseUrl()."/photo/{$hash}-0.".$ph->getExt());
1006 if ($width > 800 || $height > 800) {
1007 $image["large"] = System::baseUrl()."/photo/{$hash}-0.".$ph->getExt();
1010 if ($width > 640 || $height > 640) {
1011 $ph->scaleImage(640);
1012 $r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 1, 0, $defperm);
1014 $image["medium"] = System::baseUrl()."/photo/{$hash}-1.".$ph->getExt();
1018 if ($width > 320 || $height > 320) {
1019 $ph->scaleImage(320);
1020 $r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 2, 0, $defperm);
1022 $image["small"] = System::baseUrl()."/photo/{$hash}-2.".$ph->getExt();
1026 if ($width > 160 && $height > 160) {
1030 $min = $ph->getWidth();
1032 $x = ($min - 160) / 2;
1035 if ($ph->getHeight() < $min) {
1036 $min = $ph->getHeight();
1038 $y = ($min - 160) / 2;
1043 $ph->cropImage(160, $x, $y, $min, $min);
1045 $r = $ph->store($uid, $visitor, $hash, $tempfile, t('Wall Photos'), 3, 0, $defperm);
1047 $image["thumb"] = System::baseUrl()."/photo/{$hash}-3.".$ph->getExt();
1051 // Set the full image as preview image. This will be overwritten, if the picture is larger than 640.
1052 $image["preview"] = $image["full"];
1054 // Deactivated, since that would result in a cropped preview, if the picture wasn't larger than 320
1055 //if (isset($image["thumb"]))
1056 // $image["preview"] = $image["thumb"];
1058 // Unsure, if this should be activated or deactivated
1059 //if (isset($image["small"]))
1060 // $image["preview"] = $image["small"];
1062 if (isset($image["medium"])) {
1063 $image["preview"] = $image["medium"];