aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Cover_photo.php
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2018-07-25 10:19:19 +0200
committerMario Vavti <mario@mariovavti.com>2018-07-25 10:19:19 +0200
commit1b1d11dcf1091158232e98abad966d4900e2ccc9 (patch)
tree380d5e04c73391089bf3d658ea4b27eecffa4916 /Zotlabs/Module/Cover_photo.php
parentb655d04b3474893ee3dea99b77f2e7dd764729a0 (diff)
parent35200e5f1b10cdd18af8f0ea646996e438b97011 (diff)
downloadvolse-hubzilla-1b1d11dcf1091158232e98abad966d4900e2ccc9.tar.gz
volse-hubzilla-1b1d11dcf1091158232e98abad966d4900e2ccc9.tar.bz2
volse-hubzilla-1b1d11dcf1091158232e98abad966d4900e2ccc9.zip
Merge branch '3.6RC'
Diffstat (limited to 'Zotlabs/Module/Cover_photo.php')
-rw-r--r--Zotlabs/Module/Cover_photo.php48
1 files changed, 40 insertions, 8 deletions
diff --git a/Zotlabs/Module/Cover_photo.php b/Zotlabs/Module/Cover_photo.php
index 76e80156c..b911ac991 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');
@@ -84,10 +85,41 @@ 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) . ' -resize ' . $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);
+logger('gis: ' . print_r($gis,true));
+ $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()) {
@@ -119,10 +151,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);