PHP: Display Adobe PSD files on a web page

by Jean. 36 Comments -

Any webdesigner know the PSD filetype, which is the Adobe Photoshop format. PSDs have a lot of great features, as such as layers, but they can’t being read by a browser. Unless you use this great PHP class!

The classPhpPsdReader.php Class

The classPhpPsdReader.php Class was created by Tim de Koning in 2007. It is based on the GD library, which can do numerous operations on images with PHP, but sadly, can’t open PSD files.

The classPhpPsdReader.php Class can be downloaded for free on PhpClasses.org. It is compatible with both PHP4 and PHP5.

Usage

Nothing hard here. Once you have downloaded the classPhpPsdReader.php class and uploaded it on your server, you’re now ready to display PSD throught a web browser.
To do so, just refer to the following code example:

<?php
// Send header to client browser
header("Content-type: image/jpeg");
// Includes the requested class
include_once('classPhpPsdReader.php');
// Finally display the PSD on the screen
imagejpeg(imagecreatefrompsd('yourPsdFile.psd'));
?>

The result

Reading psd files with php
Great tool for people who are, like me, both webdevelopers and webdesigners!

On another note, I just purchased a new blog to complete my network. The blog is called PsdVibe and you can have a look here. The blog focus on providing Adobe Photoshop tutorials, resources and freebies.

Comments (36) - Leave yours

  1. Kotlina Klodzka said:

    PSD files are huge. This might be a nice idea for smaller files but I had projects as big as 10-20 mb. I wouldn’t like to display that on a page and make people load for like 10 minutes.

  2. Отобразить PSD файл при помощи PHP | Alex Volkov said:

    [...] <?php // Send header to client browser header(“Content-type: image/jpeg”); // Includes the requested class include_once(‘classPhpPsdReader.php’); // Finally display the PSD on the screen imagejpeg(imagecreatefrompsd(‘yourPsdFile.psd’)); ?> Написал кот, который кодит [...]

  3. Catrin W said:

    Well, i hear for first time for such a code. It is really interesting, and i am surely that it has some use for web designs or some other purposes.
    Anyway, congrats on the psd site purchase. If i am not wrong that is second site about photoshop tutorials that you own ? The first one is psdrecipes..

  4. diggita.it said:

    PHP: Mostrare file photoshop in una pagina web…

    Fin’ora eravate abituati con le gif, jpeg o al massimo png, ma se volete potete usare direttamente i vostri capolavori fatti con photoshop nelle vostre pagine web dinamiche, grazie alla magia delle funzioni del php, il linguaggio open source, che oram…

  5. Brad M said:

    While this is a handy feature and the concept has been around for while… it only does come down to the one simple use… to quickly display PSD files… It is not ideal or recommended to be used in normal web development.

    Having a personal blog, progress reports and so on it can be applied to.. As for the people thinking this will slow the site to load a 20mb file… NO… your not downloading the whole file to the user nor does the user ever get the PSD file… You are simply creating a render from it… imagine like a database that is 100′s of mb in size and your searching and displaying from that file…. The server handles the actual load, the client receives the final output from the server. in this case a flat single layer image.

    While this will be handy for some and not others… weight up the pros and cons… if you do not want a massive server load, then i would suggest simply using pngs/jpgs…

    If you have a small low traffic blog site or host your own images and designs. this will be for you.

    if you have clients who login to an area where they access a progress report of art design, then this is for you.

    *** One suggestion if it does already not have the option… CACHE!… let it create the image once as a jpg/png then if the image is available. load that instead… So simply a web based PSD->Flat Image…

  6. Keith said:

    I have tried this and it has not worked – had error 500 internal server error!
    I am no coder but the server is mine – including the hardware and it runs 30 websites in all sorts of formats including php/mysql which runs all sorts of php like joomla with no errors and other systems.

    can anyone let me know if there is alternative version of the reader file I downloaded as its not working at all with no errors in the log either

    • Eddie Adolf said:

      I was able to get it working real quick after some trial and error as I am a coder / designer but not on the backend with php. Just add the classPhpPsdReader.php on your server. Then make a test psd and place it in same folder. Then make a new php file, I just made mine all blank and put this in it:

      Then run this file.

      Fun and all, but it would work best if you put it in an upload process or something of course.

      I plan to use it for a new proofing system i’m developing (the outline atleast) so that I’ll be able to just upload a psd, it will convert it to a jpg, and then resize it for the client to review. It really just saves me a step. But hey anything to save steps!

Leave a Reply

Your email address will not be published. Required fields are marked *

Please respect the following rules: No advertising, no spam, no keyword in name field. Thank you!