I'm having trouble resizing an image to a specific width, I can only resize proportionally according to width or height.
I can only:
<?php
$original_width = x;
$original_height = y;
$redimensionar = 200;
// Novos valores
$width = 0;
$height = 0;
if ($original_width > $original_height) {
$ratio = ($redimensionar / $original_width);
}
else {
$ratio = ($redimensionar / $original_height);
}
$width = ($original_width * $ratio);
$height = ($original_height * $ratio);
The problem with this is that the image may be 200 wide or tall, what I have to do and I can not do is leave the width always with 200 and the proportional height.
[EDITED]
When I made a code to always resize with a width of 200, the ratio calculation was upside down, so I was working with just this one up.