4 ms·
Does anyone know of a similar tool for Python? Not trying to start a Ruby/Python fight or anything; Python just happens to be my preferred language.
by nja 13y ago
Does anyone know of a similar tool for Python?
Not trying to start a Ruby/Python fight or anything; Python just happens to be my preferred language.
- sjtgraham 13y agoJust use Ruby for this. I prefer Ruby, but there are times I will pick Python instead because it has better libs for what I need to do, e.g. numerical and scientific libs.
- hoov 13y ago"Just use Ruby" isn't always the best option; if you have a large base of Python code, it's probably preferable to use Python directly rather than using the subprocess module. Also, a port would be fairly straightforward. Some combo of the struct/ctypes modules (depending on how complicated the data structures are) would make a transliteration pretty simple.
- sjtgraham 13y agoA "large base of Python code" would not be my main reason for eschewing other languages: - Unfortunately psd.py doesn't seem to exist. Tell me, what is less effort: Implementing that, or building a small app/service that performs the functionality you need using existing tools? - Also I'd consider the suitability of a given technology before this too, e.g. on my current project there is a lot of Ruby code, but it's a major bottleneck in one of our services performing a particular task. We rewrote that service in Clojure and it performs orders of magnitude faster and uses orders of magnitude less memory.
- hoov 13y ago> Tell me, what is less effort: Implementing that, or building a small app/service that performs the functionality you need using existing tools? I think it depends on your use case. In certain cases, you want to do work inline. In other cases, you want to do PS manipulation in the background. I could imagine projects that go in either direction. If I had a large Python desktop application, I'd port the code. If I had a Django application that wanted to do background processing of PS documents, I'd put the work on a queue and have Ruby take care of the messy bits. > Also I'd consider the suitability of a given technology before this too, e.g. on my current project there is a lot of Ruby code, but it's a major bottleneck in one of our services performing a particular task. We rewrote that service in Clojure and it performs orders of magnitude faster and uses orders of magnitude less memory. I take a different approach. If I find a bottleneck in Python code, I use ctypes or write a C extension. I'd do the same thing in Ruby. I'm hesitant to deploy multiple runtimes, since I worry about security updates, etc. If I were on JRuby, Clojure would be a natural fit -- I'd only be deploying one JVM.
- kmike84 13y ago> Unfortunately psd.py doesn't seem to exist. This is just plain wrong. There are many Python readers for PSD format: * https://github.com/kmike/psd-tools https://github.com/kmike/psd-tools * https://github.com/jerem/psdparse https://github.com/jerem/psdparse * https://code.google.com/p/pypsd/ https://code.google.com/p/pypsd/ * PIL and Pillow can read PSD files. I'm biased because I wrote psd-tools, but I think psd-tools API is quite simple, and it has some features that PSD.rb doesn't have, e.g. it supports more PSD compression formats (actually, all of them) and can export individual layers and layer groups as images. It also has more tests than PSD.rb and more PSD files in testing suite.
- sjtgraham 13y agoNice. Obviously I didn't look too hard hence "doesn't seem to exist". My main point was against reimplementing something already extant just because you have a swathe of code in a given language.
- kmike84 13y agoYour point applies more to PSD.rb then - there was a lot of PSD readers in Python, C, C++ and C# for ages :) But it seems that reimplementing worked very well for them: API, language and a good timing really matters.
- shurcooL 13y agoI would've liked to see it in Go, but alas.
- fish2000 13y agoClose: https://github.com/migurski/Blit https://github.com/migurski/Blit
- TheZenPsycho 13y agoyes. this https://github.com/jerem/psdparse https://github.com/jerem/psdparse
- enry_straker 13y agoYou can access ruby code from python ( throuh jython and jruby) and the process is relatively seamless. or check out psdparse on github ( there are others out in the wild )
- kmike84 13y agoA shameless plug: you can give https://github.com/kmike/psd-tools https://github.com/kmike/psd-tools a try. I've read PSD.rb docs and a bit of its code; the implementation is one of the best and complete I've seen (I've checked almost all PSD reader implementations some time ago). But it seems that psd-tools is mostly on par with PSD.rb. It also have some features that PSD.rb doesn't have, e.g. full support for 'zip-with-prediction' compression, including 32bit layers. Such images are very common in practice, and parsing them is not easy because the compression format is not documented anywhere, and "zip-with-prediction" for 8 and 16bit layers is totally different from "zip-with-prediction" for 32bit layers (for 32bits it is really tricky). If PSD.rb authors are reading this, I urge them to check the decompression code in psd-tools (https://github.com/kmike/psd-tools/blob/master/src/psd_tools/compression.py https://github.com/kmike/psd-tools/blob/master/src/psd_tools...) or in Paint.NET PSD plugin (http://psdplugin.codeplex.com/ http://psdplugin.codeplex.com/) to not waste the time. psd-tools also knows how to export individual layers, and there is an experimental support for exporting layer groups; it seems that this is not implemented in PSD.rb yet. PSD.rb has some features that psd-tools doesn't have, e.g. it parses "Font data" which is really cool and hard because the format is not described anywhere.
- tluyben2 13y agoI checked out psd-tools and it's good. Any chance of you adding their features to yours or vice versa? I know I know, I should do it myself and do a pull request, but just asking if you are planning to?
- kmike84 13y agoUnfortunately I'm currently very busy with other projects, so I probably won't implement PSD.rb features myself anytime soon. I'm trying to provide feedback for psd-tools pull requests, merge them and release new psd-tools versions in timely manner; the testing suite also helps here, so you know, pull requests are welcome :) Most improvements over last 6 months came from pull requests submitted by other great people. I think that the "reader" part of library is feature-complete. psd-tools reads all the information, but it doesn't decode all Photoshop data structures (some of them are available only as binary blobs). So I think implementing a PSD.rb feature will most likely involve checking PSD.rb code and decoding a binary blob (already loaded to memory) to a Python data structure.