How to open PSD/DDS/BMP images in PHP
Image conversion from various formats
In order to open PSD, DDS and BMP images in PHP we first need to convert them to a format supported by PHP. Conversion to JPEG or GIF would loose some of the quality so we'll stick to PNG.<?php
$url = 'http://your_server.com/image.psd'; //it can be PSD, BMP, DDS and so on
$data = json_decode(file_get_contents('http://api.rest7.com/v1/image_convert.php?url=' . $url . '&format=png'));
if (@$data->success !== 1)
{
die('Failed');
}
$image = file_get_contents($data->file);
file_put_contents('converted.png', $image);
Now we have an image in PNG format named "converted.png". We can open it in PHP without any more problems:$im = imagecreatefrompng('converted.png');
//here do your pixel manipulations or anything else
Comments