Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 44dc384

Browse files
committed
resources/images: Add IsImageResourceWithMeta etc. tests for bmp and gif
Closes #14568
1 parent 5594b28 commit 44dc384

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

resources/images/meta/meta_integration_test.go

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,10 @@ sources = ['exif', 'iptc', 'xmp']
242242
sourcefilename: ../../testdata/sunset.avif
243243
-- assets/sunset.jpg --
244244
sourcefilename: ../../testdata/sunset.jpg
245+
-- assets/giphy.gif --
246+
sourcefilename: ../../testdata/giphy.gif
247+
-- assets/pix.bmp --
248+
sourcefilename: ../../testdata/pix.bmp
245249
-- assets/mytext.txt --
246250
This is a text file, not an image.
247251
-- assets/mysvg.svg --
@@ -253,21 +257,30 @@ This is a text file, not an image.
253257
{{ $svg := resources.Get "mysvg.svg" }}
254258
{{ $avif := resources.Get "sunset.avif" }}
255259
{{ $jpg := resources.Get "sunset.jpg" }}
260+
{{ $gif := resources.Get "giphy.gif" }}
261+
{{ $bmp := resources.Get "pix.bmp" }}
256262
{{ $ic := images.Config "/assets/sunset.avif" }}
263+
257264
$avif.Width/Height: {{ $avif.Width }}x{{ $avif.Height }}
258265
$ic.Width/Height: {{ $ic.Width }}x{{ $ic.Height }}
259266
260267
{{ template "is-meta-etc" dict "what" "AVIF" "dot" $avif -}}
261268
{{ template "is-meta-etc" dict "what" "JPG" "dot" $jpg -}}
262269
{{ template "is-meta-etc" dict "what" "TXT" "dot" $txt -}}
263270
{{ template "is-meta-etc" dict "what" "SVG" "dot" $svg -}}
271+
{{ template "is-meta-etc" dict "what" "GIF" "dot" $gif -}}
272+
{{ template "is-meta-etc" dict "what" "BMP" "dot" $bmp -}}
264273
265274
{{ $meta := $avif.Meta }}
266275
Num Exif tags: {{ $meta.Exif | len }}|
267276
{{ define "is-meta-etc"}}
268277
IsImageResource {{ .what }}: {{ if reflect.IsImageResource .dot }}true{{ else }}false{{ end }}
269278
IsImageResourceWithMeta {{ .what }}: {{ if reflect.IsImageResourceWithMeta .dot }}true{{ else }}false{{ end }}
270279
IsImageResourceProcessable {{ .what }}: {{ if reflect.IsImageResourceProcessable .dot }}true{{ else }}false{{ end }}
280+
{{ if reflect.IsImageResourceWithMeta .dot }}
281+
Has width {{ .what }}: {{ if .dot.Width }}true{{ else }}false{{ end }}
282+
Has meta {{ .what }}: {{ if .dot.Meta }}true{{ else }}false{{ end }}
283+
{{ end }}
271284
{{ end }}
272285
273286
`
@@ -279,15 +292,19 @@ IsImageResourceProcessable {{ .what }}: {{ if reflect.IsImageResourceProcessable
279292
$avif.Width/Height: 900x562
280293
$ic.Width/Height: 900x562
281294
282-
283295
IsImageResource AVIF: true
284296
IsImageResourceWithMeta AVIF: true
285297
IsImageResourceProcessable AVIF: false
298+
Has width AVIF: true
299+
Has meta AVIF: true
286300
287301
IsImageResource JPG: true
288302
IsImageResourceWithMeta JPG: true
289303
IsImageResourceProcessable JPG: true
290304
305+
Has width JPG: true
306+
Has meta JPG: true
307+
291308
IsImageResource TXT: false
292309
IsImageResourceWithMeta TXT: false
293310
IsImageResourceProcessable TXT: false
@@ -296,6 +313,20 @@ IsImageResource SVG: true
296313
IsImageResourceWithMeta SVG: false
297314
IsImageResourceProcessable SVG: false
298315
316+
IsImageResource GIF: true
317+
IsImageResourceWithMeta GIF: true
318+
IsImageResourceProcessable GIF: true
319+
320+
Has width GIF: true
321+
Has meta GIF: false
322+
323+
IsImageResource BMP: true
324+
IsImageResourceWithMeta BMP: true
325+
IsImageResourceProcessable BMP: true
326+
327+
Has width BMP: true
328+
Has meta BMP: false
329+
299330
Num Exif tags: 52|
300331
`,
301332
)

resources/testdata/pix.bmp

142 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)