@@ -9,13 +9,18 @@ import (
9
9
gocontext "context"
10
10
"encoding/base64"
11
11
"fmt"
12
+ "image"
12
13
"io"
13
14
"net/http"
14
15
"net/url"
15
16
"path"
16
17
"strings"
17
18
"time"
18
19
20
+ _ "image/gif" // for processing gif images
21
+ _ "image/jpeg" // for processing jpeg images
22
+ _ "image/png" // for processing png images
23
+
19
24
activities_model "code.gitea.io/gitea/models/activities"
20
25
admin_model "code.gitea.io/gitea/models/admin"
21
26
asymkey_model "code.gitea.io/gitea/models/asymkey"
@@ -44,6 +49,9 @@ import (
44
49
issue_service "code.gitea.io/gitea/services/issue"
45
50
46
51
"github.com/nektos/act/pkg/model"
52
+
53
+ _ "golang.org/x/image/bmp" // for processing bmp images
54
+ _ "golang.org/x/image/webp" // for processing webp images
47
55
)
48
56
49
57
const (
@@ -578,6 +586,15 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
578
586
}
579
587
}
580
588
589
+ if fInfo .st .IsImage () && ! fInfo .st .IsSvgImage () {
590
+ img , _ , err := image .DecodeConfig (bytes .NewReader (buf ))
591
+ if err == nil {
592
+ // There are Image formats go can't decode
593
+ // Instead of throwing an error in that case, we show the size only when we can decode
594
+ ctx .Data ["ImageSize" ] = fmt .Sprintf ("%dx%dpx" , img .Width , img .Height )
595
+ }
596
+ }
597
+
581
598
if ctx .Repo .CanEnableEditor (ctx , ctx .Doer ) {
582
599
if lfsLock != nil && lfsLock .OwnerID != ctx .Doer .ID {
583
600
ctx .Data ["CanDeleteFile" ] = false
0 commit comments