我的下面的PHP代码在浏览器上显示原始大小为300x300的图像.
<?
$location="http://localhost/folwer.bmp ";
header("Location: $location");
?>
Run Code Online (Sandbox Code Playgroud)
但我需要在浏览器上将其显示为120x240或任何其他大小.如果不使用PHP调整原始图像大小,我该怎么办呢?请帮忙.
使用此页面上的类(在服务器上保存为SimpleImage.php)然后使用:
<?php
header('Content-Type: image/jpeg');
include('SimpleImage.php');
$image = new SimpleImage();
$image->load($location);
$image->resize(120, 240);
$image->output();
?>
Run Code Online (Sandbox Code Playgroud)
一些评论:
为此,$ location变量必须具有服务器上的映像路径,而不是URL.
这会将图像调整为宽度为120像素,高度为240像素.你可能想要240 x120.
我不确定这是否适用于bmp文件.无论如何,你在使用bmp文件做什么?