Thumbs

Soldato
Joined
26 Dec 2003
Posts
16,520
Location
London
I quite often want to upload some images and then post them on a forum or other medium along with thumbnails. After a while manually generating the thumbnails and manually typing out/copy-paste-alter-ung the URLs gets really annoying, and I typically don't want them in a Gallery so that's out too.

So, I wrote this quick and (very) dirty PHP script. Upload it to the same directory as your images, open it in your browser and Robert's your mother's brother:



(Default is 250x250 with aspect ratio maintained; you can optionally pass `width` and `height` parameters in the URL to have a custom width.)

Hope someone finds it useful!

Download

The smallprint:

You should probably delete the thumbs.php file once you're done, so that people don't generate new thumbs! Use at your own risk don't blame me if it sets of a thermonuclear reaction in your photographs etc.!
 
Last edited:
I have my own hosted image hosting service, designed specifically for OcUK users, at http://ocuk.doesntexist.com.
You can login and view your images etc and you get a static link pointing to your image. When you upload an image it even generates the line for you :)

nice little script there though!
 
Just had a look at this, looks pretty cool, gonna have to try it out next time I'm posting images.

Out of interest, what is the advantage of determining the image type by extension instead of mime-type? (see thread I just posted for confession of noobery).

Thanks, null :)
 
null said:
Out of interest, what is the advantage of determining the image type by extension instead of mime-type? (see thread I just posted for confession of noobery).
Just what I was wondering :/
 
Last edited:
Maybe it uses less CPU power? and if it is already an image there is no need to check that its a valid image or not?

Just a thought.


Nice script btw :)
 
It's a minor point really but there's always the possibility of the file extension being wrong - perhaps it's .jpg and actually not a picture, in which case it shouldn't be processed, or it's .jpg and actually a PNG image but would be processed as .jpg. Just seems more 'proper' checking mime types that's all. I'm sure rob has a good reason...

/waits
 
Well no not really, because YOU would have already uploaded the images, (so he would be assuming that the images are all correct with the correct extensions) and you would just be making it hard no yourself if you renamed it with the wrong extension.

If it was an uploading script, then the story would be different and he would check the MIME type.


EDIT:

Despite what it looks like, i am not talking on behalf of rob, just expression an opinion :)
 
Last edited:
The problem with determining via mime-type is that not everyone has the mime-type functionality built in—XAMPP doesn't, since I don't have it on my local machine. Determining via extension was just a dirty hack to get things working for me.

While there might be security issues when allowing the public to upload files, for example, that's not an issue here; the exploit, if any, requires FTP or shell access—and if someone has that then there's far worse things they can do.
 
Back
Top Bottom