Reputation: 1754
I was trying to read a psd file from database as like pdf or images but I failed. Is there any way to read or display psd file in browser?
Upvotes: 4
Views: 3717
Reputation: 183
You can use the code below. It uses a webapi but it's free and has no limitations.
<?php
$url = 'http://server.com/image.psd';
$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('rendered_page.png', $image);
Additional bonus- it reads not only PSD images but many, many more.
You can get more examples here: http://rest7.com/image_convert
I am not affiliated with this website but I use it for over a week now so if you have questions I can try to answer :)
Upvotes: 1
Reputation: 3294
You can use ImageMagick for this,
$im = new Imagick("image.psd");
foreach($im as $layer) {
// do something with each $layer
// example: save all layers to separate PNG files
$layer->writeImage("layer" . ++$i . ".png");
}
Refer to this question too: PHP: Get the position (x, y) of the layer of PSD file
OR You could use something like this: PSD Library - Read .psd files without any 3rd party libraries.
Upvotes: 5