Skip to content

Commit

Permalink
0.0.4: #1
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrii-fediuk committed Oct 26, 2020
1 parent 31e4f8b commit e67db11
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand All @@ -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
Expand All @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"
Expand Down

0 comments on commit e67db11

Please sign in to comment.