summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/parse.coffee5
-rw-r--r--lib/psd.js33
-rw-r--r--lib/psd.min.js16
-rwxr-xr-xsrc/layerdata/layereffect.coffee11
-rwxr-xr-xsrc/psdfile.coffee2
-rwxr-xr-xsrc/psdlayer.coffee6
6 files changed, 50 insertions, 23 deletions
diff --git a/examples/parse.coffee b/examples/parse.coffee
index df55ba0..fbb93d0 100644
--- a/examples/parse.coffee
+++ b/examples/parse.coffee
@@ -10,3 +10,8 @@ if process.argv.length is 2
psd = PSD.fromFile process.argv[2]
psd.parse()
+
+data = psd.toJSON()
+
+fs.writeFile __dirname + "/output.json", JSON.stringify(data, null, "\t"), (err) ->
+ console.log "JSON data saved to output.json" \ No newline at end of file
diff --git a/lib/psd.js b/lib/psd.js
index 69e6539..5090b5c 100644
--- a/lib/psd.js
+++ b/lib/psd.js
@@ -339,7 +339,7 @@ var jspack = new JSPack(); ;
PSD.name = 'PSD';
- PSD.VERSION = "0.4.1";
+ PSD.VERSION = "0.4.2";
PSD.DEBUG = false;
@@ -995,7 +995,7 @@ var jspack = new JSPack(); ;
for (i = _i = 0; 0 <= length ? _i < length : _i > length; i = 0 <= length ? ++_i : --_i) {
ret[i] = String.fromCharCode(this.read(1)[0]);
}
- return ret.join('');
+ return ret.join('').replace(/\u0000/g, "");
};
PSDFile.prototype.readLengthWithString = function(defaultLen) {
@@ -2052,7 +2052,7 @@ var jspack = new JSPack(); ;
};
PSDLayer.prototype.parseEffectsLayer = function() {
- var count, effect, effects, left, pos, signature, size, type, v, _ref, _ref1;
+ var count, data, effect, effects, left, pos, signature, size, type, v, _ref, _ref1;
effects = [];
_ref = this.file.readf(">HH"), v = _ref[0], count = _ref[1];
while (count-- > 0) {
@@ -2070,16 +2070,14 @@ var jspack = new JSPack(); ;
return new PSDDropDownLayerEffect(this.file, true);
}
}).call(this);
- if (effect != null) {
- effect.parse();
- }
+ data = effect != null ? effect.parse() : void 0;
left = (pos + size) - this.file.tell();
if (left !== 0) {
Log.debug("Failed to parse effect layer with type " + type);
this.file.seek(left);
} else {
if (type !== "cmnS") {
- effects.push(effect);
+ effects.push(data);
}
}
}
@@ -2102,7 +2100,7 @@ var jspack = new JSPack(); ;
PSDLayer.prototype.toJSON = function() {
var data, section, sections, _i, _len;
- sections = ['name', 'top', 'left', 'bottom', 'right', 'channels', 'rows', 'cols', 'channelsInfo', 'mask', 'adjustments', 'layerType', 'blendMode'];
+ sections = ['name', 'top', 'left', 'bottom', 'right', 'channels', 'rows', 'cols', 'channelsInfo', 'mask', 'layerType', 'blendMode', 'adjustments'];
data = {};
for (_i = 0, _len = sections.length; _i < _len; _i++) {
section = sections[_i];
@@ -2475,7 +2473,10 @@ var jspack = new JSPack(); ;
PSDLayerEffectCommonStateInfo.prototype.parse = function() {
PSDLayerEffectCommonStateInfo.__super__.parse.call(this);
this.visible = this.file.readBoolean();
- return this.file.read(2);
+ this.file.read(2);
+ return {
+ visible: this.visible
+ };
};
return PSDLayerEffectCommonStateInfo;
@@ -2504,7 +2505,7 @@ var jspack = new JSPack(); ;
}
PSDDropDownLayerEffect.prototype.parse = function() {
- var _ref, _ref1;
+ var data, key, val, _ref, _ref1;
PSDDropDownLayerEffect.__super__.parse.call(this);
_ref = this.file.readf(">hiii"), this.blur = _ref[0], this.intensity = _ref[1], this.angle = _ref[2], this.distance = _ref[3];
this.file.read(2);
@@ -2514,8 +2515,18 @@ var jspack = new JSPack(); ;
this.useAngleInAllFX = this.file.readBoolean();
this.opacity = this.file.read(1)[0];
if (this.version === 2) {
- return this.nativeColor = this.getSpaceColor();
+ this.nativeColor = this.getSpaceColor();
}
+ data = {};
+ for (key in this) {
+ if (!__hasProp.call(this, key)) continue;
+ val = this[key];
+ if (key === "file") {
+ continue;
+ }
+ data[key] = val;
+ }
+ return data;
};
return PSDDropDownLayerEffect;
diff --git a/lib/psd.min.js b/lib/psd.min.js
index ded27a2..92b389d 100644
--- a/lib/psd.min.js
+++ b/lib/psd.min.js
@@ -71,7 +71,7 @@ return a;};m.Pack=function(fmt,values)
{sum+=(((m[1]==undefined)||(m[1]==''))?1:parseInt(m[1]))*this._lenLut[m[2]];}
return sum;};};var jspack=new JSPack();;var Log,PSD,PSDBrightnessContrast,PSDChannelImage,PSDColor,PSDColorBalance,PSDCurves,PSDDropDownLayerEffect,PSDFile,PSDHeader,PSDHueSaturation,PSDImage,PSDInvert,PSDLayer,PSDLayerEffect,PSDLayerEffectCommonStateInfo,PSDLayerMask,PSDLevels,PSDPosterize,PSDResource,PSDSelectiveColor,PSDThreshold,Root,Util,assert,fs,__hasProp={}.hasOwnProperty,__extends=function(child,parent){for(var key in parent){if(__hasProp.call(parent,key))child[key]=parent[key];}function ctor(){this.constructor=child;}ctor.prototype=parent.prototype;child.prototype=new ctor;child.__super__=parent.prototype;return child;};assert=(function(assert){if(typeof exports!=="undefined"&&exports!==null){return require('assert');}
assert=function(test){if(test!==true){throw"Assertion error";}};assert.equal=function(actual,expected){if(actual!==expected){throw"Assertion error";}};return assert;})(assert);if(typeof exports!=="undefined"&&exports!==null){Root=exports;fs=require('fs');}else{Root=window;}
-Root.PSD=PSD=(function(){PSD.name='PSD';PSD.VERSION="0.4.1";PSD.DEBUG=false;PSD.fromFile=function(file,cb){var data,reader;if(cb==null){cb=function(){};}
+Root.PSD=PSD=(function(){PSD.name='PSD';PSD.VERSION="0.4.2";PSD.DEBUG=false;PSD.fromFile=function(file,cb){var data,reader;if(cb==null){cb=function(){};}
if(typeof exports!=="undefined"&&exports!==null){data=fs.readFileSync(file);return new PSD(data);}else{reader=new FileReader();reader.onload=function(f){var bytes,psd;bytes=new Uint8Array(f.target.result);psd=new PSD(bytes);return cb(psd);};return reader.readAsArrayBuffer(file);}};PSD.fromURL=function(url,cb){var xhr;if(cb==null){cb=function(){};}
xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=function(){var data,psd;data=new Uint8Array(xhr.response||xhr.mozResponseArrayBuffer);psd=new PSD(data);return cb(psd);};return xhr.send(null);};PSD.prototype.options={layerImages:false};function PSD(data){this.file=new PSDFile(data);this.header=null;this.resources=null;this.layerMask=null;this.layers=null;this.images=null;this.image=null;}
PSD.prototype.setOptions=function(options){var key,val,_results;_results=[];for(key in options){if(!__hasProp.call(options,key))continue;val=options[key];_results.push(this.options[key]=val);}
@@ -124,7 +124,7 @@ return{x:x*95.047,y:y*100.0,z:z*108.883};};PSDColor.labToRGB=function(l,a,b){var
PSDFile.prototype.tell=function(){return this.pos;};PSDFile.prototype.read=function(bytes){var i,_i,_results;_results=[];for(i=_i=0;0<=bytes?_i<bytes:_i>bytes;i=0<=bytes?++_i:--_i){_results.push(this.data[this.pos++]);}
return _results;};PSDFile.prototype.seek=function(amount,rel){if(rel==null){rel=true;}
if(rel){return this.pos+=amount;}else{return this.pos=amount;}};PSDFile.prototype.readInt=function(){var int;int=this.readUInt();if(int>=0x80000000){return int-0x100000000;}else{return int;}};PSDFile.prototype.readUInt=function(){var b1,b2,b3,b4;b1=this.read(1)[0]<<24;b2=this.read(1)[0]<<16;b3=this.read(1)[0]<<8;b4=this.read(1)[0];return b1|b2|b3|b4;};PSDFile.prototype.readShortInt=function(){var int;int=this.readShortUInt();if(int>=0x8000){return int-0x10000;}else{return int;}};PSDFile.prototype.readShortUInt=function(){var b1,b2;b1=this.read(1)[0]<<8;b2=this.read(1)[0];return b1|b2;};PSDFile.prototype.readLongInt=function(){return this.readf(">l")[0];};PSDFile.prototype.readLongUInt=function(){return this.readf(">L")[0];};PSDFile.prototype.readDouble=function(){return this.readf(">d")[0];};PSDFile.prototype.readBoolean=function(){return this.read(1)[0]!==0;};PSDFile.prototype.readString=function(length){var i,ret,_i;ret=[];for(i=_i=0;0<=length?_i<length:_i>length;i=0<=length?++_i:--_i){ret[i]=String.fromCharCode(this.read(1)[0]);}
-return ret.join('');};PSDFile.prototype.readLengthWithString=function(defaultLen){var length,str;if(defaultLen==null){defaultLen=4;}
+return ret.join('').replace(/\u0000/g,"");};PSDFile.prototype.readLengthWithString=function(defaultLen){var length,str;if(defaultLen==null){defaultLen=4;}
length=this.read(1)[0];if(length===0){str=this.readString(defaultLen);}else{str=this.readString(length);}
return str;};PSDFile.prototype.readBytesList=function(size){return this.read(size);};PSDFile.prototype.readf=function(format){return jspack.Unpack(format,this.read(jspack.CalcLength(format)));};PSDFile.prototype.skipBlock=function(desc){var n;if(desc==null){desc="unknown";}
n=this.readf('>L')[0];if(n){this.seek(n);}
@@ -207,9 +207,8 @@ _ref1=this.file.readf(">llllBB"),this.mask.top=_ref1[0],this.mask.left=_ref1[1],
return true;};PSDLayer.prototype.parseBlendingRanges=function(){var i,length,pos,_i,_ref,_results;length=this.file.readInt();this.blendingRanges.grey={source:{black:this.file.readShortInt(),white:this.file.readShortInt()},dest:{black:this.file.readShortInt(),white:this.file.readShortInt()}};pos=this.file.tell();this.blendingRanges.numChannels=(length-8)/8;assert(this.blendingRanges.numChannels>0);this.blendingRanges.channels=[];_results=[];for(i=_i=0,_ref=this.blendingRanges.numChannels;0<=_ref?_i<_ref:_i>_ref;i=0<=_ref?++_i:--_i){_results.push(this.blendingRanges.channels.push({source:{black:this.file.readShortInt(),white:this.file.readShortInt()},dest:{black:this.file.readShortInt(),white:this.file.readShortInt()}}));}
return _results;};PSDLayer.prototype.parseLayerName=function(){var namelen;namelen=Util.pad4(this.file.read(1)[0]);this.name=this.file.readString(namelen);return Log.debug("Layer name: "+this.name);};PSDLayer.prototype.parseExtraData=function(){var key,length,pos,signature,_ref,_results;_results=[];while(this.file.tell()<this.layerEnd){_ref=this.file.readf(">4s4s"),signature=_ref[0],key=_ref[1];assert.equal(signature,"8BIM");length=Util.pad2(this.file.readInt());pos=this.file.tell();Log.debug("Extra layer info: key = "+key+", length = "+length);switch(key){case"levl":this.adjustments.levels=(new PSDLevels(this,length)).parse();break;case"curv":this.adjustments.curves=(new PSDCurves(this,length)).parse();break;case"brit":this.adjustments.brightnessContrast=(new PSDBrightnessContrast(this,length)).parse();break;case"blnc":this.adjustments.colorBalance=(new PSDColorBalance(this,length)).parse();break;case"hue2":this.adjustments.hueSaturation=(new PSDHueSaturation(this,length)).parse();break;case"selc":this.adjustments.selectiveColor=(new PSDSelectiveColor(this,length)).parse();break;case"thrs":this.adjustments.threshold=(new PSDThreshold(this,length)).parse();break;case"nvrt":this.adjustments.invert=(new PSDInvert(this,length)).parse();break;case"post":this.adjustments.posterize=(new PSDPosterize(this,length)).parse();break;case"lyid":this.layerId=this.file.readInt();break;case"lsct":this.readLayerSectionDivider();break;case"lrFX":this.parseEffectsLayer();this.file.read(2);break;default:this.file.seek(length);Log.debug("Skipping additional layer info with key "+key);}
if(this.file.tell()!==(pos+length)){Log.debug("Error parsing additional layer info with key "+key+" - unexpected end");_results.push(this.file.seek(pos+length,false));}else{_results.push(void 0);}}
-return _results;};PSDLayer.prototype.parseEffectsLayer=function(){var count,effect,effects,left,pos,signature,size,type,v,_ref,_ref1;effects=[];_ref=this.file.readf(">HH"),v=_ref[0],count=_ref[1];while(count-->0){_ref1=this.file.readf(">4s4s"),signature=_ref1[0],type=_ref1[1];size=this.file.readf(">i")[0];pos=this.file.tell();Log.debug("Parsing effect layer with type "+type+" and size "+size);effect=(function(){switch(type){case"cmnS":return new PSDLayerEffectCommonStateInfo(this.file);case"dsdw":return new PSDDropDownLayerEffect(this.file);case"isdw":return new PSDDropDownLayerEffect(this.file,true);}}).call(this);if(effect!=null){effect.parse();}
-left=(pos+size)-this.file.tell();if(left!==0){Log.debug("Failed to parse effect layer with type "+type);this.file.seek(left);}else{if(type!=="cmnS"){effects.push(effect);}}}
-return this.adjustments.effects=effects;};PSDLayer.prototype.readLayerSectionDivider=function(){var code;code=this.file.readInt();this.layerType=SECTION_DIVIDER_TYPES[code];Log.debug("Layer type:",this.layerType);switch(code){case 1:case 2:return this.isFolder=true;case 3:return this.isHidden=true;}};PSDLayer.prototype.toJSON=function(){var data,section,sections,_i,_len;sections=['name','top','left','bottom','right','channels','rows','cols','channelsInfo','mask','adjustments','layerType','blendMode'];data={};for(_i=0,_len=sections.length;_i<_len;_i++){section=sections[_i];data[section]=this[section];}
+return _results;};PSDLayer.prototype.parseEffectsLayer=function(){var count,data,effect,effects,left,pos,signature,size,type,v,_ref,_ref1;effects=[];_ref=this.file.readf(">HH"),v=_ref[0],count=_ref[1];while(count-->0){_ref1=this.file.readf(">4s4s"),signature=_ref1[0],type=_ref1[1];size=this.file.readf(">i")[0];pos=this.file.tell();Log.debug("Parsing effect layer with type "+type+" and size "+size);effect=(function(){switch(type){case"cmnS":return new PSDLayerEffectCommonStateInfo(this.file);case"dsdw":return new PSDDropDownLayerEffect(this.file);case"isdw":return new PSDDropDownLayerEffect(this.file,true);}}).call(this);data=effect!=null?effect.parse():void 0;left=(pos+size)-this.file.tell();if(left!==0){Log.debug("Failed to parse effect layer with type "+type);this.file.seek(left);}else{if(type!=="cmnS"){effects.push(data);}}}
+return this.adjustments.effects=effects;};PSDLayer.prototype.readLayerSectionDivider=function(){var code;code=this.file.readInt();this.layerType=SECTION_DIVIDER_TYPES[code];Log.debug("Layer type:",this.layerType);switch(code){case 1:case 2:return this.isFolder=true;case 3:return this.isHidden=true;}};PSDLayer.prototype.toJSON=function(){var data,section,sections,_i,_len;sections=['name','top','left','bottom','right','channels','rows','cols','channelsInfo','mask','layerType','blendMode','adjustments'];data={};for(_i=0,_len=sections.length;_i<_len;_i++){section=sections[_i];data[section]=this[section];}
return data;};return PSDLayer;})();PSDLayerMask=(function(){PSDLayerMask.name='PSDLayerMask';function PSDLayerMask(file,header,options){this.file=file;this.header=header;this.options=options;this.layers=[];this.mergedAlpha=false;this.globalMask={};this.extras=[];}
PSDLayerMask.prototype.skip=function(){return this.file.seek(this.file.readInt());};PSDLayerMask.prototype.parse=function(){var endLoc,i,layer,layerInfoSize,maskSize,pos,_i,_j,_len,_ref,_ref1;maskSize=this.file.readInt();endLoc=this.file.tell()+maskSize;Log.debug("Layer mask size is "+maskSize);if(maskSize<=0){return;}
layerInfoSize=Util.pad2(this.file.readInt());pos=this.file.tell();if(layerInfoSize>0){this.numLayers=this.file.readShortInt();if(this.numLayers<0){Log.debug("Note: first alpha channel contains transparency data");this.numLayers=Math.abs(this.numLayers);this.mergedAlpha=true;}
@@ -238,8 +237,11 @@ for(j=_k=0;_k<3;j=++_k){this.data.settingValues[i][j]=this.file.getShortInt();}}
return this.data;};return PSDHueSaturation;})();PSDInvert=(function(){PSDInvert.name='PSDInvert';function PSDInvert(layer,length){this.layer=layer;this.length=length;this.file=this.layer.file;}
PSDInvert.prototype.parse=function(){return true;};return PSDInvert;})();PSDLayerEffect=(function(){PSDLayerEffect.name='PSDLayerEffect';function PSDLayerEffect(file){this.file=file;}
PSDLayerEffect.prototype.parse=function(){var _ref;return _ref=this.file.readf(">i"),this.version=_ref[0],_ref;};PSDLayerEffect.prototype.getSpaceColor=function(){this.file.read(2);return this.file.readf(">HHHH");};return PSDLayerEffect;})();PSDLayerEffectCommonStateInfo=(function(_super){__extends(PSDLayerEffectCommonStateInfo,_super);PSDLayerEffectCommonStateInfo.name='PSDLayerEffectCommonStateInfo';function PSDLayerEffectCommonStateInfo(){return PSDLayerEffectCommonStateInfo.__super__.constructor.apply(this,arguments);}
-PSDLayerEffectCommonStateInfo.prototype.parse=function(){PSDLayerEffectCommonStateInfo.__super__.parse.call(this);this.visible=this.file.readBoolean();return this.file.read(2);};return PSDLayerEffectCommonStateInfo;})(PSDLayerEffect);PSDDropDownLayerEffect=(function(_super){__extends(PSDDropDownLayerEffect,_super);PSDDropDownLayerEffect.name='PSDDropDownLayerEffect';function PSDDropDownLayerEffect(file,inner){this.inner=inner!=null?inner:false;PSDDropDownLayerEffect.__super__.constructor.call(this,file);this.blendMode="mul";this.color=this.nativeColor=[0,0,0,0];this.opacity=191;this.angle=120;this.useGlobalLight=true;this.distance=5;this.spread=0;this.size=5;this.antiAliased=false;this.knocksOut=false;}
-PSDDropDownLayerEffect.prototype.parse=function(){var _ref,_ref1;PSDDropDownLayerEffect.__super__.parse.call(this);_ref=this.file.readf(">hiii"),this.blur=_ref[0],this.intensity=_ref[1],this.angle=_ref[2],this.distance=_ref[3];this.file.read(2);this.color=this.getSpaceColor();_ref1=this.file.readf(">4s4s"),this.signature=_ref1[0],this.blendMode=_ref1[1];this.enabled=this.file.readBoolean();this.useAngleInAllFX=this.file.readBoolean();this.opacity=this.file.read(1)[0];if(this.version===2){return this.nativeColor=this.getSpaceColor();}};return PSDDropDownLayerEffect;})(PSDLayerEffect);PSDLevels=(function(){PSDLevels.name='PSDLevels';function PSDLevels(layer,length){this.layer=layer;this.length=length;this.file=this.layer.file;this.data={records:[]};}
+PSDLayerEffectCommonStateInfo.prototype.parse=function(){PSDLayerEffectCommonStateInfo.__super__.parse.call(this);this.visible=this.file.readBoolean();this.file.read(2);return{visible:this.visible};};return PSDLayerEffectCommonStateInfo;})(PSDLayerEffect);PSDDropDownLayerEffect=(function(_super){__extends(PSDDropDownLayerEffect,_super);PSDDropDownLayerEffect.name='PSDDropDownLayerEffect';function PSDDropDownLayerEffect(file,inner){this.inner=inner!=null?inner:false;PSDDropDownLayerEffect.__super__.constructor.call(this,file);this.blendMode="mul";this.color=this.nativeColor=[0,0,0,0];this.opacity=191;this.angle=120;this.useGlobalLight=true;this.distance=5;this.spread=0;this.size=5;this.antiAliased=false;this.knocksOut=false;}
+PSDDropDownLayerEffect.prototype.parse=function(){var data,key,val,_ref,_ref1;PSDDropDownLayerEffect.__super__.parse.call(this);_ref=this.file.readf(">hiii"),this.blur=_ref[0],this.intensity=_ref[1],this.angle=_ref[2],this.distance=_ref[3];this.file.read(2);this.color=this.getSpaceColor();_ref1=this.file.readf(">4s4s"),this.signature=_ref1[0],this.blendMode=_ref1[1];this.enabled=this.file.readBoolean();this.useAngleInAllFX=this.file.readBoolean();this.opacity=this.file.read(1)[0];if(this.version===2){this.nativeColor=this.getSpaceColor();}
+data={};for(key in this){if(!__hasProp.call(this,key))continue;val=this[key];if(key==="file"){continue;}
+data[key]=val;}
+return data;};return PSDDropDownLayerEffect;})(PSDLayerEffect);PSDLevels=(function(){PSDLevels.name='PSDLevels';function PSDLevels(layer,length){this.layer=layer;this.length=length;this.file=this.layer.file;this.data={records:[]};}
PSDLevels.prototype.parse=function(){var start,tag,version;start=this.file.tell();version=this.file.readShortInt();assert(version===1);this.parseLevelRecords();if(this.file.tell()-start<this.length-4){tag=this.file.readf(">4s");assert.equal(tag,"Lvls");version=this.file.readShortInt();assert.equal(version,3);this.data.levelCount=this.file.readShortInt()-29;assert(levelCount>=0);this.parseLevelRecords(levelCount);return this.data;}};PSDLevels.prototype.parseLevelRecords=function(count){var i,record,_i,_ref,_results;if(count==null){count=29;}
_results=[];for(i=_i=0;0<=count?_i<count:_i>count;i=0<=count?++_i:--_i){record={};_ref=this.file.readf(">hhhhh"),record.inputFloor=_ref[0],record.inputCeiling=_ref[1],record.outputFloor=_ref[2],record.outputCeiling=_ref[3],record.gamma=_ref[4];record.gamma/=100;if(i<27){assert(record.inputFloor>=0&&record.inputFloor<=255);assert(record.inputCeiling>=2&&record.inputCeiling<=255);assert(record.outputFloor>=0&&record.outputFloor<=255);assert(record.outputCeiling>=0&&record.outputCeiling<=255);assert(record.gamma>=0.1&&record.gamma<=9.99);}
_results.push(this.data.records.push(record));}
diff --git a/src/layerdata/layereffect.coffee b/src/layerdata/layereffect.coffee
index b92922c..d69586d 100755
--- a/src/layerdata/layereffect.coffee
+++ b/src/layerdata/layereffect.coffee
@@ -3,7 +3,7 @@
class PSDLayerEffect
- constructor: (@file) ->
+ constructor: (@file) ->
parse: ->
# these are common to all effects
@@ -22,6 +22,8 @@ class PSDLayerEffectCommonStateInfo extends PSDLayerEffect
# unused
@file.read(2)
+ {visible: @visible}
+
# Based on https://github.com/alco/psdump/blob/master/libpsd-0.9/src/drop_shadow.c
class PSDDropDownLayerEffect extends PSDLayerEffect
@@ -68,3 +70,10 @@ class PSDDropDownLayerEffect extends PSDLayerEffect
[@opacity] = @file.read(1)
@nativeColor = @getSpaceColor() if @version == 2
+
+ data = {}
+ for own key, val of @
+ continue if key is "file"
+ data[key] = val
+
+ data
diff --git a/src/psdfile.coffee b/src/psdfile.coffee
index 4d9c7af..417f8ec 100755
--- a/src/psdfile.coffee
+++ b/src/psdfile.coffee
@@ -65,7 +65,7 @@ class PSDFile
readString: (length) ->
ret = []
ret[i] = String.fromCharCode @read(1)[0] for i in [0...length]
- ret.join ''
+ ret.join('').replace /\u0000/g, ""
# Used for reading pascal strings, which are strings that have their length
# prepended to the chunk of character bytes. If a length isn't found, a
diff --git a/src/psdlayer.coffee b/src/psdlayer.coffee
index a490bd2..9da4ad8 100755
--- a/src/psdlayer.coffee
+++ b/src/psdlayer.coffee
@@ -334,14 +334,14 @@ class PSDLayer
when "dsdw" then new PSDDropDownLayerEffect @file
when "isdw" then new PSDDropDownLayerEffect @file, true # inner drop shadow
- effect?.parse()
+ data = effect?.parse()
left = (pos + size) - @file.tell()
if left != 0
Log.debug("Failed to parse effect layer with type #{type}")
@file.seek left
else
- effects.push(effect) unless type == "cmnS" # ignore commons state info
+ effects.push(data) unless type == "cmnS" # ignore commons state info
@adjustments.effects = effects
@@ -367,9 +367,9 @@ class PSDLayer
'cols'
'channelsInfo'
'mask'
- 'adjustments'
'layerType'
'blendMode'
+ 'adjustments'
]
data = {}