Hi,
What you're looking for is pretty simple to construct.
To determine the file size and possibly reject (reports file size in bytes):
filesize($filename)
To check file types (you can use a switch statement for multiple file types):
mime_content_type('php.gif')
There's a few PHP classes to resize images on the fly (in this case when its uploaded). Check PHPClasses
As for the 2px black border, is this for presentation purposes? If so, its best to do this with CSS style applied to the image. This way you can change it later if necessary and it doesn't add additional bytes to the images.
Have it secure? You could create a basic user authentication using sessions or cookies (sessions are better). Not sure how your handling this though.
Before or after completing the above, just use:
bool move_uploaded_file ( string filename, string destination )
to move the file and rename it at the same time. Though you will need to indicate the path and new file name in the destination. I typically use something like:
$new_filename = uniqid("img-");
this creates a new filename with the prefix "img-" (or whatever you want).
uniqid() returns a prefixed unique identifier based on the current time in microseconds. prefix is optional but can be useful, for instance, if you generate identifiers simultaneously on several hosts that might happen to generate the identifier at the same microsecond. Up until PHP 4.3.1, prefix could only be a maximum of 114 characters long.
It's so much easier to perhaps write your own routine, then to rework someone else's logic. Because by the time you're done, you know what it should do and can extend it as you see fit.
Best,
Cent