큰 배경에 GIF를 추가합니다
-
12-12-2019 - |
문제
imageMagick을 사용하여 업로드 된 파일의 크기를 조정하지만 처리하는 동안 나는 썸네일이 정상적으로가는 사용자에게 회전하는 GIF 휠을 표시하고 싶습니다.나는 약 7 가지 크기의 엄지 손가락을 봉사하고 휠이 중간에 32x32 크기로 유지되며, 그것은 간단한 비트입니다.
내가 알아야 할 것은 여전히 애니메이션을 유지하면서 위의 것을 할 수 있습니까?
예 :
이 이미지 : p>
이 크기로 시작합니다
애니메이션
해결책
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);
. 다른 팁
이 바이올린을 확인하십시오. http://jsfiddle.net/tgdfb/1/
jQuery를 사용하지만 쉽게 적응할 수 있어야합니다 ...
imagemagick을 통해이 작업을 수행 할 수있는 자동화 된 방법을 찾을 수없는 후에 Photoshop에 의해 수동 으로이 작업을 수행했습니다.나는 'coalesce'플래그를 발견했지만 다른 것이 아니라
제휴하지 않습니다 StackOverflow