Php 网站设计中的图像
我允许我的用户发布不同分辨率的图像。然后,我使用php使图像适合所需的大小,并减少为这些图像拍摄的大小。图像是400x360px。但问题是在调整大小后的图像。图像收缩为: 如果图像的比率相同。这样图像就不会受到影响。是否有任何策略或php函数来完美地处理图像。我知道不同大小的图像只能用这种方法调整大小。我想知道是否有办法显示图像?您可以计算Php 网站设计中的图像,php,html,css,image,Php,Html,Css,Image,我允许我的用户发布不同分辨率的图像。然后,我使用php使图像适合所需的大小,并减少为这些图像拍摄的大小。图像是400x360px。但问题是在调整大小后的图像。图像收缩为: 如果图像的比率相同。这样图像就不会受到影响。是否有任何策略或php函数来完美地处理图像。我知道不同大小的图像只能用这种方法调整大小。我想知道是否有办法显示图像?您可以计算 $factor = $imgheight / $imgwidth; 而且,如果你想要的图像总是,例如300px的宽度,只要采取 $widthnew =
$factor = $imgheight / $imgwidth;
而且,如果你想要的图像总是,例如300px的宽度,只要采取
$widthnew = 300;
$heightnew = $widthnew * $factor;
因此,您将始终正确显示图像
作为一个简单的功能:
function imageheight($widthnew, $imgheight, $imgwidth) {
$factor = $imgheight / $imgwidth;
$heightnew = $widthnew * $factor;
return $heightnew;
}
你可以计算
$factor = $imgheight / $imgwidth;
而且,如果你想要的图像总是,例如300px的宽度,只要采取
$widthnew = 300;
$heightnew = $widthnew * $factor;
因此,您将始终正确显示图像
作为一个简单的功能:
function imageheight($widthnew, $imgheight, $imgwidth) {
$factor = $imgheight / $imgwidth;
$heightnew = $widthnew * $factor;
return $heightnew;
}
你可以计算
$factor = $imgheight / $imgwidth;
而且,如果你想要的图像总是,例如300px的宽度,只要采取
$widthnew = 300;
$heightnew = $widthnew * $factor;
因此,您将始终正确显示图像
作为一个简单的功能:
function imageheight($widthnew, $imgheight, $imgwidth) {
$factor = $imgheight / $imgwidth;
$heightnew = $widthnew * $factor;
return $heightnew;
}
你可以计算
$factor = $imgheight / $imgwidth;
而且,如果你想要的图像总是,例如300px的宽度,只要采取
$widthnew = 300;
$heightnew = $widthnew * $factor;
因此,您将始终正确显示图像
作为一个简单的功能:
function imageheight($widthnew, $imgheight, $imgwidth) {
$factor = $imgheight / $imgwidth;
$heightnew = $widthnew * $factor;
return $heightnew;
}
你想要的是修剪它 尝试调整图像大小,直到高度达到您想要的高度。然后,完全忽略宽度,而是剪切部分宽度 例如,收缩
##############################
# #
# #
# #
# #
# #
# #
# #
# #
##############################
到
然后裁剪:
### ------- ###
# | , , | #
# | _ | #
# | __/ | #
### ------- ###
你想要的是修剪它 尝试调整图像大小,直到高度达到您想要的高度。然后,完全忽略宽度,而是剪切部分宽度 例如,收缩
##############################
# #
# #
# #
# #
# #
# #
# #
# #
##############################
到
然后裁剪:
### ------- ###
# | , , | #
# | _ | #
# | __/ | #
### ------- ###
你想要的是修剪它 尝试调整图像大小,直到高度达到您想要的高度。然后,完全忽略宽度,而是剪切部分宽度 例如,收缩
##############################
# #
# #
# #
# #
# #
# #
# #
# #
##############################
到
然后裁剪:
### ------- ###
# | , , | #
# | _ | #
# | __/ | #
### ------- ###
你想要的是修剪它 尝试调整图像大小,直到高度达到您想要的高度。然后,完全忽略宽度,而是剪切部分宽度 例如,收缩
##############################
# #
# #
# #
# #
# #
# #
# #
# #
##############################
到
然后裁剪:
### ------- ###
# | , , | #
# | _ | #
# | __/ | #
### ------- ###