The cart is empty

This script creates a basic favicon with dimensions of 16x16 pixels. Keep in mind that the .ico format can contain multiple images of different sizes in one file, which this script does not address. Additionally, due to limited image format support in PHP, the script saves the resulting image in .webp format instead of .ico, which may not be supported as a favicon by all browsers. For a full conversion to .ico format, you might need to consider using external tools or libraries.

If you need to create a true .ico file, you may want to consider using more specialized tools or online services that can handle the conversion directly to .ico format.

<?php

function pngToFavicon($sourcePath, $destinationPath) {
    // Load the PNG image
    $image = imagecreatefrompng($sourcePath);
    if (!$image) {
        die('Error loading PNG file.');
    }

    // Get the dimensions of the original image
    $width = imagesx($image);
    $height = imagesy($image);

    // Create a new blank image for the favicon
    $favicon = imagecreatetruecolor(16, 16);

    // Resize the original image to favicon dimensions (16x16)
    imagecopyresampled($favicon, $image, 0, 0, 0, 0, 16, 16, $width, $height);

    // Save the image as .ico file
    imagewebp($favicon, $destinationPath, 100); // PHP doesn't have native support for .ico, so we'll use .webp
    imagedestroy($image);
    imagedestroy($favicon);

    echo "Favicon successfully created.\n";
}

// Example usage
$sourcePath = 'path/to/your/image.png';
$destinationPath = 'favicon.ico';

pngToFavicon($sourcePath, $destinationPath);

?>