Jump to content

Preview Uploaded Files


FishSword

Recommended Posts

Hiya,

 

I’m currently working on a website that will enable users to upload certain types of files.

Upon the file(s) being uploaded, I need to generate a preview of the file(s) content, in image format.

 

Some of the files I need to upload and generate a preview of include, but are not limited to: .doc(x), .jpg, .ppt(x), .xls(x), .html, .psd.

 

Can this be done with PHP?

 

Any help is greatly appreciated.

If you have any queries, please let me know.

 

Many Thanks,

 

FishSword

Link to comment
Share on other sites

Hi Fugix,

 

Thanks for your reply.

 

I think you may have got confused when I said that I need to display the contents of a file in image format.

I don't want to display the code/text that makes up the file as an image, but instead show the actual content that the code represents, as an image.

 

For example, if somebody uploaded a Microsoft Word file containing a letter addressed to somebody, then the preview that should be generated, would be of the letter.

I have attached a screenshot showing the preview generated for a file when a file has been selected in Windows Explorer. I am after a preview of a file, similar to this.

 

I appreciate your help ;)

 

Many Thanks,

 

FishSword

 

[attachment deleted by admin]

Link to comment
Share on other sites

Hey FishSword,

  There are libraries out there that can do some of the files you're talking about but not all, and of course there is an issue with versions of those files and the many formats over the years when you're talking about the microsoft suite.  I know some things about doing this, and I can tell you that it is not a trivial task, and very much related to the operating system of the machine(s) used to render the thumbnail image.

 

Here's a couple approaches you can consider:

 

-Based on the extension of the file, load a program that can process the native file format.  Then print that to pdf and use imagemagick or some other program that can convert .pdf's to images.  Then resize to thumbnail.

-Based on the extension of the file, load a program that can process the native file format and put the application into full screen mode, then call an operating system macro that can capture the framebuffer/printscreen the page to an image, and then thumbnail the image.

 

 

 

 

Link to comment
Share on other sites

Hi Gizmola,

 

Thanks for your reply.

 

When you say program, would this need to be a program that is installed within the operating system?

Would it not be possible to achieve this using PHP, or through the development of a library file, that could be plugged into to PHP?

 

My aim is to take screenshots of the files, and save these screenshots in image format.

 

Thanks for your help so far, its a very interesting topic.

 

Many Thanks,

 

FishSword

Link to comment
Share on other sites

Yes you literally need at least one program that can handle every file format you're talking about, and be able to render them.  For a lot of the image files, there are libraries that will let you load and manipulate them, but for word docs, excel spreadsheets and powerpoints.  If your focus is these microsoft application formats, then a windows machine has a lot of advantages due to the windows os technologies used.  I have my doubts about being able to prtscrn everything, but you definately can have a custom print driver installed like the one that comes with adobe pdf. 

Link to comment
Share on other sites

Hi Gizmola,

 

Thanks for your reply.

 

I would prefer to use Apache server to host the site, on a Linux machine.

I've heard that it is possible to develop extensions for PHP. How easy would it be to build such an extension that would generate preview images of files, and can this be done?

 

Many Thanks,

 

FishSword

Link to comment
Share on other sites

If you know C very well you can probably develop a php extension.  Being on linux, I'd take a look at open office which is written in java, and see if that might not make a good basis for a lot of this system, since open office can load in a lot of the microsoft files.

Link to comment
Share on other sites

I would say that loading, rendering and saving rendered output to some sort of image file that reflects what a print view of excel, word and powerpoint documents is what I would consider a "non-trivial" task to say the least.  Anything is "possible", but I don't know of any open source libraries you could use other than open office.  It is conceptually possible to call java routines using the java bridge, but I have no idea if that's a viable path.  Hopefully I've provided you a few ideas to explore. 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.