Skip to content

Commit

Permalink
Merge pull request #35856 from nextcloud/enh/31284/improve-preview-ma…
Browse files Browse the repository at this point in the history
…x-memory

increase preview_max_memory and make it easier to debug
  • Loading branch information
szaimen authored Dec 22, 2022
2 parents 65a98f6 + bfb3b2a commit 5c4b4bd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions config/config.sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -1171,9 +1171,9 @@
* If creating the image would allocate more memory, preview generation will
* be disabled and the default mimetype icon is shown. Set to -1 for no limit.
*
* Defaults to ``128`` megabytes
* Defaults to ``256`` megabytes
*/
'preview_max_memory' => 128,
'preview_max_memory' => 256,

/**
* custom path for LibreOffice/OpenOffice binary
Expand Down
6 changes: 3 additions & 3 deletions lib/private/legacy/OC_Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
*/
class OC_Image implements \OCP\IImage {

// Default memory limit for images to load (128 MBytes).
protected const DEFAULT_MEMORY_LIMIT = 128;
// Default memory limit for images to load (256 MBytes).
protected const DEFAULT_MEMORY_LIMIT = 256;

// Default quality for jpeg images
protected const DEFAULT_JPEG_QUALITY = 80;
Expand Down Expand Up @@ -585,7 +585,7 @@ private function checkImageMemory($width, $height) {

// Assume 32 bits per pixel.
if ($width * $height * 4 > $memory_limit * 1024 * 1024) {
$this->logger->debug('Image size of ' . $width . 'x' . $height . ' would exceed allowed memory limit of ' . $memory_limit);
$this->logger->info('Image size of ' . $width . 'x' . $height . ' would exceed allowed memory limit of ' . $memory_limit . '. You may increase the preview_max_memory in your config.php if you need previews of this image.');
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions tests/lib/ImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ public function testData() {
->willReturn(null);
$config->expects($this->once())
->method('getSystemValueInt')
->with('preview_max_memory', 128)
->willReturn(128);
->with('preview_max_memory', 256)
->willReturn(256);
$img = new \OC_Image(null, null, $config);
$img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.jpg');
$raw = imagecreatefromstring(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.jpg'));
Expand Down

0 comments on commit 5c4b4bd

Please sign in to comment.