note 41719 deleted from function.imagecopyresized by aidan
| From: | aidan@php.net | Date: | Mon, 04 Oct 2004 09:31:16 +0000 |
| Subject: | note 41719 deleted from function.imagecopyresized by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-77899@lists.php.net to get a copy of this message | ||
Note Submitter: dank at no spam dot org
----
I recently had to go back and take a look at creating a thumbnail from an uploaded image in a fairly
restricted hosting environment. I created the below as a butt-easy example of how to do that.
Thinking it was fairly newbie friendly, Im posting it here
For newbies: Create a directory with full read, write and exec permissions. Upload the below file
and a 200x200 jpeg called girl.jpg to that directory. Then hit the script in a browser. Ive
used as few variables as possible, so lookup individual functions for their usage. Kapla!
<?php
error_reporting (E_ALL);
$abc = imagecreatefromjpeg("girl.jpg");
$def = imagecreate(20, 20);
imagecopyresized($def, $abc, 0, 0, 0, 0, 20, 20, 200, 200);
imagejpeg($def, 'new_girl_thumb.jpg', 95);
ImageDestroy($abc);
ImageDestroy($def);
print "<HTML><HEAD><TITLE>test</TITLE></HEAD><BODY>
original:<hr><img
src=\"girl.jpg\"><br><br><br>new:<hr><img
src=\"new_girl_thumb.jpg\"></BODY></HTML>";
?>