Store only the smallest cover_photos (425x239 or scale '9') in cache/xp .

In setup, check for ther existence of /usr/bin/magick prior to looking for /usr/bin/convert.
This commit is contained in:
Mike Macgirvin 2022-06-26 17:17:04 -07:00
parent 2cf3f9ed9d
commit 636688e432
3 changed files with 12 additions and 4 deletions

View file

@ -10,7 +10,9 @@ use Code\Web\Controller;
use Code\Lib\Channel;
use Code\Extend\Hook;
use Code\Render\Theme;
use Code\Lib\XConfig;
use Code\Lib\Hashpath;
use Code\Storage\Stdio;
/*
@file cover_photo.php
@ -210,6 +212,9 @@ class Cover_photo extends Controller
$channel = App::get_channel();
$this->send_cover_photo_activity($channel, $base_image, $profile);
// put the url and a copy in the places we look for remote cover photos.
XConfig::Set($channel['channel_hash'], 'system', 'cover_photo', z_root() . '/photo/' . $base_image['resource_id'] . '-7');
Stdio::fcopy('store/' . $channel['channel_address'] . '/' . $p['os_path'] . '-9', Hashpath::path($channel['channel_hash'], 'cache/xp' , 2) . '-9');
} else {
notice(t('Unable to process image') . EOL);
}

View file

@ -782,7 +782,10 @@ class Setup extends Controller
set_config('system', 'allowed_themes', 'redbasic');
// if imagick converter is installed, use it
if (@is_executable('/usr/bin/convert')) {
if (@is_executable('/usr/bin/magick')) {
set_config('system', 'imagick_convert_path', '/usr/bin/magick');
}
elseif (@is_executable('/usr/bin/convert')) {
set_config('system', 'imagick_convert_path', '/usr/bin/convert');
}

View file

@ -363,8 +363,8 @@ function import_remote_cover_photo($src, $xchan)
if ($imagick_path && file_exists($imagick_path)) {
exec($imagick_path . ' '
. escapeshellarg(PROJECT_BASE . '/' . $orig)
. ' -resize 850x478 '
. escapeshellarg(PROJECT_BASE . '/' . $path . '-8')
. ' -resize 425x239 '
. escapeshellarg(PROJECT_BASE . '/' . $path . '-9')
);
}
}