duanpendan8067 2013-03-25 16:02
浏览 47

多个图像调整大小,具有相同的宽高比

How can I resize multiple image with same aspect ratio. For example,

960x600 1152x720 1280x800 1440x900 1680x1050 1920x1200 2560x1600 2880x1800 3840x2400

these pixels are in same aspect ratio, if we have the image size 3840x2400. I need to resize the images from 3840x2400 into the above pixels. Preferably solved using either tool or PHP Script or Javascript.

  • 写回答

1条回答 默认 最新

  • duanhuren5581 2013-04-23 14:29
    关注
    <?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");
    ?>
    

    Alter $width for other sizes...

    评论

报告相同问题?

悬赏问题

  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀