$ratio = 16/9;
$rat = $info[0] / $info[1];
if ($rat == $ratio){
$newimg = imagescale($newimg, 960, 540, IMG_BICUBIC); // this works
}
elseif ($rat > $ratio){
// here I want something like:
$newimg = imagescale($newimg, 'auto', 540, IMG_BICUBIC);
}那么,如何在保持高宽比的前提下,自动缩放到540度和比例宽度呢?
发布于 2018-04-20 17:08:17
您可以使用$rat * 540来保持相同的比率,而不是'auto'。
$newimg = imagescale($newimg, $rat * 540, 540, IMG_BICUBIC);因此,如果比例是4/3的例子,宽度将是:540*4/3 = 720。如果比率为16/9,则为540*16/19 = 960。
https://stackoverflow.com/questions/49946539
复制相似问题