note 112764 added to function.imagecopyresampled
| From: | wbcarts at juno dot com | Date: | Sat, 20 Jul 2013 19:59:01 +0000 |
| Subject: | note 112764 added to function.imagecopyresampled | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-195690@lists.php.net to get a copy of this message | ||
FOUR RECTANGLES -- The Tools to Use this Function Creatively
A rectangle is not an image, but every image has a Rectangled boundary with x=0 and y=0. The width
and height are obtained with the getimagesize function.
Because this function allows subimage areas to be defined, there are actually four rectangled areas
that we need to be aware of.
* R1 -- Source Image Boundaries
* R2 -- Source Copy Area Boundaries
* R3 -- Destination Image Boundaries
* R4 -- Destination Resampled Placement Area Boundaries
+-----------------------+ +-----------------+
| R1 | | R3 |
| | | |
| +------------+ | | |
| | | | | |
| | | | | +------+ |
| | R2 | | | | | |
| | | | | | R4 | |
| | | | | | | |
| | | | | +------+ |
| +------------+ | | |
| | +-----------------+
| |
+-----------------------+
R1 contains all of the original pixel data. If R2 goes outside of R1 in any direction, then R2 will
contain stuff that doesn't help. A lot of the time R2 == R1 exactly.
R3 defines the area that holds the resampled image data. If R4 goes outside of R3 in any direction,
then the resampled image data in R4 will be clipped by R3. In other words, R3 has the final say as
to which of R4's pixels will be included in the final image. Most of the time, R4 == R3.
In the end, R2 (and the pixels in it) will be strecthed, squeezed, and placed exactly over R4.
There are plenty of good examples on this page to create thumbnails etc. But what if R3 was not
destined to be a thumbnail? What if we wanted to take the entire R1 image and shrink it to fit
inside R2 for example, leaving the original picture as a border? With the knowledge we have just
gained it is a simple matter of creating the Source & Destination Images from the same .jpg
file, then R2 should be equal to R1, and R4 should be smaller and completely inside R3.
When we think of these rectangles as tools and not images, it becomes easier to see what's
going on.
----
Server IP: 69.147.83.199
Probable Submitter: 69.85.145.136
----
Manual Page -- http://php.net/manual/en/function.imagecopyresampled.php
Edit -- https://master.php.net/note/edit/112764
Del: integrated -- https://master.php.net/note/delete/112764/integrated
Del: useless -- https://master.php.net/note/delete/112764/useless
Del: bad code -- https://master.php.net/note/delete/112764/bad+code
Del: spam -- https://master.php.net/note/delete/112764/spam
Del: non-english -- https://master.php.net/note/delete/112764/non-english
Del: in docs -- https://master.php.net/note/delete/112764/in+docs
Del: other reasons-- https://master.php.net/note/delete/112764
Reject -- https://master.php.net/note/reject/112764
Search -- https://master.php.net/manage/user-notes.php