From 0d47b3a3b6f0a4bcda47bc3ce12de344b86d238f Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 28 Sep 2023 08:40:59 +0200 Subject: [PATCH] wip #6300 @0.25 --- src/CommandLine/Imagemagick.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/CommandLine/Imagemagick.php b/src/CommandLine/Imagemagick.php index b3946c5..49ba40f 100644 --- a/src/CommandLine/Imagemagick.php +++ b/src/CommandLine/Imagemagick.php @@ -3,6 +3,7 @@ namespace Cubist\Util\CommandLine; use Cubist\Util\CommandLine; +use Cubist\Util\Graphics\Color; class Imagemagick extends CommandLine { @@ -117,4 +118,19 @@ class Imagemagick extends CommandLine $cl->execute(); } + public static function getAverageColor($image) + { + $cl = new self(); + $cl->setArg(null, $image); + $cl->setManualArg('-resize 1x1\!'); + $cl->setManualArg('-format "%[fx:int(255*r+.5)],%[fx:int(255*g+.5)],%[fx:int(255*b+.5)]"'); + $cl->setManualArg('info:-'); + $cl->execute(); + $cl->debug(); + return new Color('rgb(' . trim($cl->getOutput()) . ')'); + +// convert cat.png -resize 1x1\! \ +// -format "%[fx:int(255*r+.5)],%[fx:int(255*g+.5)],%[fx:int(255*b+.5)]" info:- + } + } -- 2.39.5