Ajouter un gif à un fond plus grand
-
12-12-2019 - |
Question
J'utilise ImageMagick pour redimensionner des fichiers téléchargés, mais lorsqu'ils sont en traitement, je souhaite montrer une roue gife rotative à l'utilisateur où la vignette serait normalement.Je serve environ 7 tailles de pouces et j'aimerais que la roue reste à sa taille 32x32 au milieu, c'est le petit bit.
Ce que j'ai besoin de savoir, puis-je faire ce qui précède tout en conservant l'animation
Exemple:
Cette image:
à partir de cette taille
avec animation
La solution
Il y a une solution dans PHP Sorcière J'utilise pour filigrane GIF animée d'images animées .... Il crée un bacone de bacone noire mettez une image dessus puis mettez le filigrane ...
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);
Autres conseils
Consultez ce violon, il peut contenir ce que vous voulez: http://jsfiddle.net/tgdfb/1/
Il utilise JQuery, mais devrait être facilement adaptable ...
a fini par faire cela manuellement par Photoshop après ne pas être capable de trouver une manière automatisée de faire cela à travers ImageMagick.J'ai trouvé le drapeau "coalesce" mais pas grand chose d'autre.