Please bookmark this page to avoid losing your image tool!

Image Government Classified Document Creator

(Free & Supports Bulk Upload)

Drag & drop your images here or

The result will appear here...
You can edit the below JavaScript code to customize the image tool.
async function processImage(
    originalImg,
    classificationLevel = "TOP SECRET",
    classificationColor = "red",
    headerTextTop = "", // Example: "CLASSIFIED BY ORDER OF..."
    footerTextBottom = "", // Example: "DECLASSIFY ON:..."
    documentId = "", // Auto-generates if empty. Example: "DOCID-XYZ-2023"
    fontFamilyClassification = "Impact, Arial Black, sans-serif",
    fontFamilyDetails = "Courier New, monospace",
    classificationTextOpacity = 0.7
) {
    const imgWidth = originalImg.naturalWidth || originalImg.width;
    const imgHeight = originalImg.naturalHeight || originalImg.height;

    if (imgWidth === 0 || imgHeight === 0) {
        const errorCanvas = document.createElement('canvas');
        errorCanvas.width = 300;
        errorCanvas.height = 100;
        const errorCtx = errorCanvas.getContext('2d');
        errorCtx.fillStyle = '#f0f0f0';
        errorCtx.fillRect(0, 0, errorCanvas.width, errorCanvas.height);
        errorCtx.fillStyle = 'red';
        errorCtx.font = '16px Arial';
        errorCtx.textAlign = 'center';
        errorCtx.textBaseline = 'middle';
        errorCtx.fillText('Error: Image not loaded or invalid.', errorCanvas.width / 2, errorCanvas.height / 2);
        console.error("Image Government Classified Document Creator: Image has zero dimensions.");
        return errorCanvas;
    }

    const canvas = document.createElement('canvas');
    canvas.width = imgWidth;
    canvas.height = imgHeight;
    const ctx = canvas.getContext('2d');

    // 1. Draw Original Image
    ctx.drawImage(originalImg, 0, 0, imgWidth, imgHeight);

    // Auto-generate Document ID if not provided
    if (!documentId) {
        documentId = `DOCID-${Math.random().toString(36).substring(2, 10).toUpperCase()}-${new Date().getFullYear()}`;
    }

    // --- Define layout constants ---
    // Padding from the absolute edges of the canvas for items like Doc ID
    const edgePadding = Math.max(5, Math.round(Math.min(imgWidth, imgHeight) * 0.01));

    // Zone for small detail texts (headerTextTop, footerTextBottom, documentId)
    // This zone is at the very top and very bottom of the image.
    const detailZoneHeight = Math.max(12, Math.round(imgHeight * 0.035));
    const fontSizeDetails = Math.max(8, Math.round(detailZoneHeight * 0.7)); // Font size for detail text

    // Zone for main classification text (e.g., "TOP SECRET")
    // This zone is located just inside the detail zones.
    const classificationZoneHeight = Math.max(15, Math.round(imgHeight * 0.08));
    const fontSizeClassification = Math.max(10, Math.round(classificationZoneHeight * 0.85));

    // --- Draw detail texts (header, footer, docID) ---
    ctx.font = `${fontSizeDetails}px ${fontFamilyDetails}`;
    ctx.fillStyle = 'black'; // Detail texts are typically black
    ctx.globalAlpha = 1.0;   // Ensure full opacity for details

    // Top details zone: Y position calculated from top edge
    const topDetailCenterY = detailZoneHeight / 2;
    if (headerTextTop) {
        ctx.textAlign = 'center';
        ctx.textBaseline = 'middle';
        ctx.fillText(headerTextTop.toUpperCase(), imgWidth / 2, topDetailCenterY);
    }
    if (documentId) {
        ctx.textAlign = 'right';
        ctx.textBaseline = 'middle';
        ctx.fillText(documentId.toUpperCase(), imgWidth - edgePadding, topDetailCenterY);
    }

    // Bottom details zone: Y position calculated from bottom edge
    const bottomDetailCenterY = imgHeight - (detailZoneHeight / 2);
    if (footerTextBottom) {
        ctx.textAlign = 'center';
        ctx.textBaseline = 'middle';
        ctx.fillText(footerTextBottom.toUpperCase(), imgWidth / 2, bottomDetailCenterY);
    }

    // --- Draw Main Classification Text ---
    ctx.font = `bold ${fontSizeClassification}px ${fontFamilyClassification}`;
    ctx.fillStyle = classificationColor;
    ctx.globalAlpha = classificationTextOpacity;
    ctx.textAlign = 'center';
    ctx.textBaseline = 'middle';

    // Top Classification Text: positioned below the top detail zone
    const topClassificationCenterY = detailZoneHeight + (classificationZoneHeight / 2);
    ctx.fillText(classificationLevel.toUpperCase(), imgWidth / 2, topClassificationCenterY);

    // Bottom Classification Text: positioned above the bottom detail zone
    const bottomClassificationCenterY = imgHeight - detailZoneHeight - (classificationZoneHeight / 2);
    ctx.fillText(classificationLevel.toUpperCase(), imgWidth / 2, bottomClassificationCenterY);

    // Reset globalAlpha if it was changed by classification text
    ctx.globalAlpha = 1.0;

    return canvas;
}

Free Image Tool Creator

Can't find the image tool you're looking for?
Create one based on your own needs now!

Description

The Image Government Classified Document Creator allows users to add classification markings to images, transforming them into documents that resemble classified government files. Users can select the classification level (e.g., TOP SECRET), specify the color of the markings, and customize header and footer text. This tool is useful for creating visually formatted images that require clear identification of document status, such as preparing materials for training, presentations, or internal communications where confidentiality is emphasized.

Leave a Reply

Your email address will not be published. Required fields are marked *