X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2FPhoto.php;h=1450374ffc27971fd91b20d325c5593d3ac33413;hb=685686b3e81e53264b4946f54904e8f5323da2ea;hp=9934b9a3928f2e79ec060ede1cb55f547718f4ef;hpb=f4fd67992812c5c356ff51e875077921a2222d90;p=friendica.git diff --git a/include/Photo.php b/include/Photo.php old mode 100644 new mode 100755 index 9934b9a392..1450374ffc --- a/include/Photo.php +++ b/include/Photo.php @@ -162,12 +162,20 @@ class Photo { } public function saveImage($path) { - imagejpeg($this->image,$path,100); + $quality = get_config('system','jpeg_quality'); + if((! $quality) || ($quality > 100)) + $quality = JPEG_QUALITY; + imagejpeg($this->image,$path,$quality); } public function imageString() { ob_start(); - imagejpeg($this->image,NULL,100); + + $quality = get_config('system','jpeg_quality'); + if((! $quality) || ($quality > 100)) + $quality = JPEG_QUALITY; + + imagejpeg($this->image,NULL,$quality); $s = ob_get_contents(); ob_end_clean(); return $s; @@ -177,11 +185,20 @@ class Photo { public function store($uid, $cid, $rid, $filename, $album, $scale, $profile = 0, $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '') { + $r = q("select `guid` from photo where `resource-id` = '%s' and `guid` != '' limit 1", + dbesc($rid) + ); + if(count($r)) + $guid = $r[0]['guid']; + else + $guid = get_guid(); + $r = q("INSERT INTO `photo` - ( `uid`, `contact-id`, `resource-id`, `created`, `edited`, `filename`, `album`, `height`, `width`, `data`, `scale`, `profile`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid` ) - VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, '%s', '%s', '%s', '%s' )", + ( `uid`, `contact-id`, `guid`, `resource-id`, `created`, `edited`, `filename`, `album`, `height`, `width`, `data`, `scale`, `profile`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid` ) + VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, '%s', '%s', '%s', '%s' )", intval($uid), intval($cid), + dbesc($guid), dbesc($rid), dbesc(datetime_convert()), dbesc(datetime_convert()), @@ -222,21 +239,21 @@ function import_profile_photo($photo,$uid,$cid) { $hash = photo_new_resource(); - $r = $img->store($uid, $cid, $hash, $filename, t('Contact Photos'), 4 ); + $r = $img->store($uid, $cid, $hash, $filename, 'Contact Photos', 4 ); if($r === false) $photo_failure = true; $img->scaleImage(80); - $r = $img->store($uid, $cid, $hash, $filename, t('Contact Photos'), 5 ); + $r = $img->store($uid, $cid, $hash, $filename, 'Contact Photos', 5 ); if($r === false) $photo_failure = true; $img->scaleImage(48); - $r = $img->store($uid, $cid, $hash, $filename, t('Contact Photos'), 6 ); + $r = $img->store($uid, $cid, $hash, $filename, 'Contact Photos', 6 ); if($r === false) $photo_failure = true;