Display Unsupported Image Formats In Browser

Display Unsupported Image Formats In Browser

Most of the browsers do not support most of the image file types rather than some common file types like JPG, PNG and GIF. But in most of the web projects user need to upload some most used file types like PSD, PDF ( Unsupported image formats ) etc. and they need to see what they have uploaded is perfect or not.

So here are some methods using PHP and ImageMagick module for PHP to disply a little more formats in browsers by converting them into JPG format.

Displaying the JPG file format image in browsers :

Displaying the PNG file format image in browsers :

Displaying the GIF file format image in browsers :

The functions used above imagecreatefromjpeg(), imagecreatefrompng(), imagecreatefromgif(), imagejpeg() for reading .jpg, .png and .gif files are library functions of PHP. So so need not to bother about how to make them work.

Displaying the PSD file format image in browsers :

Here the function used i.e. imagecreatefrompsd() is not predefined library function. So in order to make it work we need to include an extra class file which will read the PSD files and gice the browser a JPEG file as output. You can download the classPhpPsdReader.php here.

Displaying the TIFF file format image in browsers :

Displaying the PDF file format image in browsers :

You need to call he wrapper class of ImageMagick in order to make it work of pdf and tiff files. Follow the installation guide of ImageMagick here.

Happy Coding 🙂

1
Leave a Reply

avatar
1 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
0 Comment authors
Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
trackback

[…] all. Check your php.ini or test with any simple script. Check this post for a working version of […]

Close Menu