Question

I'm using imagemagick to resize uploaded files but while they're processing I want to show a rotating gif wheel to the user where the thumbnail would normally be. I serve about 7 sizes of thumbs and would like the wheel to remain at it's 32x32 size in the middle, that's the simple bit.

What I need to know is, can I do the above while still retaining the animation

Example:

This Image: This Image

Starting at this size This Size

With Animation

Was it helpful?

Solution

there is a solution in php witch i use to watermark gif animated images .... it create an black bacground put an image on it and then put watermark ...

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);

OTHER TIPS

Check out this fiddle, it might contain what you want: http://jsfiddle.net/TGdFB/1/

It uses jQuery, but should be easily adaptable...

Ended up doing this manually by Photoshop after not being able to find an automated way of doing this through imagemagick. I found the 'coalesce' flag but not much else.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top