From db930b794dc228f24549d7ef8052be8110990e1f Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 1 May 2018 16:54:54 -0700 Subject: provide warnings about profile photo and cover photo permissions --- Zotlabs/Module/Cover_photo.php | 1 + 1 file changed, 1 insertion(+) (limited to 'Zotlabs/Module/Cover_photo.php') diff --git a/Zotlabs/Module/Cover_photo.php b/Zotlabs/Module/Cover_photo.php index d76c1b408..76e80156c 100644 --- a/Zotlabs/Module/Cover_photo.php +++ b/Zotlabs/Module/Cover_photo.php @@ -355,6 +355,7 @@ class Cover_photo extends \Zotlabs\Web\Controller { $o .= replace_macros($tpl,array( '$user' => \App::$channel['channel_address'], + '$info' => t('Your cover photo may be visible to anybody on the internet'), '$existing' => get_cover_photo(local_channel(),'array',PHOTO_RES_COVER_850), '$lbl_upfile' => t('Upload File:'), '$lbl_profiles' => t('Select a profile:'), -- cgit v1.2.3 From 3c8de7b59d010f8273370c720aafde80067f77d7 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 7 May 2018 23:57:17 -0700 Subject: use imagemagick first stage thumbnail for cover photos, if configured --- Zotlabs/Module/Cover_photo.php | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) (limited to 'Zotlabs/Module/Cover_photo.php') diff --git a/Zotlabs/Module/Cover_photo.php b/Zotlabs/Module/Cover_photo.php index 76e80156c..d0780c4de 100644 --- a/Zotlabs/Module/Cover_photo.php +++ b/Zotlabs/Module/Cover_photo.php @@ -84,10 +84,39 @@ class Cover_photo extends \Zotlabs\Web\Controller { ); if($r) { - - $base_image = $r[0]; - $base_image['content'] = (($r[0]['os_storage']) ? @file_get_contents(dbunescbin($base_image['content'])) : dbunescbin($base_image['content'])); - + + $max_thumb = intval(get_config('system','max_thumbnail',1600)); + $iscaled = false; + if(intval($r[0]['height']) > $max_thumb || intval($r[0]['width']) > $max_thumb) { + $imagick_path = get_config('system','imagick_convert_path'); + if($imagick_path && @file_exists($imagick_path) && intval($r[0]['os_storage'])) { + $fname = dbunescbin($r[0]['content']); + $tmp_name = $fname . '-001'; + $newsize = photo_calculate_scale(array_merge(getimagesize($fname),['max' => $max_thumb])); + $cmd = $imagick_path . ' ' . escapeshellarg(PROJECT_BASE . '/' . $fname) . ' -thumbnail ' . $newsize . ' ' . escapeshellarg(PROJECT_BASE . '/' . $tmp_name); + // logger('imagick thumbnail command: ' . $cmd); + for($x = 0; $x < 4; $x ++) { + exec($cmd); + if(file_exists($tmp_name)) { + break; + } + } + if(file_exists($tmp_name)) { + $base_image = $r[0]; + $gis = getimagesize($tmp_name); + $base_image['width'] = $gis[0]; + $base_image['height'] = $gis[1]; + $base_image['content'] = @file_get_contents($tmp_name); + $iscaled = true; + @unlink($tmp_name); + } + } + } + if(! $iscaled) { + $base_image = $r[0]; + $base_image['content'] = (($r[0]['os_storage']) ? @file_get_contents(dbunescbin($base_image['content'])) : dbunescbin($base_image['content'])); + } + $im = photo_factory($base_image['content'], $base_image['mimetype']); if($im->is_valid()) { -- cgit v1.2.3 From fbd26e8d9d5482961d5b0d0f2f10a38b2ea8009c Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 8 May 2018 16:50:16 -0700 Subject: changes made during testing imagick scaling for cover photo thumbnail --- Zotlabs/Module/Cover_photo.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'Zotlabs/Module/Cover_photo.php') diff --git a/Zotlabs/Module/Cover_photo.php b/Zotlabs/Module/Cover_photo.php index d0780c4de..9adfa2209 100644 --- a/Zotlabs/Module/Cover_photo.php +++ b/Zotlabs/Module/Cover_photo.php @@ -90,6 +90,7 @@ class Cover_photo extends \Zotlabs\Web\Controller { if(intval($r[0]['height']) > $max_thumb || intval($r[0]['width']) > $max_thumb) { $imagick_path = get_config('system','imagick_convert_path'); if($imagick_path && @file_exists($imagick_path) && intval($r[0]['os_storage'])) { + $fname = dbunescbin($r[0]['content']); $tmp_name = $fname . '-001'; $newsize = photo_calculate_scale(array_merge(getimagesize($fname),['max' => $max_thumb])); @@ -104,6 +105,7 @@ class Cover_photo extends \Zotlabs\Web\Controller { if(file_exists($tmp_name)) { $base_image = $r[0]; $gis = getimagesize($tmp_name); +logger('gis: ' . print_r($gis,true)); $base_image['width'] = $gis[0]; $base_image['height'] = $gis[1]; $base_image['content'] = @file_get_contents($tmp_name); @@ -148,10 +150,10 @@ class Cover_photo extends \Zotlabs\Web\Controller { intval(local_channel()) ); - $orig_srcx = ( $r[0]['width'] / $scaled_width ) * $srcX; - $orig_srcy = ( $r[0]['height'] / $scaled_height ) * $srcY; - $orig_srcw = ( $srcW / $scaled_width ) * $r[0]['width']; - $orig_srch = ( $srcH / $scaled_height ) * $r[0]['height']; + $orig_srcx = ( $base_image['width'] / $scaled_width ) * $srcX; + $orig_srcy = ( $base_image['height'] / $scaled_height ) * $srcY; + $orig_srcw = ( $srcW / $scaled_width ) * $base_image['width']; + $orig_srch = ( $srcH / $scaled_height ) * $base_image['height']; $im->cropImageRect(1200,435,$orig_srcx, $orig_srcy, $orig_srcw, $orig_srch); -- cgit v1.2.3 From 4f3be92a0d8b9b8555647d3086e13dd3530c6463 Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Sun, 27 May 2018 17:57:35 +0200 Subject: include photos.php required for photo_calculate_scale() --- Zotlabs/Module/Cover_photo.php | 1 + 1 file changed, 1 insertion(+) (limited to 'Zotlabs/Module/Cover_photo.php') diff --git a/Zotlabs/Module/Cover_photo.php b/Zotlabs/Module/Cover_photo.php index 9adfa2209..88fd4485d 100644 --- a/Zotlabs/Module/Cover_photo.php +++ b/Zotlabs/Module/Cover_photo.php @@ -9,6 +9,7 @@ namespace Zotlabs\Module; require_once('include/photo/photo_driver.php'); require_once('include/channel.php'); +require_once('include/photos.php'); -- cgit v1.2.3 From 156010050c874eb51f8d2b2334d36909f99e732c Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 26 Jun 2018 17:19:32 -0700 Subject: imagick converter: -thumbnail doesn't preserve exif, -resize does --- Zotlabs/Module/Cover_photo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Module/Cover_photo.php') diff --git a/Zotlabs/Module/Cover_photo.php b/Zotlabs/Module/Cover_photo.php index 88fd4485d..b911ac991 100644 --- a/Zotlabs/Module/Cover_photo.php +++ b/Zotlabs/Module/Cover_photo.php @@ -95,7 +95,7 @@ class Cover_photo extends \Zotlabs\Web\Controller { $fname = dbunescbin($r[0]['content']); $tmp_name = $fname . '-001'; $newsize = photo_calculate_scale(array_merge(getimagesize($fname),['max' => $max_thumb])); - $cmd = $imagick_path . ' ' . escapeshellarg(PROJECT_BASE . '/' . $fname) . ' -thumbnail ' . $newsize . ' ' . escapeshellarg(PROJECT_BASE . '/' . $tmp_name); + $cmd = $imagick_path . ' ' . escapeshellarg(PROJECT_BASE . '/' . $fname) . ' -resize ' . $newsize . ' ' . escapeshellarg(PROJECT_BASE . '/' . $tmp_name); // logger('imagick thumbnail command: ' . $cmd); for($x = 0; $x < 4; $x ++) { exec($cmd); -- cgit v1.2.3