在PHP中宽度大于高度时自动旋转图像

Wan*_*ook 3 css php image image-rotation autorotate

我过去问过,但我不确定我们是否明白,我仍然没有解决方案.我需要优雅的解决方案; 我有照片600x800我需要在我的网站上显示它旋转90度,所以结果将是,当我打印php页面时所有照片将自动垂直.

例如,我有很多照片,有两种:800x600和600x800.我需要在我的php页面上显示所有这些都是原始的800x600和所有600x800旋转90度.

我需要一些非常简单的解决方案,我完全不在乎.一些可以旋转宽度大于高度的图像的功能.

非常感谢.

ser*_*gio 5

使用PHP函数getimagesize()你可以widthheight你的形象:

  list($width, $height) = getimagesize($imageUrl);
Run Code Online (Sandbox Code Playgroud)

然后,在您的模板中:

  <?php if($width > $height): ?>
        //put css here as you want
  <?php else: ?>
        //put css here as you want
  <?php endif; ?>
Run Code Online (Sandbox Code Playgroud)