Wednesday, 25 September 2024

My Tools Web Free



<script type="text/javascript" src="https://udbaa.com/bnr.php?section=General&pub=654274&format=728x90&ga=g"></script>

<noscript><a href="https://yllix.com/publishers/654274" target="_blank"><img src="//ylx-aff.advertica-cdn.com/pub/728x90.png" style="border:none;margin:0;padding:0;vertical-align:baseline;" alt="ylliX - Online Advertising Network" /></a></noscript>

<Br>

 <!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Responsive Image Resizer</title>

    <style>

        * {

            box-sizing: border-box;

            padding: 0;

            margin: 0;

        }

        

        body {

            font-family: Arial, sans-serif;

            background-color: #f4f7f6;

            display: flex;

            justify-content: center;

            align-items: center;

            min-height: 100vh;

        }

        

        .container {

            background-color: #fff;

            border-radius: 10px;

            padding: 20px;

            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);

            width: 100%;

            max-width: 600px;

        }

        

        h1 {

            text-align: center;

            color: #333;

            margin-bottom: 20px;

        }

        

        .controls {

            display: flex;

            flex-direction: column;

            gap: 10px;

        }

        

        .controls label {

            font-size: 1rem;

            color: #555;

        }

        

        .controls input {

            padding: 10px;

            border: 1px solid #ddd;

            border-radius: 5px;

            font-size: 1rem;

            width: 100%;

        }

        

        canvas {

            display: none;

        }

        

        .buttons {

            display: flex;

            justify-content: space-between;

            margin-top: 20px;

        }

        

        .buttons button {

            background-color: #4CAF50;

            color: white;

            border: none;

            padding: 10px 20px;

            font-size: 1rem;

            cursor: pointer;

            border-radius: 5px;

            transition: background-color 0.3s ease;

        }

        

        .buttons button:hover {

            background-color: #45a049;

        }

        

        .buttons button:disabled {

            background-color: #ccc;

        }

        

        #outputImage {

            max-width: 100%;

            margin-top: 20px;

            border-radius: 5px;

            border: 2px solid #ddd;

        }

        

        @media screen and (max-width: 600px) {

            .buttons {

                flex-direction: column;

                gap: 10px;

            }

        }

    </style>

</head>

<body>

    <div class="container">

        <h1>Responsive Image Resizer</h1>

        <div class="controls">

            <label for="imageInput">Select an Image:</label>

            <input type="file" id="imageInput" accept="image/*">

            

            <label for="imageWidth">Set Width (px):</label>

            <input type="number" id="imageWidth" placeholder="Width in px">

            

            <label for="imageHeight">Set Height (px):</label>

            <input type="number" id="imageHeight" placeholder="Height in px">

        </div>

        <canvas id="canvas"></canvas>

        <div class="buttons">

            <button id="resizeBtn" disabled>Resize Image</button>

            <button id="downloadBtn" disabled>Download Image</button>

        </div>

        <img id="outputImage" alt="Resized Image">

    </div>


    <script>

        const imageInput = document.getElementById('imageInput');

        const imageWidthInput = document.getElementById('imageWidth');

        const imageHeightInput = document.getElementById('imageHeight');

        const resizeBtn = document.getElementById('resizeBtn');

        const downloadBtn = document.getElementById('downloadBtn');

        const canvas = document.getElementById('canvas');

        const outputImage = document.getElementById('outputImage');

        let ctx = canvas.getContext('2d');

        let originalImage;


        imageInput.addEventListener('change', (e) => {

            const file = e.target.files[0];

            if (file) {

                const reader = new FileReader();

                reader.onload = (event) => {

                    originalImage = new Image();

                    originalImage.src = event.target.result;

                    originalImage.onload = () => {

                        imageWidthInput.value = originalImage.width;

                        imageHeightInput.value = originalImage.height;

                        resizeBtn.disabled = false;

                    };

                };

                reader.readAsDataURL(file);

            }

        });


        resizeBtn.addEventListener('click', () => {

            const width = parseInt(imageWidthInput.value);

            const height = parseInt(imageHeightInput.value);

            canvas.width = width;

            canvas.height = height;

            ctx.drawImage(originalImage, 0, 0, width, height);

            const resizedImageUrl = canvas.toDataURL('image/png');

            outputImage.src = resizedImageUrl;

            downloadBtn.disabled = false;

        });


        downloadBtn.addEventListener('click', () => {

            const link = document.createElement('a');

            link.download = 'resized-image.png';

            link.href = canvas.toDataURL('image/png');

            link.click();

        });

    </script>

</body>

</html>


My Tools Web Free

<script type="text/javascript" src="https://udbaa.com/bnr.php?section=General&pub=654274&format=728x90&ga=g...