PHPackages                             mike-jc/image-bot - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. mike-jc/image-bot

ActiveProject[CLI &amp; Console](/categories/cli)

mike-jc/image-bot
=================

Bot that resizes and upload images to the storage

1.0.0(8y ago)03[1 issues](https://github.com/mike-jc/image-bot/issues)MITPHPPHP &gt;=5.4

Since Jun 5Pushed 8y agoCompare

[ Source](https://github.com/mike-jc/image-bot)[ Packagist](https://packagist.org/packages/mike-jc/image-bot)[ RSS](/packages/mike-jc-image-bot/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (10)Versions (2)Used By (0)

Image Bot
=========

[](#image-bot)

Bot that (re)schedules, resizes and store images into cloud storage.

The workflow should be divided into the following independent steps:

- Schedule list of images to be processed.
- Resize scheduled images.
- Upload resized image to cloud storage.

Installation
------------

[](#installation)

#### Via composer

[](#via-composer)

Run:

```
$ php composer require mike-jc/image-bot

```

After that you can use any other bot command you want:

```
$ php vendor/bin/bot schedule ./images
$ php vendor/bin/bot resize -n 10
$ php vendor/bin/bot upload

```

#### Or as a Docker image

[](#or-as-a-docker-image)

Run the following commands:

```
$ mkdir sandbox && cd sandbox
$ curl -sS https://raw.githubusercontent.com/mike-jc/ImageBot/master/Dockerfile > Dockerfile
$ docker build -t bots/image-bot .
$ docker run -it --volume=:/images --workdir="/images" --entrypoint=/bin/bash bots/image-bot

```

After that Docker container will run and you will get into it.

In the running docker container:

```
$ vim /home/ImageBot/config/config.yml

... edit configuration (at least, add cloud storage credentials)

$ /etc/init.d/rabbitmq-server start

... now you're in images directory, so:

$ bot schedule ./
$ bot resize

... use any other bot command you want

```

Configuration
-------------

[](#configuration)

Configuration is placed in `config/config.yml` and has to be written in YAML format.

You need at least to choose cloud storage and add credentials for it. Currently the following cloud storages are supported:

- Amazon S3
- Dropbox
- Google Drive

#### Configuration for Amazon S3

[](#configuration-for-amazon-s3)

```
    type: amazon-s3
    parameters:
        region: YOUR_REGION_IN_AMAZON
        bucket-name: YOUR_BUCKET_NAME # by default: `default-bucket`
    credentials:
        key: YOU_CLIENT_KEY
        sercret: YOU_CLIENT_SECRET

```

#### Configuration for Dropbox

[](#configuration-for-dropbox)

```
storage:
    type: dropbox # can be: amazon-s3 for Amazon S3 storage, dropbox for Dropbox, g-drive for Google Drive
    credentials: # different structure for each storage type
        key: YOUR_CLIENT_KEY
        secret: YOUR_CLIENT_SECRET
        access-token: YOUR_DEVELOPER_ACCESS_TOKEN

```

#### Configuration for Google Drive

[](#configuration-for-google-drive)

```
    type: g-drive
    credentials:
        config-file: PATH_TO_FILE  # file with credentials in JSON for service account (not for web client!)

```

#### Other configurable parameters

[](#other-configurable-parameters)

```
queues:
    host: localhost     # connection parameters for RabbitMQ
    port: 5672
    user: admin
    password: admin
    names:              # names of queues in RabbitMQ
        resizer: resize
        storage: upload
        success: done
        failure: failed

resizer:
    side: 640           # size to which images should be resized
    bg-color: '#ffffff' # what colour to use for background if image does not fit new ratio
    delete-origin: true # delete origin images after successful resized or not

```

All settings above are optional and can be omitted in your `config.yml` file.

Usage
-----

[](#usage)

#### Schedule list of images

[](#schedule-list-of-images)

Use `schedule` command that accepts a path to the directory with images and schedule them for resize:

```
$ bot schedule ./images

```

#### Resize scheduled images

[](#resize-scheduled-images)

Use `resize` command that accept option `-n `. Takes next *count* of images from resize queue and resizes them to 640x640 pixels in JPEG format. If image is not a square shape resizer should make it square by means of adding a white background.

The next command will resize not more then 12 images:

```
$ bot resize -n 12

```

To resize all images in the queue:

```
$ bot resize

```

Resized images will be stored in directory called `_resized`. That is new directory will be created (if not exists) with name of origin directory where images were placed plus suffix `_resized`. If resize goes well original image will be removed from origin directory (this behaviour can be changed in configuration).

#### Upload resized images to the storage

[](#upload-resized-images-to-the-storage)

Use `upload` command that accept option `-n `. Uploads next count of images from upload queue to one of the remote storages. Type of cloud storage and corresponding credentials should be set in config file. There can be only one remote storage at the moment.

The next command will upload not more then 5 images:

```
$ bot upload -n 5

```

To upload all images in the queue:

```
$ bot upload

```

#### Monitoring

[](#monitoring)

You can get status of all steps in the process using command `status`. It will output all queues with a count of images in them:

```
$ bot status
Queue   Count
resize  0       # origin images scheduled for resizing
upload  12      # resized images scheduled for uploading
done    42      # uploaded images
failed  4       # images which could not be resized/uploaded for some reason

```

#### Rescheduling "failed" images

[](#rescheduling-failed-images)

Sometimes images could not be uploaded (e.g. due to network problems) or resized. Use `retry` command that accept option `-n `. It moves all (or the chosen count) "failed" images again to the queue for resizing.

The next command will reschedule not more then 3 images:

```
$ bot retry -n 3

```

To retry all images in the queue:

```
$ bot retry

```

###  Health Score

24

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3214d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a9a11bda01aa1778e080204cc023395d8dc0d33f0fa1314e337649a368314e86?d=identicon)[mike-jc](/maintainers/mike-jc)

---

Tags

cliresizequeuescloud-storage

### Embed Badge

![Health badge](/badges/mike-jc-image-bot/health.svg)

```
[![Health](https://phpackages.com/badges/mike-jc-image-bot/health.svg)](https://phpackages.com/packages/mike-jc-image-bot)
```

###  Alternatives

[n98/magerun

Tools for managing Magento projects and installations

1.4k264.1k6](/packages/n98-magerun)[acmephp/acmephp

Let's Encrypt client written in PHP

649153.6k](/packages/acmephp-acmephp)[n98/magerun2

Tools for managing Magento projects and installations

924243.9k6](/packages/n98-magerun2)[seregazhuk/php-watcher

Automatically restart PHP application once the source code changes

394137.8k1](/packages/seregazhuk-php-watcher)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
