I use PHP
to be able to render images in a certain system.
I need the photos to contain the ratio of 3x4.
The system works like this:
1 - The user takes the photo from the webcam.
2 - An ajax is sent to PHP to process this image.
3 - The image is resized to 3x4
, but the default height should be 478
.
I need to know how I can know the width that I have to define for this image when I resize it, and I only have the time, because I do not want to be putting fixed numbers, I want to leave the calculation ready, that if I change the height, the width is dynamically adjusted.
What is the calculation that I should use in PHP to know the width of a 3x4 photo, based only on height?
The code I currently have is this:
class Solicitacao {
const IMAGE_HEIGHT = 478;
}
In creating the image, I do so:
$imageString = base64_decode(Input::get('file'));
Gregwar\Image\Image::fromData($imageString)
->resize($largura_dinamica_aqui, Solicitacao::IMAGE_HEIGHT)
->save('temp.png', 'png');