Hash collision using the same quality level and incorrect quality for WebP (#1431)
* fix: webp quality level mismatch * fix: hash collision using the same image ops Using the same image operations, but for different formats, e.g. `.jpg` and `.webp`, produced the same hash. To differentiate between these, the image extension is added to the hash.
This commit is contained in:
parent
fc808f2aa8
commit
421a2512f7
|
@ -207,6 +207,7 @@ impl Hash for Format {
|
||||||
};
|
};
|
||||||
|
|
||||||
hasher.write_u8(q);
|
hasher.write_u8(q);
|
||||||
|
hasher.write(self.extension().as_bytes());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,7 +317,7 @@ impl ImageOp {
|
||||||
Format::WebP(q) => {
|
Format::WebP(q) => {
|
||||||
let encoder = webp::Encoder::from_image(&img);
|
let encoder = webp::Encoder::from_image(&img);
|
||||||
let memory = match q {
|
let memory = match q {
|
||||||
Some(q) => encoder.encode(q as f32 / 100.),
|
Some(q) => encoder.encode(q as f32),
|
||||||
None => encoder.encode_lossless(),
|
None => encoder.encode_lossless(),
|
||||||
};
|
};
|
||||||
f.write_all(&memory.as_bytes())?;
|
f.write_all(&memory.as_bytes())?;
|
||||||
|
|
Loading…
Reference in a new issue