Open JanisPlayer opened 1 year ago
This is an image that is generated with 100% quality and max resolution. It may put some load on the CPU but can save bandwidth and achieve the same results as loading the full image. JPEG could be used, which can be processed quickly, or bandwidth-saving WebP, which also offers fast processing. The generation could be integrated here or a separate file could be created like /lib/Controller/Previewer.php. Then, in /src/components/viewer/Viewer.vue, you can simply request the IMAGE_HQ_PREVIEW when, for example, zooming is performed. One could go further and create a cache with a maximum size and file count. What would you think of the idea?
I'm a bit confused. This is more or less exactly what is done right now (see). When the user zooms into the image, the image is converted to JPEG server-side and displayed to the user.
I have a question, how do you change the FFmpeg quality setting from "Faster" to "Ultrafast"?
For now, you'll need to compile go-vod
yourself. Make sure you use the correct version tag.
https://github.com/pulsejet/memories/blob/bf7721cb1fc8d4b0d97f9a21834102a90d59f9ed/lib/Controller/ImageController.php#L364 Yes I totally missed it and didn't look into the function, I thought it just called the original image. So then I could just change that to WebP, cool. Then my functional idea would actually be to add more formats such as quality, maxWidth, maxHeight settings. And an option is to be added so that it always converts to the format you want.
$format = $this->config->getSystemValueString('memories.preview.format', 'jpeg');
switch ($format) {
case 'jpeg':
$format = 'jpeg';
break;
case 'webp':
$format = 'webp';
break;
case 'avif':
$format = 'avif';
break;
default:
$format = 'jpeg';
}
$image->setImageFormat($format);
$quality = (int)$this->config->getSystemValue('memories.preview.quality', '95');
if ($quality < 0 || $quality > 100) {
//throw Exceptions::Forbidden('Warning: You have set an invalid quality value for image conversion');
}
$image->setImageCompressionQuality($quality);
// Set maximum width and height
$maxWidth = (int)$this->config->getSystemValue('memories.preview.x', '0');
$maxHeight = (int)$this->config->getSystemValue('memories.preview.y', '0');
// Get current dimensions
$width = (int)$image->getImageWidth();
$height = (int)$image->getImageHeight();
// Calculate new dimensions while maintaining aspect ratio
if($maxWidth != 0 && $maxHeight != 0) {
if ($width > $maxWidth || $height > $maxHeight) {
$aspectRatio = $width / $height;
if ($width > $height) {
$newWidth = $maxWidth;
$newHeight = $maxWidth / $aspectRatio;
} else {
$newHeight = $maxHeight;
$newWidth = $maxHeight * $aspectRatio;
}
// Resize the image
//$image->resizeImage((int)$newWidth, (int)$newHeight, \Imagick::FILTER_CATROM, 1); Dont Work
$image->scaleImage((int)$newWidth, (int)$newHeight);
}
}
// Convert image to JPEG if required
$format = $this->config->getSystemValueString('memories.preview.format', 'false');
if (!\in_array($mimetype, ['image/png', 'image/webp', 'image/jpeg', 'image/gif'], true) || $format= false) {
Warning this is untested sample code, it's just meant to explain an idea better. But I'll make a version that you could include. Update: I test it and it works. :) So finish, i try to make a pull for this: https://github.com/JanisPlayer/memories/commit/e613076cc565d6ed8695e4ad39f2449142f4e9c6
For now, you'll need to compile go-vod yourself. Make sure you use the correct version tag.
Thanks will try.
https://github.com/pulsejet/memories/tree/master/src/native.ts#L16 https://github.com/pulsejet/memories/tree/master/src/components/viewer/Viewer.vue#L808 I have a feature idea for the app: IMAGE_HQ_PREVIEW This is an image that is generated with 100% quality and max resolution. It may put some load on the CPU but can save bandwidth and achieve the same results as loading the full image. JPEG could be used, which can be processed quickly, or bandwidth-saving WebP, which also offers fast processing. The generation could be integrated here or a separate file could be created like /lib/Controller/Previewer.php. Then, in /src/components/viewer/Viewer.vue, you can simply request the IMAGE_HQ_PREVIEW when, for example, zooming is performed. One could go further and create a cache with a maximum size and file count. What would you think of the idea?
I have a question, how do you change the FFmpeg quality setting from "Faster" to "Ultrafast"? https://github.com/pulsejet/memories/blob/master/docs/system-config.md https://github.com/pulsejet/memories/blob/master/docs/hw-transcoding.md
Oh, and I think the app is fantastic. I had a similar idea recently, and then someone recommended your app to me. It's already working very well, there was only one installation error, which could be easily fixed.