Skip to content

Instantly share code, notes, and snippets.

@tarikmanoar
Created March 20, 2024 08:50
Show Gist options
  • Save tarikmanoar/1799278d6ca3edc4da7f4b88f9afcad8 to your computer and use it in GitHub Desktop.
Save tarikmanoar/1799278d6ca3edc4da7f4b88f9afcad8 to your computer and use it in GitHub Desktop.
Inserting Images (Like prothomalo.com)
Install Latest "intervention/image": "3.5.0",
composer require intervention/image 3.5.0
Route::get('image', function () {
$client = new Client();
$source = $client->get('https://picsum.photos/728/410');
$overly = $client->get('https://picsum.photos/728/45');
$source = $source->getBody()->getContents();
$overly = $overly->getBody()->getContents();
$manager = ImageManager::gd();
$image = $manager->read($source);
$img = $image->place($overly, 'bottom');
return response($img->encodeByExtension('png'), 200)->header('Content-Type', 'image/jpeg');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment