2013-03-25 123 views
-3

如何使用相同宽高比调整多个图像的大小。例如,使用相同宽高比调整大小的多个图像

960x600 1152x720 1280x800的 1680×1050 1920×1200 的2560x1600 2880x1800艺术 3840x2400

这些像素在相同的纵横比,如果我们有图像尺寸3840x2400。我需要将3840x2400的图像调整为上述像素。最好使用工具或PHP脚本或Javascript解决。

+0

你有没有做过基础研究?谷歌的PHP图像调整大小库?试过你找到的任何代码示例? – 2013-03-25 16:04:18

回答

1
<?php 
    $source = imagecreatefromjpeg("path_to_source/filename.jpg"); 
    $width = 960; 
    $height = $width*(imagesy($source)/imagesx($source)); 
    $destination = imagecreatetruecolor($width, $height); 
    imagecopyresampled($destination, $source, 0, 0, 0, 0, $width, $height, imagesx($source), imagesy($source)); 
    imagejpeg($destination,"path_to_destination/filename.jpg"); 
?> 

阿尔特$width其他尺寸...

相关问题