sattorbek / photolab
A PHP wrapper for applying photo effects using photolab.me (scraping interface)
Requires
- php: >=7.4
- guzzlehttp/guzzle: ^7.9
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 pathPhotolab\Upload\File
– CURLFile objectPhotolab\Upload\Url
– Remote image URLPhotolab\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:
-
Find an effect on https://photolab.me
-
Extract the effect ID from the URL.
Example:
URL:https://photolab.me/d/46303100
→ Doc ID:46303100
-
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!