Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Join two images #376

Closed
huglester opened this issue Jun 4, 2015 · 3 comments
Closed

Join two images #376

huglester opened this issue Jun 4, 2015 · 3 comments

Comments

@huglester
Copy link

Hello,

is there a way to join two images? i.e. horizontally or vertically?

say I have two images 50x100.
If I join them horizontaly, I get 50x200 size
if I join them vertically - I would get: 100x100 size

Thanks!

@olivervogel
Copy link
Member

Not out of the box and automatically. But I think it would be easy to achieve this with canvas(), insert(), width() and height(). Ideally you wrap it in a custom filter at the end.

@huglester
Copy link
Author

hello @olivervogel

Thanks for the idea. Did not think about this. Firstly I tried:

$img_canvas = Image::canvas(200, 100);
$img_canvas->fill(Image::make('img/color.jpg'), 0, 0);
$img_canvas->fill(Image::make('img/grey.jpg'), 100, 0); // add offset
$img_canvas->save('img/canvas.png', 100);

But it was adding same (color) picture over and over.

Using insert:

$img_canvas = Image::canvas(200, 100);
$img_canvas->insert(Image::make('img/color.jpg'));
$img_canvas->insert(Image::make('img/grey.jpg'), 'top-right'); // add offset
$img_canvas->save('img/canvas_horizontal.png', 100);

$img_canvas = Image::canvas(100, 200);
$img_canvas->insert(Image::make('img/color.jpg'));
$img_canvas->insert(Image::make('img/grey.jpg'), 'bottom-left'); // add offset
$img_canvas->save('img/canvas_vertical.png', 100);

I basicly can achieve what I wanted :)
I will try creating a filter maybe, which would accept two images and 'join type', or something like that.

We will see If I will manage it. So far very 'eloquent-like' lib :)

Thanks!

@olivervogel
Copy link
Member

It's also possible to insert directly, without creating a new image instance.

$img_canvas = Image::canvas(200, 100);
$img_canvas->insert('img/color.jpg');
$img_canvas->insert('img/grey.jpg', 'top-right'); // add offset
$img_canvas->save('img/canvas_horizontal.png', 100);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants