1
Use the PHP
to be able to process images in a given system.
I need the photos to contain the 3x4 ratio.
That’s how the system works:
1 - User takes webcam photo.
2 - An ajax is sent to PHP to process this image.
3 - The image is resized to 3x4
, but the standard height should be 478
.
I need to know how I can know which width I have to set for that image when I resize it, and I only have the height, because I don’t want to keep putting fixed numbers, I want to get the calculation ready, so that if I change the height, the width is dynamically adjusted.
Which calculation should I use in PHP to know what is 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');
You swear you’ll ask that question?
– Maniero
@Wallace, we have to do it differently, the way this will have horizontally compressed images so we lose the ratio, I suggest you change your question and make an image-cutting system, where the user can choose the rectangle in the 3x4 ratio of the part of the image he wants to save, more or less like Instagram does, but in your case in a rectangle, and not square.
– David
@bigown just wanted to see if they would complicate or simplify.
– Wallace Maxters
@bigown already asked the question, kkkkk
– Wallace Maxters