sattorbek/photolab

A PHP wrapper for applying photo effects using photolab.me (scraping interface)

1.0.0 2025-05-17 08:31 UTC

This package is auto-updated.

Last update: 2025-05-17 08:31:58 UTC


README

A simple PHP library to apply cool photo effects using photolab.me, via web scraping.

⚠️ This is not an official API. It mimics browser behavior to upload and apply effects to photos.

📦 Installation

composer require sattorbek/photolab

Requires PHP 8.0+ and ext-curl.

🚀 Quick Example

<?php

require_once __DIR__ . '/vendor/autoload.php';

print "Uploading image...\n";
$image = new Photolab\Upload\Path();
$tmp = $image->upload(new \CURLFile("./image.jpg")->getFilename());

print "Applying combo...\n";
$combo = new Photolab\Apply\Combo();
$applied = $combo->apply($tmp, 46492400); // Example effect ID

print "Parsing response...\n";
$parse = new Photolab\Parse\Response();
$image = $parse->parse($applied) . PHP_EOL;

echo $image;

🧰 Upload Methods

You can upload your image in different ways using any of the following classes:

  • Photolab\Upload\Path – Local file path
  • Photolab\Upload\File – CURLFile object
  • Photolab\Upload\Url – Remote image URL
  • Photolab\Upload\Base64 – Base64 encoded string

Example:

$uploader = new Photolab\Upload\Url();
$tmp = $uploader->upload('https://example.com/image.jpg');

🎨 Applying Effects

To apply an effect:

  1. Find an effect on https://photolab.me

  2. Extract the effect ID from the URL.
    Example:
    URL: https://photolab.me/d/46303100
    → Doc ID: 46303100

  3. Use the apply() method:

$combo = new Photolab\Apply\Combo();
$result = $combo->apply($tmpImage, 46303100);

📤 Getting Final Result

After applying the effect, use Photolab\Parse\Response to extract the final image URL:

$parser = new Photolab\Parse\Response();
$imageUrl = $parser->parse($result);

You can now download or use this image as needed.

🌍 Using Proxy (Optional)

You can optionally pass a proxy URL to each class constructor:

$proxy = 'http://127.0.0.1:8080'; // Optional proxy

Update each usage like this:

$image = new Photolab\Upload\Path($proxy);
$tmp = $image->upload(new \CURLFile("./image.jpg")->getFilename());

$combo = new Photolab\Apply\Combo($proxy);
$applied = $combo->apply($tmp, 46492400);

$parse = new Photolab\Parse\Response($proxy);
$image = $parse->parse($applied);

All classes support $proxy as an optional constructor argument.

🪪 License

MIT License

🙋‍♂️ Author

Built by Sattorbek
Questions or ideas? PRs and issues are welcome!