+13
-12
src-tauri/src/pngmeta.rs
+13
-12
src-tauri/src/pngmeta.rs
···
16
16
17
17
impl PNGImage {
18
18
pub fn new(buff: Vec<u8>, path: String) -> PNGImage {
19
+
if buff[0] != 0x89
20
+
|| buff[1] != 0x50
21
+
|| buff[2] != 0x4E
22
+
|| buff[3] != 0x47
23
+
|| buff[4] != 0x0D
24
+
|| buff[5] != 0x0A
25
+
|| buff[6] != 0x1A
26
+
|| buff[7] != 0x0A
27
+
{
28
+
dbg!(path);
29
+
panic!("Image is not a PNG file");
30
+
}
31
+
19
32
let mut img = PNGImage {
20
33
width: 0,
21
34
height: 0,
···
27
40
metadata: "".to_string(),
28
41
path: path,
29
42
};
30
-
31
-
if buff[0] != 0x89
32
-
|| buff[1] != 0x50
33
-
|| buff[2] != 0x4E
34
-
|| buff[3] != 0x47
35
-
|| buff[4] != 0x0D
36
-
|| buff[5] != 0x0A
37
-
|| buff[6] != 0x1A
38
-
|| buff[7] != 0x0A
39
-
{
40
-
panic!("Image is not a PNG file");
41
-
}
42
43
43
44
img.read_png_chunk(8, buff);
44
45
img