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

New Collage Layout #164

Closed
KH404 opened this issue Oct 24, 2019 · 9 comments · Fixed by andi34/photobooth#108
Closed

New Collage Layout #164

KH404 opened this issue Oct 24, 2019 · 9 comments · Fixed by andi34/photobooth#108

Comments

@KH404
Copy link

KH404 commented Oct 24, 2019

Is your feature request related to a problem? Please describe.
On my own wedding we had a photobooth which had a 2x4 layout for the collage function. We likes the layout, because with one print you had the pictures twice. The print was cut in half, so you had two picture stripes. One was for the guest book and the other for the guests.

Describe the solution you'd like
On my local code I implemented the layout for an older version. I am not into php, so it is not coded in a good way. It worked but the performance was bad. Unfortunately the code files are not matching with the new code structure so I attached the code parts which I implemented for the previous release. Maybe you can take it, improve it and add it as a new feature.

Describe alternatives you've considered
If you do not like it, you can also omit the layout.

Example_of_the_new_layout

config.inc.php
$config['collage_layout'] = '2x2'; // possible layouts are 2x2 and 2x4 (row x column)

index.php
'collage_layout' => [ 'type' => 'select', 'name' => 'collage_layout', 'placeholder' => 'collage_layout', 'options' => [ '2x2' => '2x2', '2x4' => '2x4', ], 'value' => $config['collage_layout'] ]

takePic.php

switch($layout) {
	case '2x2':
		// make collage
		list($width, $height) = getimagesize($collagePhoto[0]);
		$my_collage_height = $height * 2;
		$my_collage_width = $width * 2;
		$my_collage = imagecreatetruecolor($my_collage_width, $my_collage_height)
				or die("Kann keinen neuen GD-Bild-Stream erzeugen");
		$background = imagecolorallocate($my_collage, 0, 0, 0);
		imagecolortransparent($my_collage, $background);
		$collage_pic1 = imagecreatefromjpeg($collagePhoto[0]) or die("no imagcreate");
		imagecopy($my_collage, $collage_pic1, 0, 0, 0, 0, $width, $height);
		$collage_pic2 = imagecreatefromjpeg($collagePhoto[1]) or die("no imagcreate");
		imagecopy($my_collage, $collage_pic2, $width, 0, 0, 0, $width, $height);
		$collage_pic3 = imagecreatefromjpeg($collagePhoto[2]) or die("no imagcreate");
		imagecopy($my_collage, $collage_pic3, 0, $height, 0, 0, $width, $height);
		$collage_pic4 = imagecreatefromjpeg($collagePhoto[3]) or die("no imagcreate");
		imagecopy($my_collage, $collage_pic4, $width, $height, 0, 0, $width, $height);
		break;
	case '2x4':
		// make collage
		$degrees = -90;

		list($width, $height) = getimagesize($collagePhoto[0]);
		shell_exec(sprintf('convert %s -rotate %s %s',$collagePhoto[0],$degrees,$collagePhoto[0]));
		shell_exec(sprintf('convert %s -rotate %s %s',$collagePhoto[1],$degrees,$collagePhoto[1]));
		shell_exec(sprintf('convert %s -rotate %s %s',$collagePhoto[2],$degrees,$collagePhoto[2]));
		shell_exec(sprintf('convert %s -rotate %s %s',$collagePhoto[3],$degrees,$collagePhoto[3]));
		list($width_rotate, $height_rotate) = getimagesize($collagePhoto[0]);
		$my_collage_height = $height * 3.3;
		$my_collage_width = $width * 3.3;
		$height_offset = ((($my_collage_height/2)-$height_rotate)/2);
		$width_offset = (($my_collage_width-($width_rotate*4))/5);
		$my_collage = imagecreatetruecolor($my_collage_width,$my_collage_height) or die("Kann keinen neuen GD-Bild-Stream erzeugen");
		$background = imagecolorallocate($my_collage, 240, 240, 240);
		imagefill($my_collage,0,0,$background);
		$collage_pic1 = imagecreatefromjpeg($collagePhoto[0]) or die("no imagcreate");
		imagecopy( $my_collage, $collage_pic1,$width_offset,$height_offset,0,0,$width_rotate,$height_rotate); // Bild 1 oben
		imagecopy( $my_collage, $collage_pic1,$width_offset,($height_rotate+(3*$height_offset)),0,0,$width_rotate,$height_rotate); // Bild 1 unten
		$collage_pic2 = imagecreatefromjpeg($collagePhoto[1]) or die("no imagcreate");
		imagecopy ( $my_collage, $collage_pic2,($width_offset*2+$width_rotate),$height_offset,0,0,$width_rotate,$height_rotate); // Bild 2 oben
		imagecopy ( $my_collage, $collage_pic2,($width_offset*2+$width_rotate),($height_rotate+(3*$height_offset)),0,0,$width_rotate,$height_rotate); // Bild 2 unten
		$collage_pic3 = imagecreatefromjpeg($collagePhoto[2]) or die("no imagcreate");
		imagecopy ( $my_collage, $collage_pic3,($width_offset*3+2*$width_rotate),$height_offset,0,0,$width_rotate,$height_rotate); // Bild 3 oben
		imagecopy ( $my_collage, $collage_pic3,($width_offset*3+2*$width_rotate),($height_rotate+(3*$height_offset)),0,0,$width_rotate,$height_rotate); // Bild 3 unten
		$collage_pic4 = imagecreatefromjpeg($collagePhoto[3]) or die("no imagcreate");
		imagecopy ( $my_collage, $collage_pic4,($width_offset*4+3*$width_rotate),$height_offset,0,0,$width_rotate,$height_rotate); // Bild 4 oben
		imagecopy ( $my_collage, $collage_pic4,($width_offset*4+3*$width_rotate),($height_rotate+(3*$height_offset)),0,0,$width_rotate,$height_rotate); // Bild 4 unten
		break;
	default:
		break;
}
@andi34
Copy link
Collaborator

andi34 commented Oct 24, 2019

convert command needs imagemagick, right?

@KH404
Copy link
Author

KH404 commented Oct 24, 2019

Yeah that's right. I tested it in the cmd and when it worked, for me it was the easiest way to make an "shell_exec". But I assume there is a way better solution xD

@andi34
Copy link
Collaborator

andi34 commented Oct 24, 2019

Imagemagick doesn't seem to perform that well on the Pi, quite resource hungry compared with GD.

@andi34
Copy link
Collaborator

andi34 commented Oct 28, 2019

https://www.php.net/manual/de/function.imagerotate.php
should be reworked to use the GD way.

Parts to modify:

  • config/config.inc.php
  • lib/collage.php
  • lib/configsetup.inc.php
  • resources/lang/*.js

@sualko
Copy link
Collaborator

sualko commented Oct 30, 2019

@KH404 would be nice if you could create a pr. As mentioned by @andi34 we want to use only gd at the moment and there are some other parts which needs some modifications. For example you have to take 8 pics now and not only 4.

@KH404
Copy link
Author

KH404 commented Oct 31, 2019

Unfortunately for me it is not possible to do these changes. Right now I do not have the time for, because I am going to be a father in the next few days. Maybe I will find the time when the baby won't let me sleep ;)

P.s.: There is no need to take 8 pictures.The four pictures on the left are the same then the four on the right. So if you cut it in half, both stripes are equal. One for the guest and one for e.g. the guest book.

grafik

@sualko
Copy link
Collaborator

sualko commented Oct 31, 2019

Unfortunately for me it is not possible to do these changes.

That's ok. I thing it's a nice feature, but not urgent.

Right now I do not have the time for, because I am going to be a father in the next few days.

Congratulations 👏

@andi34
Copy link
Collaborator

andi34 commented Sep 19, 2020

Reopen as not applied here.

@andi34 andi34 reopened this Sep 19, 2020
@andi34
Copy link
Collaborator

andi34 commented Oct 4, 2022

Photobooth v4 includes the new layout
https://photoboothproject.github.io/Changelog

@andi34 andi34 closed this as completed Oct 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants