123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <?php
- if (!defined('GNUSOCIAL')) { exit(1); }
- class ImageMagickPlugin extends Plugin
- {
-
- public function onFillImageFileMetadata(ImageFile $imagefile) {
- if (is_null($imagefile->animated) && $imagefile->type === IMAGETYPE_GIF) {
- $magick = new Imagick($imagefile->filepath);
- $magick = $magick->coalesceImages();
- $imagefile->animated = $magick->getNumberImages()>1;
- }
- return true;
- }
- public function onStartResizeImageFile(ImageFile $imagefile, $outpath, array $box) {
-
-
- if ($imagefile->type == IMAGETYPE_GIF && $imagefile->animated && common_config('thumbnail', 'animated')) {
- $magick = new Imagick($imagefile->filepath);
- $magick = $magick->coalesceImages();
- $magick->setIteratorIndex(0);
- do {
- $magick->cropImage($box['w'], $box['h'], $box['x'], $box['y']);
- $magick->thumbnailImage($box['width'], $box['height']);
- $magick->setImagePage($box['width'], $box['height'], 0, 0);
- } while ($magick->nextImage());
- $magick = $magick->deconstructImages();
-
-
- $fh = fopen($outpath, 'w+');
- $success = $magick->writeImagesFile($fh);
- fclose($fh);
- return !$success;
- }
- return true;
- }
- public function onPluginVersion(&$versions)
- {
- $versions[] = array('name' => 'ImageMagick',
- 'version' => GNUSOCIAL_VERSION,
- 'author' => 'Mikael Nordfeldth',
- 'homepage' => 'http://gnu.io/social',
- 'rawdescription' =>
-
- _m('Use ImageMagick for some more image support.'));
- return true;
- }
- }
|