Hacker Newsnew | past | comments | ask | show | jobs | submit | gburt2's commentslogin

"Recursive programming"... as in, programming using recursion? Why would this be important to "data science"? Surely loops are just as effective.


Are you serious? How would you iterate over a set of rules and a big data volume, without using recursion?


A loop? Can you please explain?


'Explain'?


I assume the "explain" refers to the most important thing you can learn about recursive programming: that it is often but not always the least efficient strategy when compared with looping.

So the claim that recursive programming is the only or primary method of iterating over large data sets requires some explanation...


I haven't read the article but i'm guessing this a reference to divide and conquer methods. Such as map reduce used in hadoop and such.


I just wrote a script with this that takes a directory of PSDs and outputs PNGs for each one. It took about 2 minutes. This is great.


Great, however, that was possible with ImageMagick before. Even more: ImageMagick can extract PSD layers as separate PNGs.


Sure. The difference is that with ImageMagick is getting all the flags right. Not to put down a powerful tool, but it isn't exactly memorable. In a script you can describe what's happening and customise it at any point without in-depth knowledge of the tool, and with a friendly CLI environment. I'd rather write 5 lines of Ruby than read up on the ImageMagick flags.


I'd rather look up the ImageMagick flags and write a simple 5 line shell wrapper for my specific use case than learn an API and write Ruby.


Could you provide your ImageMagick command, so we don't have to navigate the flag-infested waters?


How long did it take to output each PSD (if you have a rough file size for each that would be great to know)


Wow, everything old, is new again ;)

I think with an actual copy of Photoshop, and a little Applescript, this is something you could have done > 15 years ago.


But this way I don't have to keep paying $20/mo to Adobe CC so that I can run the script again next month.


I suspect that you could probably also manage it with GIMP/guile, but I don't suspect it would be particularly pleasant.


If you want to script it, ImageMagick or GraphicsMagick are probably a better bet than trying to hack up something with GIMP batch processing: http://www.imagemagick.com/www/formats.html

If you just want to do basic conversion ignoring layers, it's quite easy:

   for f in *.psd; do
     convert "$f" "${f%%.psd}.png"
   done


You can use find/xargs for this. It'll be faster because you can parallelize it with the -P option, for example, for a 4-core machine:

    find . -iname "*.psd" -print0 | xargs -0 -P 4 -n 1 -I I convert I I.png
For best results, change the number "4" in the above command to the number of cores you have.


The same with GNU Parallel, only it picks the right number of cores automatically and removes .psd from the file name:

  find . -iname "*.psd" -print0 | parallel -0 convert '{}' '{.}.png'


Oh excellent, I didn't know ImageMagick did PSD.


Gimp's support for PSD is understandably poor for the more advanced/modern features, so I wouldn't rely on it without being able to compare the output to something else. I use Apple's Preview utility to manually compare results.


So maybe what's great is avoiding the cost of Photoshop, which many have found to be outrageous.


  $ pacman -S applescript
  error: target not found: applescript
  $ pacman -S photoshop
  error: target not found: photoshop
  $ ruby --version
  ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
Hm, which of those can I use?


Yes, but now you can do it without having a copy of Photoshop.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: