Skip to content

Instantly share code, notes, and snippets.

@mariapaulinar
Created January 12, 2018 17:44
Show Gist options
  • Save mariapaulinar/72c69d9463562647fa65499294c7589f to your computer and use it in GitHub Desktop.
Save mariapaulinar/72c69d9463562647fa65499294c7589f to your computer and use it in GitHub Desktop.
Crear imagen a partir de otras imágenes con Intervention Image (Laravel)
<?php
$imagenes = array('foto1.jpg', 'foto2.jpg');
$i = 0;
$img_canvas = Image::canvas(1800, 1800);
foreach($imagenes as $img) {
if($img) {
$path = public_path($img);
switch($i) {
case 0:
$img_canvas->insert($path, 'left');
break;
case 1:
$img_canvas->insert($path, 'right');
break;
}
}
$i++;
}
$img_canvas->save(public_path('image_merged.jpg'), 100);
$img = Image::make(public_path('image_merged.jpg'));
$img->resize(900, null, function ($constraint) {
$constraint->aspectRatio();
})->save(public_path('image_merged.jpg'), 100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment