【问题标题】:what is best way to rotate an image using php or convert command? [closed]使用 php 或 convert 命令旋转图像的最佳方法是什么? [关闭]
【发布时间】:2015-07-25 16:47:30
【问题描述】:

使用 php 或 convert 命令旋转图像的最佳方法是什么?

【问题讨论】:

  • 您好。我们更喜欢这里已经研究过的问题,所以我不赞成。如何使用convert旋转图片在IM手册中。

标签: php imagemagick image-rotation


【解决方案1】:

使用 Imagick,使用 rotateImage

<?php
$image = new Imagick("source.kpg");
$image->rotateImage ( 'white', 90.0 );

【讨论】:

    【解决方案2】:

    使用PHP函数imagerotate
    http://php.net/manual/en/function.imagerotate.php

    例子:

    <?php
    // File and rotation
    $filename = 'test.jpg';
    $degrees = 180;
    
    // Content type
    header('Content-type: image/jpeg');
    
    // Load
    $source = imagecreatefromjpeg($filename);
    
    // Rotate
    $rotate = imagerotate($source, $degrees, 0);
    
    // Output
    imagejpeg($rotate);
    
    // Free the memory
    imagedestroy($source);
    imagedestroy($rotate);
    ?>
    

    【讨论】:

      【解决方案3】:

      您可以使用ImageMagick 执行此操作。以下命令将旋转图像:

      convert original_file.jpg -rotate 90 new_file.jpg
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-12-19
        • 1970-01-01
        • 2010-11-14
        • 2022-01-21
        • 1970-01-01
        相关资源
        最近更新 更多