Jump to content

Making thumbnails.


shadowayex

Recommended Posts

Well, I built a file uploading system for the website I'm building (the final version of the upload system is still to be decided on, but it's far enough along I need to implement this feature). I have it so when the file is uploaded, the owner, the file name, the file type, and many other things are put into a database. I do a lot of databasing to run my site FYI. Anyways, only JPEG, GIF, and PNG files are allowed right now, but as soon as I discover the why it won't work, MPEG, WMV, and AVI video formats will be allowed as well.I was wanting to build a system so a loop would look through the database and grab all the files uploaded by the user in question. It's simple enough, get the file name and file type from the database, search in the upload directory for the matching file, then grab it. I can do that. But I want to make thumbnails so that full sized images weren't being displayed and the actual videos aren't loading right away. I basically figured out a way to do that with pictures. I would just display the image in a scaled version using the img tag and CSS.My problems comes with the videos. How do I create a thumbnail image for a video without actually having to make one myself and place it in the files? I figured PHP would be able to do this. Or JavaScript maybe. I would prefer to use either those or a CSS method if possible, because those are the ones that power my website and the only resources at my disposal at this time. If there a function?

Link to comment
Share on other sites

I doubt there's *a* function to get an arbitrary frame from a movie file, but there's probably a way to do it. Even it if means reading the binary data and figuring out what's what yourself. If it's an mpeg then it's essentially a bunch of jpegs, so if you get the binary data for one frame you might be able to use imagecreatefromstring to create an image of it. I haven't looked into working with video much so I'm not sure what's available.

I would just display the image in a scaled version using the img tag and CSS.
That's still using the full filesize, they still have to download the full version. If you want to save bandwidth and time you could write a script to produce a thumbnail of a given image. e.g.<img src="thumb.php?img=image1.jpg&w=200&h=100">
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...