Created
January 12, 2018 17:44
-
-
Save mariapaulinar/72c69d9463562647fa65499294c7589f to your computer and use it in GitHub Desktop.
Crear imagen a partir de otras imágenes con Intervention Image (Laravel)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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