php 操作 PSD,php读取psd文件格式解析

这是一个PHP类库,用于读取和解析PSD文件。它支持从PSD文件中提取信息,如版本ID、通道数、行数、列数、颜色深度和颜色模式。但目前还不支持某些特定的颜色模式和压缩类型,如多通道数据和32位颜色。该类还提供了一个简单的用例,展示了如何将PSD文件转换为JPEG图像。
摘要由CSDN通过智能技术生成

/* This file is released under the GPL, any version you like

*

*PHP PSD reader class, v1.3

*

*By Tim de Koning

*

*Kingsquare Information Services, 22 jan 2007

*

*example use:

*------------

*<?php

*include_once('classPhpPsdReader.php')

*header("Content-type: image/jpeg");

*print imagejpeg(imagecreatefrompsd('test.psd'));

*?>

*

*More info, bugs or requests, contact info@kingsquare.nl

*

*Latest version and demo: http://www.kingsquare.nl/phppsdreader

*

*TODO

*----

*- read color values for "multichannel data" PSD files

*- find and implement (hunter)lab to RGB algorithm

*- fix 32 bit colors... has something to do with gamma and exposure available since CS2, but dunno how to read them...

*/

class PhpPsdReader {

var $infoArray;

var $fp;

var $fileName;

var $tempFileName;

var $colorBytesLength;

function PhpPsdReader($fileName) {

set_time_limit(0);

$this->infoArray = array();

$this->fileName = $fileName;

$this->fp = fopen($this->fileName,'r');

if (fread($this->fp,4)=='8BPS') {

$this->infoArray['version id'] = $this->_getInteger(2);

fseek($this->fp,6,SEEK_CUR); // 6 bytes of 0's

$this->infoArray['channels'] = $this->_getInteger(2);

$this->infoArray['rows'] = $this->_getInteger(4);

$this->infoArray['columns'] = $this->_getInteger(4);

$this->infoArray['colorDepth'] = $this->_getInteger(2);

$this->infoArray['colorMode'] = $this->_getInteger(2);

/* COLOR MODE DATA SECTION */ //4bytes Length The length of the following color data.

$this->infoArray['colorModeDataSectionLength'] = $this->_getInteger(4);

fseek($this->fp,$this->infoArray['colorModeDataSectionLength'],SEEK_CUR); // ignore this snizzle

/* IMAGE RESOURCES */

$this->infoArray['imageResourcesSectionLength'] = $this->_getInteger(4);

fseek($this->fp,$this->infoArray['imageResourcesSectionLength'],SEEK_CUR);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值