1

我正在使用 imagemagick 来调整上传文件的大小,但是在处理它们时,我想向用户显示一个旋转的 gif 轮,缩略图通常是在哪里。我提供大约 7 种大小的拇指,并希望轮子在中间保持 32x32 大小,这很简单。

我需要知道的是,我可以在保留动画的同时做到以上几点吗

例子:

这个图片: 这个图片

从这个尺寸开始 这个尺寸

带动画

4

3 回答 3

1

看看这个小提琴,它可能包含你想要的:http: //jsfiddle.net/TGdFB/1/

它使用 jQuery,但应该很容易适应......

于 2012-10-02T08:46:33.620 回答
1

在无法通过 imagemagick 找到自动执行此操作的方法后,最终由 Photoshop 手动执行此操作。我找到了“coalesce”标志,但没有别的。

于 2012-10-02T09:16:34.157 回答
0

php 女巫中有一个解决方案,我用它来为 gif 动画图像加水印......

watermarkpath = 'path to wathermarkimage.jpg|gif|png';
$imagepath= 'path to the image';     
$watermark = new Imagick($watermarkpath);
 $GIF = new Imagick();
 $GIF->setFormat("gif");

$animation = new Imagick($imagepath);
foreach ($animation as $frame) {

    $iWidth = $frame->getImageWidth();
    $iHeight = $frame->getImageHeight();
    $wWidth = $watermark->getImageWidth();
    $wHeight = $watermark->getImageHeight();

    if ($iHeight < $wHeight || $iWidth < $wWidth) {
        // resize the watermark
        $watermark->scaleImage($iWidth, $iHeight);

        // get new size
        $wWidth = $watermark->getImageWidth();
        $wHeight = $watermark->getImageHeight();
    }

    $bgframe = new Imagick();
    $bgframe->newImage(($iWidth), ($iHeight + 80), new ImagickPixel('Black'));
    $bgframe->setImageDelay($frame->getImageDelay());


    $x = ($iWidth) - $wWidth - 5;
    $y = ($iHeight + 80) - $wHeight - 5;


    $bgframe->compositeImage($frame, imagick::COMPOSITE_DEFAULT, 0, 0);
     $bgframe->flattenImages();
    $bgframe->compositeImage($watermark, imagick::COMPOSITE_OVER, $x, $y);
     $bgframe->flattenImages();
    $GIF->addImage($bgframe);
}



$GIF->writeimages($imagepath,true);
于 2013-01-23T09:52:14.060 回答