From e67db116f564d6c5aa32a24c2d0737a9a71b8d07 Mon Sep 17 00:00:00 2001 From: Dmitry Fedyuk Date: Mon, 26 Oct 2020 10:25:57 +0600 Subject: [PATCH] 0.0.4: https://github.com/tradefurniturecompany/image/issues/1 --- Command.php | 10 +++++++--- composer.json | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Command.php b/Command.php index 67f62d6..230f975 100644 --- a/Command.php +++ b/Command.php @@ -26,7 +26,12 @@ protected function configure() {$this->setName('tfc:image')->setDescription('Pro */ protected function p() { df_google_init_service_account(); - foreach ($this->images() as $i) {/** @var sttring $i */ + $ii = array_slice($this->images(), 0, 10); /** @var string[] $ii */ + $count = count($ii); /** @var int $count */ + $c = 0; + foreach ($ii as $i) {/** @var string $i */ + $c++; + $this->output()->writeln(sprintf("%d of %d (%d%%): %s", $c, $count, $c * 100 / $count, df_product_image_path2rel($i))); $this->image($i); } } @@ -44,7 +49,6 @@ private function image($path) { finally {$a->close();} $oo = $res->getLocalizedObjectAnnotations(); /** @var RepeatedField $oo */ if (1 === $oo->count()) { - $this->output()->writeln($path); # 2020-10-26 https://cloud.google.com/vision/docs/reference/rest/v1/AnnotateImageResponse#LocalizedObjectAnnotation $o = $oo[0]; /** @var O $o */ # 2020-10-26 @@ -66,7 +70,7 @@ private function image($path) { ,'width' => $x($v2->getX() - $v0->getX()) ,'x' => $x($v0->getX()), 'y' => $y($v0->getY()) ]); - $path = str_replace(df_product_images_path(), df_cc_path(dirname(BP), 'result'), $path); + $path = df_cc_path(dirname(BP), 'result', df_product_image_path2rel($path)); if (!is_dir($dir = dirname($path))) { mkdir($dir, 777, true); } diff --git a/composer.json b/composer.json index 3c425a3..f974d94 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "tradefurniturecompany/image" - ,"version": "0.0.3" + ,"version": "0.0.4" ,"description": "A custom image processing module for tradefurniturecompany.co.uk (Magento 2)" ,"type": "magento2-module" ,"homepage": "https://github.com/tradefurniturecompany/image" @@ -11,7 +11,7 @@ ,"homepage": "https://mage2.pro/users/dmitry_fedyuk" ,"role": "Developer" }] - ,"require": {"google/cloud-vision": "*", "mage2pro/core": ">=7.0.10"} + ,"require": {"google/cloud-vision": "*", "mage2pro/core": ">=7.0.2"} ,"autoload": {"files": ["registration.php"], "psr-4": {"TFC\\Image\\": ""}} ,"keywords": [ "eCommerce"