【发布时间】:2012-10-02 08:31:38
【问题描述】:
我正在使用 imagemagick 来调整上传文件的大小,但在处理它们时,我想向用户显示一个旋转的 gif 轮,缩略图通常是在哪里。我提供大约 7 种大小的拇指,并希望轮子在中间保持 32x32 大小,这很简单。
我需要知道的是,我可以在保持动画的同时做到以上几点
例子:
这张图片:
从这个尺寸开始
带动画
【问题讨论】:
标签: imagemagick imagemagick-convert
我正在使用 imagemagick 来调整上传文件的大小,但在处理它们时,我想向用户显示一个旋转的 gif 轮,缩略图通常是在哪里。我提供大约 7 种大小的拇指,并希望轮子在中间保持 32x32 大小,这很简单。
我需要知道的是,我可以在保持动画的同时做到以上几点
例子:
这张图片:
从这个尺寸开始
带动画
【问题讨论】:
标签: imagemagick imagemagick-convert
看看这个小提琴,它可能包含你想要的:http://jsfiddle.net/TGdFB/1/
它使用 jQuery,但应该很容易适应...
【讨论】:
在无法通过 imagemagick 找到自动执行此操作的方法后,最终由 Photoshop 手动执行此操作。我找到了 'coalesce' 标志,但没有找到其他标志。
【讨论】:
在我用来给 gif 动画图像加水印的 php 女巫中有一个解决方案.... 它会创建一个黑色的免费背景,在上面放一张图片,然后放水印......
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);
【讨论】: