i recently cleared the cache on my Nextcloud iOS app and realized that the previews are not being regenerated because they are HEIC pics or MOV videos.
The previews will only come on only when accessing the picture, not the mov video.
is there a way to generate previews like with JPEG/MP4?
require_once __DIR__ . '/lib/base.php';
if (\OCP\Util::needUpgrade()) {
\OC::$server->getLogger()->debug('Update required, skipping cron', ['app' => 'cron']);
exit;
}
if ((bool) \OC::$server->getSystemConfig()->getValue('maintenance', false)) {
\OC::$server->getLogger()->debug('We are in maintenance mode, skipping cron', ['app' => 'cron']);
exit;
}
// load all apps to get all api routes properly setup
OC_App::loadApps();
\OC::$server->getSession()->close();
// initialize a dummy memory session
$session = new \OC\Session\Memory('');
$cryptoWrapper = \OC::$server->getSessionCryptoWrapper();
$session = $cryptoWrapper->wrapSession($session);
\OC::$server->setSession($session);
$logger = \OC::$server->getLogger();
$config = \OC::$server->getConfig();
// Don't do anything if Nextcloud has not been installed
if (!$config->getSystemValue('installed', false)) {
exit(0);
}
\OC::$server->getTempManager()->cleanOld();
// Exit if background jobs are disabled!
$appMode = $config->getAppValue('core', 'backgroundjobs_mode', 'ajax');
if ($appMode === 'none') {
if (OC::$CLI) {
echo 'Background Jobs are disabled!' . PHP_EOL;
} else {
OC_JSON::error(array('data' => array('message' => 'Background jobs disabled!')));
}
exit(1);
}
if (OC::$CLI) {
// set to run indefinitely if needed
if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
@set_time_limit(0);
}
// the cron job must be executed with the right user
if (!function_exists('posix_getuid')) {
echo "The posix extensions are required - see http://php.net/manual/en/book.posix.php" . PHP_EOL;
exit(1);
}
$user = posix_getpwuid(posix_getuid());
$configUser = posix_getpwuid(fileowner(OC::$configDir . 'config.php'));
if ($user['name'] !== $configUser['name']) {
echo "Console has to be executed with the same user as the web server is operated" . PHP_EOL;
echo "Current user: " . $user['name'] . PHP_EOL;
echo "Web server user: " . $configUser['name'] . PHP_EOL;
exit(1);
}
// We call Nextcloud from the CLI (aka cron)
if ($appMode !== 'cron') {
$config->setAppValue('core', 'backgroundjobs_mode', 'cron');
}
// Work
$jobList = \OC::$server->getJobList();
// We only ask for jobs for 14 minutes, because after 15 minutes the next
// system cron task should spawn.
$endTime = time() + 14 * 60;
$executedJobs = [];
while ($job = $jobList->getNext()) {
if (isset($executedJobs[$job->getId()])) {
$jobList->unlockJob($job);
break;
}
$job->execute($jobList, $logger);
// clean up after unclean jobs
\OC_Util::tearDownFS();
$jobList->setLastJob($job);
$executedJobs[$job->getId()] = true;
unset($job);
if (time() > $endTime) {
break;
}
}
} else {
// We call cron.php from some website
if ($appMode === 'cron') {
// Cron is cron :-P
OC_JSON::error(array('data' => array('message' => 'Backgroundjobs are using system cron!')));
} else {
// Work and success :-)
$jobList = \OC::$server->getJobList();
$job = $jobList->getNext();
if ($job != null) {
$job->execute($jobList, $logger);
$jobList->setLastJob($job);
}
OC_JSON::success();
}
}
// Log the successful cron execution
$config->setAppValue('core', 'lastcron', time());
exit();
i also ran the command php -u www-data /var/www/nextcloud/occ preview:generate-all and the heic pictures taken from today didnt get the preview generated.
How are your preview settings in the config.php file look like? Have you explicitly set the “enabledPreviewProviders” parameter or are you using the default settings, like:
Could you find any related message in your Nextcloud log file if you run a scan command (make sure that “'loglevel' => 0,” is set)?
BTW, you can most likely speed-up your tests if you place some HEIC files in a dedicated directory and use the preview:generate --path=<path-to-dedicated-dir>" command as documented in the command help.
Nextcloud relies on the imagick program command line program to convert images. If this program supports the HEIC format, Nextcloud should also be able to create the preview files.
See how it could be enabled:
Afaik, the following command can be used to check if the HEIC format is supported:
# php -r 'phpinfo();' | grep HEIC
The imagick support can be checked by executing this command:
did not want to open another thread, hope its ok to post here.
I have nc 17.0.1 and imagemagic 7.x. I can see HEIC preview and when I right click and select details, I can see a picture on the right hand corner.
However, if I click on the name of the picture, or the small thumbnail of the HEIC itself, the browser attempts to download the image. If I do the same to an jpg or png file, the image opens nice and big and I can view it in browser. How can I have the same behaviour for the HEIC file as I get with a jpg or png file?
I have setup the HEIC compatibility a few month ago already and have used various browsers on many different devices and platforms, and the behavior is the same.
@Dridhas
I have exactly the same behaviour. When I work with the pictures, its easier to do with the file view and not the gallery. Problem is, I like to preview the picture before I delete or download it. With JPEG and other older formats, its no problem, just HEIC.
@j-ed
Thank you. I hope this will be implemented soon. It seems like the preview is working in gallery view, it just needs to be “ported” to the file view. But I don’t know the inner workings of nextcloud …