note 79173 deleted from ref.image by tularis
| From: | tularis@php.net | Date: | Sun, 29 Jun 2008 20:59:56 +0000 |
| Subject: | note 79173 deleted from ref.image by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-140911@lists.php.net to get a copy of this message | ||
Note Submitter: kangaroo232002 at yahoo dot co dot uk
----
I have noticed that some functions use quite complicated resizing code, however if you want to
specify just one dimension (e.g. resizing an image for a catalogue or social network etc) then you
can do it my just getting the percentage reduction of one dimension of the image and applying it to
the other, like so:
<?php
$new_width = 150;
//assuming you have already used imageSX(), imageSY() to get the dimensions.
$percentage_reduction = ($new_width / $old_width) * 100;
$new_height = ($old_height / 100) * $percentage_reduction;
?>
This means that images will not be stretched, but will be neater as they are the same width (e.g.
facebook).