Skip to content

Commit

Permalink
Merge pull request #937 from biigle/patch-1
Browse files Browse the repository at this point in the history
Fix thumbnail size configuration
  • Loading branch information
mzur authored Oct 2, 2024
2 parents 92dc4ca + 0bc2933 commit f238db0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
5 changes: 3 additions & 2 deletions app/Jobs/ProcessNewImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ public function __construct(Image $image)
*/
public function handle()
{
$this->width = config('thumbnails.width');
$this->height = config('thumbnails.height');
// Double the size for crisp display on high-dpi montors.
$this->width = config('thumbnails.width') * 2;
$this->height = config('thumbnails.height') * 2;
$this->threshold = config('image.tiles.threshold');

try {
Expand Down
5 changes: 3 additions & 2 deletions app/Jobs/ProcessNewVideo.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,9 @@ public function generateVideoThumbnails($disk, $fragment, $tmpDir)
// Config for normal thumbs
$format = config('thumbnails.format');
$thumbCount = config('videos.thumbnail_count');
$width = config('thumbnails.width');
$height = config('thumbnails.height');
// Double the size for crisp display on high-dpi montors.
$width = config('thumbnails.width') * 2;
$height = config('thumbnails.height') * 2;

// Config for sprite thumbs
$thumbnailsPerSprite = config('videos.sprites_thumbnails_per_sprite');
Expand Down
4 changes: 2 additions & 2 deletions config/thumbnails.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
| you are doing, since the views must work with these images. The images are always
| scaled proportionally, so this values are kind of a max-width and max-height.
*/
'width' => 360,
'height' => 270,
'width' => 180,
'height' => 135,

/*
| Thumbnail file format. Depending on your thumbnail service, different formats are
Expand Down
6 changes: 3 additions & 3 deletions tests/php/Jobs/ProcessNewImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ public function testHandleMakeThumbnail()
$size = getimagesize(Storage::disk('test-thumbs')->path("{$prefix}.{$format}"));
$config = [config('thumbnails.width'), config('thumbnails.height')];

$this->assertTrue($size[0] <= $config[0]);
$this->assertTrue($size[1] <= $config[1]);
$this->assertTrue($size[0] == $config[0] || $size[1] == $config[1]);
$this->assertTrue($size[0] <= ($config[0] * 2));
$this->assertTrue($size[1] <= ($config[1] * 2));
$this->assertTrue($size[0] == ($config[0] * 2) || $size[1] == ($config[1] * 2));
}

public function testHandleMakeThumbnailNotReadable()
Expand Down

0 comments on commit f238db0

Please sign in to comment.