【发布时间】:2016-04-08 12:31:15
【问题描述】:
伙计们,我知道以前有人问过这个问题,但它不一样,因为我尝试了其他答案,但没有任何效果。
我想使用 php 和缩略图 width="265px" 和 height="125px" 创建缩略图图像,这是我的代码:
$image_width = $imageSize[0];
$image_height = $imageSize[1];
$new_size = ($image_width + $image_height) / ($image_width * ($image_height / 45)); //this will set any image to 125*70 which is a good thumbnail
$new_width = $image_width * $new_size;
$new_height = $image_height * $new_size;
if($ext == "gif"){
$old_image = imagecreatefromgif($real_image_path);
}else if($ext =="png"){
$old_image = imagecreatefrompng($real_image_path);
}else{
$old_image = imagecreatefromjpeg($real_image_path);
}
$new_image = imagecreatetruecolor($new_width, $new_height); //creating new image with a new color for quality
imagecopyresized($new_image, $old_image, 0, 0, 0, 0, $new_width, $new_height, $image_width, $image_height);
我不太确定我的 cmets,但我只是写了它们以防万一
我认为它需要一个数学好的人
谢谢,新年快乐
【问题讨论】:
-
这到底是怎么不适合你的......?
-
这里有一个提示..您不需要数学来调整图像大小..
-
@MarcB 它没有得到我想要的尺寸
-
@Pamblam 我认为它需要一个方程或比率来将任何宽度和任何高度调整为固定值
-
不适用于固定的高度和宽度。如果你想缩放图像,你需要数学,但你没有缩放任何东西,你正在调整它的大小并可能改变纵横比..
标签: php image-processing thumbnails