Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
ComfyUI
Commits
aac8fc99
"test/srt/git@developer.sourcefind.cn:change/sglang.git" did not exist on "4814ecaff988c26f16d7eb270d93a9034ac0b689"
Commit
aac8fc99
authored
Oct 28, 2023
by
comfyanonymous
Browse files
Cleanup webp import code a bit.
parent
2a134bfa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
15 deletions
+11
-15
web/scripts/pnginfo.js
web/scripts/pnginfo.js
+11
-15
No files found.
web/scripts/pnginfo.js
View file @
aac8fc99
...
...
@@ -108,29 +108,25 @@ export function getWebpMetadata(file) {
return
new
Promise
((
r
)
=>
{
const
reader
=
new
FileReader
();
reader
.
onload
=
(
event
)
=>
{
// Get the PNG data as a Uint8Array
const
pngData
=
new
Uint8Array
(
event
.
target
.
result
);
const
dataView
=
new
DataView
(
pngData
.
buffer
);
const
webp
=
new
Uint8Array
(
event
.
target
.
result
);
const
dataView
=
new
DataView
(
webp
.
buffer
);
// Check that the
PNG
signature is present
// Check that the
WEBP
signature is present
if
(
dataView
.
getUint32
(
0
)
!==
0x52494646
||
dataView
.
getUint32
(
8
)
!==
0x57454250
)
{
console
.
error
(
"
Not a valid WEBP file
"
);
r
();
return
;
}
// Start searching for chunks after the
PNG
signature
// Start searching for chunks after the
WEBP
signature
let
offset
=
12
;
let
txt_chunks
=
{};
// Loop through the chunks in the PNG file
while
(
offset
<
pngData
.
length
)
{
// Get the length of the chunk
const
length
=
dataView
.
getUint32
(
offset
+
4
,
true
);
// Get the chunk type
const
type
=
String
.
fromCharCode
(...
pngData
.
slice
(
offset
,
offset
+
4
));
if
(
type
===
"
EXIF
"
)
{
// Get the keyword
let
data
=
parseExifData
(
pngData
.
slice
(
offset
+
8
,
offset
+
8
+
length
));
// Loop through the chunks in the WEBP file
while
(
offset
<
webp
.
length
)
{
const
chunk_length
=
dataView
.
getUint32
(
offset
+
4
,
true
);
const
chunk_type
=
String
.
fromCharCode
(...
webp
.
slice
(
offset
,
offset
+
4
));
if
(
chunk_type
===
"
EXIF
"
)
{
let
data
=
parseExifData
(
webp
.
slice
(
offset
+
8
,
offset
+
8
+
chunk_length
));
for
(
var
key
in
data
)
{
var
value
=
data
[
key
];
let
index
=
value
.
indexOf
(
'
:
'
);
...
...
@@ -138,7 +134,7 @@ export function getWebpMetadata(file) {
}
}
offset
+=
8
+
length
;
offset
+=
8
+
chunk_
length
;
}
r
(
txt_chunks
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment