{"id":17049396,"url":"https://github.com/samccone/psd.js","last_synced_at":"2025-04-30T18:04:11.209Z","repository":{"id":65993037,"uuid":"9828229","full_name":"samccone/psd.js","owner":"samccone","description":"Mirror of Meltingice's CoffeeScript PDF parser library.","archived":false,"fork":false,"pushed_at":"2013-05-08T21:22:26.000Z","size":7117,"stargazers_count":3,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-30T18:02:53.134Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://git.zx2c4.com/psd.js","language":"CoffeeScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/samccone.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-05-03T03:46:03.000Z","updated_at":"2017-12-07T23:14:36.000Z","dependencies_parsed_at":"2023-02-19T21:00:39.633Z","dependency_job_id":null,"html_url":"https://github.com/samccone/psd.js","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samccone%2Fpsd.js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samccone%2Fpsd.js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samccone%2Fpsd.js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samccone%2Fpsd.js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samccone","download_url":"https://codeload.github.com/samccone/psd.js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251758164,"owners_count":21638988,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T09:54:32.785Z","updated_at":"2025-04-30T18:04:11.164Z","avatar_url":"https://github.com/samccone.png","language":"CoffeeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# psd.js\n\nA Photoshop file format (PSD) parser written in Coffeescript/Javascript for both browsers and NodeJS implementations.\n\nThis implementation is inspired by, and in some parts directly ported, from:\n\n  * [pypsd](http://code.google.com/p/pypsd)\n  * [psdparse](https://github.com/jerem/psdparse)\n  * [libpsd](http://sourceforge.net/projects/libpsd)\n\n**Please note!**\n\nThe PSD file format is complex, buggy, hacky, and poorly documented. Because of this, psd.js may or may not be able to correctly parse every PSD you throw at it. Use with caution.\n\n## Contributing\n\nIf you would like to contribute to psd.js, you can refer to the [official PSD file format specifications](http://www.adobe.com/devnet-apps/photoshop/fileformatashtml/) for basic help.\n\n### Installing Development Dependencies\n\nThese dependencies are only required if you are making changes to the psd.js source. If you are simply using psd.js, there is no need to install them.\n\nIn the psd.js folder, run:\n\n```\nnpm install -d\n```\n\nAnd all of the dependencies will be installed for you automatically using npm.\n\n### Building psd.js\n\npsd.js comes with a handy Cakefile to build the library for you. It first searches for all dependencies in the `deps/` folder, then adds the core library afterwards in the order speciifed in the Cakefile.\n\nTo build, simply run `cake build`. If you would like the library to automatically build after any source files are saved, you can run `cake watch`.\n\nPlease run all of the tests before committing any code as well using `cake test`.\n\n## Using psd.js\n\nThere are two main things you can do with psd.js: parse information and export images.\n\n### Installing\n\npsd.js is available in npm. Simply run:\n\n```\nnpm install psd\n```\n\nAlternatively, download and use the `lib/psd.js` file from this repository, or you can use the CDN hosted version at:\n\n```\n//cdnjs.cloudflare.com/ajax/libs/psd.js/0.4.5/psd.min.js\n```\n\n### Loading a PSD\n\nIn order to load a PSD into psd.js, you have to give it the byte data in a Uint8Array buffer. psd.js has some helper methods for you to make your life easier.\n\n``` coffeescript\n# If you're in NodeJS, use this:\npsd = PSD.fromFile 'path/to/file.psd'\n\n# or if you're in the browser, you can do:\npsd = PSD.fromURL 'path/to/file.psd', (psd) -\u003e\n  console.log 'PSD loaded!'\n\n# If you already have the byte data from other means, simply do:\npsd = new PSD(bytes)\n```\n\n### Parsing Information\n\nYou can parse the PSD file for valuable information such as: image size, color channels, layer and mask information, etc.\n\n``` coffeescript\n{PSD} = require 'psd'\n\npsd = PSD.fromFile __dirname + '/test.psd'\npsd.parse()\n\n# Extract info to a friendly JSON format\ninfo = psd.toJSON()\n\nconsole.log \"Header\", info.header\nconsole.log \"Resources\", info.resources\nconsole.log \"Layers\", info.layerMask.layers\n```\n\n### Setting Options\n\n**By default, psd.js will not parse/format individual layer image data.** If you're working with large files, you will probably want to leave this disabled this for the time being as you may find your node.js process running out of memory for allocation.\n\nTo enable layer image parsing, do:\n\n``` coffeescript\npsd = PSD.fromFile __dirname + '/test.psd'\npsd.setOptions\n  layerImages: true # Should we parse layer image data?\n  onlyVisibleLayers: true # Should we only parse layer images that are visible?\n\npsd.parse()\n```\n\n### Exporting Merged Image Data\n\nYou can easily export a merged/flattened version of the PSD image either to file (NodeJS) or canvas (browser).\n\n``` coffeescript\n{PSD} = require 'psd'\n\npsd = PSD.fromFile __dirname + '/test.psd'\n\n# In node (async)\npsd.toFile __dirname + '/output.png', -\u003e\n  console.log \"PSD flattened to output.png\"\n\n# In node (sync)\npsd.toFileSync __dirname + '/output.png'\n\n# In browser...\ncanvas = document.getElementById('psd-output')\npsd.toCanvas(canvas)\n\n# Get raw pixel data\npixels = canvas.image.toCanvasPixels()\n```\n\nTo export individual layers, access the image object for each layer:\n\n``` coffeescript\n{PSD} = require 'psd'\n\npsd = PSD.fromFile __dirname + '/test.psd'\npsd.setOptions layerImages: true\npsd.parse()\n\nfor layer in psd.layers\n  continue if layer.isFolder\n\n  do (layer) -\u003e\n    layer.image.toFile __dirname + \"/output/#{layer.name}.png\", -\u003e\n      console.log \"Layer #{layer.name} output to file.\"\n```\n\n### Other Examples\n\nSee the `examples/` folder and the wiki for some handy code snippets.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamccone%2Fpsd.js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamccone%2Fpsd.js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamccone%2Fpsd.js/lists"}