• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nepada / file-upload-control / 3609782379

pending completion
3609782379

push

github

Petr Morávek
v1.4.0

637 of 706 relevant lines covered (90.23%)

0.9 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.86
/src/FileUploadControl/Thumbnail/ImageLoader.php
1
<?php
2
declare(strict_types = 1);
3

4
namespace Nepada\FileUploadControl\Thumbnail;
5

6
use Nette;
7
use Nette\Utils\Arrays;
8
use Nette\Utils\Image;
9

10
final class ImageLoader
11
{
12

13
    use Nette\SmartObject;
14

15
    private bool $autoRotate;
16

17
    public function __construct(bool $autoRotate = true)
1✔
18
    {
19
        $this->autoRotate = $autoRotate;
1✔
20
    }
1✔
21

22
    public function load(string $path): Image
1✔
23
    {
24
        $image = Image::fromFile($path);
1✔
25
        if (! $this->autoRotate) {
1✔
26
            return $image;
1✔
27
        }
28

29
        $orientation = Arrays::get((array) @exif_read_data($path), 'Orientation', 1);
1✔
30
        switch ($orientation) {
1✔
31
            case 2:
×
32
                $image->resize('-100%', null);
1✔
33
                break;
1✔
34
            case 3:
×
35
                $image->resize('-100%', '-100%');
1✔
36
                break;
1✔
37
            case 4:
×
38
                $image->resize(null, '-100%');
1✔
39
                break;
1✔
40
            /** @noinspection PhpMissingBreakStatementInspection */
41
            case 5:
×
42
                $image->resize(null, '-100%');
1✔
43
                // intentionally no break
44
            case 6:
×
45
                $image->rotate(-90, Image::rgb(0, 0, 0, 127));
1✔
46
                break;
1✔
47
            /** @noinspection PhpMissingBreakStatementInspection */
48
            case 7:
×
49
                $image->resize(null, '-100%');
1✔
50
                // intentionally no break
51
            case 8:
×
52
                $image->rotate(90, Image::rgb(0, 0, 0, 127));
1✔
53
                break;
1✔
54
        }
55

56
        return $image;
1✔
57
    }
58

59
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc