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

nepada / file-upload-control / 11627792231

28 Oct 2024 11:42AM UTC coverage: 81.674%. Remained the same
11627792231

push

github

xificurk
FE: fix binding to latest nette-forms.js

722 of 884 relevant lines covered (81.67%)

0.82 hits per line

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

78.13
/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\Image;
8
use Nette\Utils\ImageColor;
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
        $exifData = @exif_read_data($path);
1✔
30
        if ($exifData === false) {
1✔
31
            return $image;
1✔
32
        }
33

34
        $orientation = $exifData['Orientation'] ?? 1;
1✔
35
        switch ($orientation) {
1✔
36
            case 2:
×
37
                $image->resize('-100%', null);
1✔
38
                break;
1✔
39
            case 3:
×
40
                $image->resize('-100%', '-100%');
1✔
41
                break;
1✔
42
            case 4:
×
43
                $image->resize(null, '-100%');
1✔
44
                break;
1✔
45
            /** @noinspection PhpMissingBreakStatementInspection */
46
            case 5:
×
47
                $image->resize(null, '-100%');
1✔
48
                // intentionally no break
49
            case 6:
×
50
                $image->rotate(-90, ImageColor::rgb(0, 0, 0, 0));
1✔
51
                break;
1✔
52
            /** @noinspection PhpMissingBreakStatementInspection */
53
            case 7:
×
54
                $image->resize(null, '-100%');
1✔
55
                // intentionally no break
56
            case 8:
×
57
                $image->rotate(90, ImageColor::rgb(0, 0, 0, 0));
1✔
58
                break;
1✔
59
        }
60

61
        return $image;
1✔
62
    }
63

64
}
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