Php 我可以向该脚本添加调整大小功能吗?

Php 我可以向该脚本添加调整大小功能吗?,php,Php,我不是很擅长PHP,但我的网页上显示的图像将是主要的分辨率。我想缩小规模,但我不知道怎么做 <?php $images = glob('*.{gif,png,jpg,jpeg}', GLOB_BRACE); // Formats to look for $num_of_files = 2; // Number of images to display foreach ($images as $image) { $num_of_files--; if ($num_of_

我不是很擅长PHP,但我的网页上显示的图像将是主要的分辨率。我想缩小规模,但我不知道怎么做

<?php
$images = glob('*.{gif,png,jpg,jpeg}', GLOB_BRACE); // Formats to look for

$num_of_files = 2; // Number of images to display

foreach ($images as $image) {
    $num_of_files--;

    if ($num_of_files > -1) // This made me laugh when I wrote it
    {
        echo "<b>" . $image . "</b><br>"
            . "Created on " . date('D, d M y H:i:s', filemtime($image)) . "<br>"
            . "<img src='" . $image . "'><br><br>";
    } // Display images
    else {
        break;
    }
}
?>

您似乎只想调整浏览器中显示的图像的大小,对吗?在这种情况下,一些简单的样式就可以做到:

. "<img src='" . $image . "' style='width: 200px'><br><br>";
。“

”;
将200px更改为任意宽度,高度将按比例缩放

您还应该了解如何使用


如果您想缩放实际图像文件(即,如果它位于您的服务器上),请查看。

我不确定您在问什么。是否要在服务器上调整文件大小或在用户浏览器中缩小文件大小?如果要减小文件大小但保持图像质量:(如果他们有此API,则未知)否则: