Auto Arrange

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

Revnart
Posts: 9
Joined: Wed Sep 28, 2016 8:56 am

Auto Arrange

Post by Revnart »

I often need to arrange layers or files in minimal space on a 100cm wide document, heigth doesn't matter.
I'm curious if anyone know a tool which can do something like this in attachement, or know is it possible with JavaScript?
Attachments
script_question.jpg
script_question.jpg (198.28 KiB) Viewed 7361 times
User avatar
Jaroslav Bereza
Posts: 38
Joined: Tue Dec 27, 2016 7:22 pm

Re: Auto Arrange

Post by Jaroslav Bereza »

Do you want only recangles or any shapes? Can you rotate shapes?
Revnart
Posts: 9
Joined: Wed Sep 28, 2016 8:56 am

Re: Auto Arrange

Post by Revnart »

all I use are files or raster layers but all of them are rectangles, squares etc. I used shapes in my attachement as an idea. Yes, rotation is main problem, because it can drastically improve space reduction.
kjell
Posts: 8
Joined: Wed Nov 30, 2016 1:11 pm

Re: Auto Arrange

Post by kjell »

This problem is called "bin packing" and is NP-complete, meaning (simplified) that if you want the optimal result you have (for the moment) try all permutations - of which there are an exponential amount of. Thus, for large numbers of rectangles this problem becomes intractable.

You can resort to heuristics, of which there are quite a few. I can send you one if you like, feel free to send me a private message.
User avatar
Jaroslav Bereza
Posts: 38
Joined: Tue Dec 27, 2016 7:22 pm

Re: Auto Arrange

Post by Jaroslav Bereza »

You don't need reinvent wheel. Just try already made tool in JS.

https://github.com/jakesgordon/bin-packing

https://www.google.cz/search?rlz=1C1GGR ... CIBF2YcYJg