born05 / craft-colorextractor

Extract colors from image assets in Craft CMS.
MIT License
2 stars 5 forks source link

Error on install task #2

Closed dpschen closed 2 years ago

dpschen commented 5 years ago

Hello, after installing the ColorExtractorTask fails to run through. In the queue.log I found the following:

2019-01-24 17:59:27 [-][18][-][error][craft\queue\QueueLogBehavior::afterError]  [7770] ColorExtractorTask (attempt: 1) - Error (time: 0.343s): imagecreatefromstring(): Data is not in a recognized format
2019-01-24 17:59:27 [-][18][-][error][yii\base\ErrorException:2] yii\base\ErrorException: imagecreatefromstring(): Data is not in a recognized format in /var/www/html/vendor/league/color-extractor/src/League/ColorExtractor/Palette.php:54
Stack trace:
#0 /var/www/html/vendor/craftcms/cms/src/web/ErrorHandler.php(76): yii\base\ErrorHandler->handleError(2, 'imagecreatefrom...', '/var/www/html/v...', 54)
#1 [internal function]: craft\web\ErrorHandler->handleError(2, 'imagecreatefrom...', '/var/www/html/v...', 54, Array)
#2 /var/www/html/vendor/league/color-extractor/src/League/ColorExtractor/Palette.php(54): imagecreatefromstring('II*\x00\xEE\x90\x15\x00\x802\xD8\xAB\xF2\x98D...')
#3 /var/www/html/vendor/born05/craft-colorextractor/src/services/Asset.php(32): League\ColorExtractor\Palette::fromFilename([<!-- STRING WITH CROPPED URL (PROBABLY IMAGE) -->])
#4 /var/www/html/vendor/born05/craft-colorextractor/src/services/Asset.php(57): born05\colorextractor\services\Asset->extractColor(Object(craft\elements\Asset))
#5 /var/www/html/vendor/born05/craft-colorextractor/src/jobs/ColorExtractorTask.php(44): born05\colorextractor\services\Asset->getImageColor(Object(craft\elements\Asset), true)
#6 /var/www/html/vendor/yiisoft/yii2-queue/src/Queue.php(214): born05\colorextractor\jobs\ColorExtractorTask->execute(Object(craft\queue\Queue))
#7 /var/www/html/vendor/yiisoft/yii2-queue/src/cli/Queue.php(147): yii\queue\Queue->handleMessage('7770', 'O:45:"born05\\co...', '300', 1)
#8 /var/www/html/vendor/craftcms/cms/src/queue/Queue.php(96): yii\queue\cli\Queue->handleMessage('7770', 'O:45:"born05\\co...', '300', 1)
#9 /var/www/html/vendor/craftcms/cms/src/controllers/QueueController.php(86): craft\queue\Queue->run()
#10 [internal function]: craft\controllers\QueueController->actionRun()
#11 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#12 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#13 /var/www/html/vendor/craftcms/cms/src/web/Controller.php(109): yii\base\Controller->runAction('run', Array)
#14 /var/www/html/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('run', Array)
#15 /var/www/html/vendor/craftcms/cms/src/web/Application.php(297): yii\base\Module->runAction('queue/run', Array)
#16 /var/www/html/vendor/craftcms/cms/src/web/Application.php(561): craft\web\Application->runAction('queue/run', Array)
#17 /var/www/html/vendor/craftcms/cms/src/web/Application.php(281): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#18 /var/www/html/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#19 /var/www/html/web/index.php(21): yii\base\Application->run()
#20 {main}
roelvanhintum commented 5 years ago

Looks like filetype validation is missing.

roelvanhintum commented 5 years ago

@dpschen can you give me some info on what kind of image it was loading? It shouldn't load anything other than images.

roelvanhintum commented 5 years ago

Should be fixed with 2.0.0

dpschen commented 5 years ago

Thanks for the quick fix. Sadly I still get the a similar error. I'm not sure which file triggers the error. It's difficult to test since there are many files in the installation. Also the file path is cropped in the error, so I don't know the actual file…

I have the assumption that the problematic image might be in the webp format. In the new error in the queue.log after installation of 2.00 you can see the string x00WEBPVP8 in line #2.

2019-02-21 11:48:04 [-][18][-][error][craft\queue\QueueLogBehavior::afterError]  [11047] ColorExtractorTask (attempt: 1) - Error (time: 0.505s): imagecreatefromstring(): Data is not in a recognized format
2019-02-21 11:48:04 [-][18][-][error][yii\base\ErrorException:2] yii\base\ErrorException: imagecreatefromstring(): Data is not in a recognized format in /var/www/html/vendor/league/color-extractor/src/League/ColorExtractor/Palette.php:54
Stack trace:
#0 /var/www/html/vendor/craftcms/cms/src/web/ErrorHandler.php(76): yii\base\ErrorHandler->handleError(2, 'imagecreatefrom...', '/var/www/html/v...', 54)
#1 [internal function]: craft\web\ErrorHandler->handleError(2, 'imagecreatefrom...', '/var/www/html/v...', 54, Array)
#2 /var/www/html/vendor/league/color-extractor/src/League/ColorExtractor/Palette.php(54): imagecreatefromstring('RIFFH\xE8\x00\x00WEBPVP8...')
#3 /var/www/html/vendor/born05/craft-colorextractor/src/services/Asset.php(32): League\ColorExtractor\Palette::fromFilename([<!-- STRING WITH CROPPED URL (PROBABLY IMAGE) -->])
#4 /var/www/html/vendor/born05/craft-colorextractor/src/services/Asset.php(62): born05\colorextractor\services\Asset->extractColor(Object(craft\elements\Asset))
#5 /var/www/html/vendor/born05/craft-colorextractor/src/jobs/ColorExtractorTask.php(44): born05\colorextractor\services\Asset->getImageColor(Object(craft\elements\Asset), true)
#6 /var/www/html/vendor/yiisoft/yii2-queue/src/Queue.php(214): born05\colorextractor\jobs\ColorExtractorTask->execute(Object(craft\queue\Queue))
#7 /var/www/html/vendor/yiisoft/yii2-queue/src/cli/Queue.php(147): yii\queue\Queue->handleMessage('11047', 'O:45:"born05\\co...', '300', 1)
#8 /var/www/html/vendor/craftcms/cms/src/queue/Queue.php(96): yii\queue\cli\Queue->handleMessage('11047', 'O:45:"born05\\co...', '300', 1)
#9 /var/www/html/vendor/craftcms/cms/src/controllers/QueueController.php(86): craft\queue\Queue->run()
#10 /var/www/html/vendor/craftcms/cms/src/controllers/QueueController.php(106): craft\controllers\QueueController->actionRun()
#11 [internal function]: craft\controllers\QueueController->actionRetry()
#12 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#13 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#14 /var/www/html/vendor/craftcms/cms/src/web/Controller.php(109): yii\base\Controller->runAction('retry', Array)
#15 /var/www/html/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('retry', Array)
#16 /var/www/html/vendor/craftcms/cms/src/web/Application.php(297): yii\base\Module->runAction('queue/retry', Array)
#17 /var/www/html/vendor/craftcms/cms/src/web/Application.php(561): craft\web\Application->runAction('queue/retry', Array)
#18 /var/www/html/vendor/craftcms/cms/src/web/Application.php(281): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#19 /var/www/html/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#20 /var/www/html/web/index.php(21): yii\base\Application->run()
#21 {main}
roelvanhintum commented 5 years ago

@dpschen Yes, it turns out webp isn't supported by php's imagecreatefromstring. Should be fixable.

roelvanhintum commented 5 years ago

The plugin depends on League/ColorExtractor, just added an issue. https://github.com/thephpleague/color-extractor/issues/55

dpschen commented 5 years ago

That might be it. Thanks for the issue!

roelvanhintum commented 2 years ago

Looks like League/ColorExtractor does not support php 8.0 and up and isn't updated anymore.