PHPackages                             boris/imgscrape - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. boris/imgscrape

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

boris/imgscrape
===============

Simple image scraper from remote URL to get the largest image

0.3.4(11y ago)7411MITPHP

Since Feb 4Pushed 11y ago2 watchersCompare

[ Source](https://github.com/borispavlov0/image-scrape)[ Packagist](https://packagist.org/packages/boris/imgscrape)[ RSS](/packages/boris-imgscrape/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (4)Versions (13)Used By (0)

\#Installation

Install via composer:

```
require: {
    "boris/imgscrape": "0.*"
}

```

\#Usage

Please check the index.php file supplied for a working example.

In essence you initialize the scraper by doing:

```
$scraper = new Boris\ImgScraper\Scraper($client, $logger, $configArray);

```

Here the $client object is a Guzzle client instance and the $logger is located in the same namespace as the scraper.

To get the source of the largest image on any URL:

```
$scraper->getLargestImageUrl($url);

```

The script issues a head request first. If the 'imageLinksOnly' parameter is set to true, if the response does not contain a 'Content-Type' header or if that header is not of an image type, it returns null. Otherwise, it just returns the same URL (this functionality is useful if you have a huge array of URLs and you want to get only the direct image URLs).

\###Symfony

To use this component in Symfony, please register it as a service:

```
parameters:
  boris.scraper: ~
  boris.logger: ~
  guzzle.params:
    base_url: http://www.reddit.com

services:
    boris.logger:
      class: Boris\ImgScrape\Logger
      arguments: [%boris.logger%]

    boris.imgscrape:
      class: Boris\ImgScrape\Scraper
      arguments: [@guzzle.client, @boris.logger, %boris.scraper%]

    guzzle.client:
      class: GuzzleHttp\Client
      arguments: [%guzzle.params%]

```

You can then call this from the container:

```
$this->container->get('boris.imgscrape');

```

\#Parameter Reference

There is a default set of parameters that can be overridden when initializing the scraper and logger combo:

```
$config = [
    'imageLinksOnly' => false,
    'acceptedTypes' => [
        'jpeg',
        'jpg',
        'gif',
        'png',
    ],
    'blacklist' => [
        'www.reddit.com'
    ],
    'user-agent' => 'Boris-ImgScrape/0.2 (amateur script, contact: my at email dot com)'
];

$configLogger = [
    'enabled' => true,
    'handlers' => [
        [
            'dir' => __DIR__ . '/../../../../log/debug.log',
            'level' => 'debug'
        ],
        [
            'dir' => __DIR__ . '/../../../../log/main.log',
            'level' => 'info'
        ],
    ]
];

```

These can be used as your %scraper% parameters value and you only need to override what you need. Here is a reference on what each parameter means:

```
scraper:
    imageLinksOnly: only returns the URL if the supplied URL is for and image
    acceptedTypes: accepted image mime types
    blacklist: which hostnames to ignore
    user-agent: your useragent string

logger:
    enabled: whether or not to enable the logger
    handlers: an array for each logger handler. Supply the dir and the level of the logger (this component uses Monolog, so you can check the default documentation for levels)

```

\#Tests

In order for tests to run, you need to include the following dependencies in your project for composer to install:

```
require-dev: {
    "mockery/mockery": "0.9.*@dev",
    "phpunit/phpunit": "4.7.*@dev"
}

```

To run tests, navigate to the root directory of the project and run:

```
phpunit --group=BorisImgScrape

```

\#Logs

By default, Monolog creates a log file with the level specified in the 'handlers' parameter of the logger config. You can use DEBUG, but keep in mind the logs get quite big.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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

Every ~2 days

Total

10

Last Release

4147d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6319036?v=4)[borispavlov0](/maintainers/borispavlov0)[@borispavlov0](https://github.com/borispavlov0)

---

Top Contributors

[![bulletdodger-boris](https://avatars.githubusercontent.com/u/218610011?v=4)](https://github.com/bulletdodger-boris "bulletdodger-boris (28 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/boris-imgscrape/health.svg)

```
[![Health](https://phpackages.com/badges/boris-imgscrape/health.svg)](https://phpackages.com/packages/boris-imgscrape)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k543.8M20.1k](/packages/laravel-framework)[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[google/cloud-core

Google Cloud PHP shared dependency, providing functionality useful to all components.

346132.9M112](/packages/google-cloud-core)[pantheon-systems/terminus

A command line interface for Pantheon

3391.5M18](/packages/pantheon-systems-terminus)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M574](/packages/shopware-core)

PHPackages © 2026

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