mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-25 09:16:17 -04:00
Add image preview to input file overlay.
This can be turned off
This commit is contained in:
parent
d09ab4a153
commit
2049e4e1d5
2 changed files with 13 additions and 2 deletions
|
@ -6,6 +6,8 @@
|
|||
|
||||
import LoaderWorker from "worker-loader?inline&fallback=false!./LoaderWorker";
|
||||
import Utils from "../core/Utils";
|
||||
import { toBase64 } from "../core/lib/Base64";
|
||||
import { isImage } from "../core/lib/FileType";
|
||||
|
||||
|
||||
/**
|
||||
|
@ -290,8 +292,16 @@ class InputWaiter {
|
|||
*/
|
||||
displayFilePreview() {
|
||||
const inputText = document.getElementById("input-text"),
|
||||
fileSlice = this.fileBuffer.slice(0, 4096);
|
||||
|
||||
fileSlice = this.fileBuffer.slice(0, 4096),
|
||||
fileThumb = document.getElementById("input-file-thumbnail"),
|
||||
arrBuffer = new Uint8Array(this.fileBuffer),
|
||||
type = isImage(arrBuffer);
|
||||
if (type && type !== "image/tiff" && this.app.options.imagePreview) {
|
||||
// Don't show TIFFs as not much supports them
|
||||
fileThumb.src = `data:${type};base64,${toBase64(arrBuffer)}`;
|
||||
} else {
|
||||
fileThumb.src = require("./static/images/file-128x128.png");
|
||||
}
|
||||
inputText.style.overflow = "hidden";
|
||||
inputText.classList.add("blur");
|
||||
inputText.value = Utils.printable(Utils.arrayBufferToStr(fileSlice));
|
||||
|
|
|
@ -53,6 +53,7 @@ function main() {
|
|||
ioDisplayThreshold: 512,
|
||||
logLevel: "info",
|
||||
autoMagic: true,
|
||||
imagePreview: true,
|
||||
};
|
||||
|
||||
document.removeEventListener("DOMContentLoaded", main, false);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue