If I have a Photoshop Document containing an image for example. How can I break it into a grid ? Similar to doing: - Select a rectangle - new Layer Via Cut - move to the next rectangle vertically repeat ?

Any scripts/plugins that automate/parameterize that ?

link|improve this question

feedback

3 Answers

The only way I've done this is to layout a grid with guides, then slice the image using the slice tool. This should allow you to break the image into many seperate pieces. After using the slice tool you can Save For Web, and export only the slices, each as a separate image file.

link|improve this answer
thanks, but I'm afraid that's way to long winded, I'm to lazy for that :) – George Profenza Jan 31 '10 at 1:38
feedback

It is similar to a question I answered here: I did recommend a free tool that allows you to do this, you export the png, load the png there and hit the button....

Other soutions were proposed, too.

http://superuser.com/questions/112346/image-editor-that-allows-multiple-separate-simultaneous-crop-selections-to-be-s/131787#131787

link|improve this answer
feedback
up vote 1 down vote accepted

All nice answers, thanks for the contribution.

As I said, I wondering if there was something out there for Photoshop.

For documentation purposes here is a little script I wrote:

var doc  = app.activeDocument;
var arranger = makeDialog();

arranger .arrange.onClick = function(){
    if(isNaN(parseInt(arranger.w.text)) || isNaN(parseInt(arranger.h.text)) || isNaN(parseInt(arranger.c.text)) || isNaN(parseInt(arranger.r.text))){
        alert('Yo! Can you feed \' dis dialog some integer numbers ?\n For Real!');
    }else{
        sliceLayer(parseInt(arranger.w.text),parseInt(arranger.h.text),parseInt(arranger.r.text),parseInt(arranger.c.text));
    }
    arranger.close();
}

arranger.show();

function sliceLayer(w,h,r,c){
    var hw = w * 0.5;
    var hh = h * 0.5;
    var l0 = doc.activeLayer;
    for(var j = 0 ; j < r ; j++){
        for(var i = 0 ; i < c; i++){
            var x = i * w; //edited
            var y = j * h; //here
            //select
            doc.selection.select([[x,y],[x+w,y],[x+w,y+h],[x,y+h]]);
            //new layer via cut
            doc.selection.cut();
            var layer  = doc.artLayers.add();
            doc.paste();
            //move
            //$.writeln('translate x: '+(y)+', y: '+(x));
            layer.translate(y,x);
            doc.activeLayer = l0;
        }
    }
    l0.remove();//remove original layer(now empty)
}


function makeDialog(){
        var dialog = new Window('dialog','Slice and Dice');
        dialog.frameLocation = [300,300];
        dialog.w = dialog.add('edittext',undefined,'Selection width');
        dialog.w.prefferedSize = [200,50];
        dialog.h = dialog.add('edittext',undefined,'Selection height');
        dialog.h.prefferedSize = [200,50];
        dialog.c = dialog.add('edittext',undefined,'Grid Columns(V sections)');
        dialog.c.prefferedSize = [200,50];
        dialog.r = dialog.add('edittext',undefined,'Grid Rows(H sections)');
        dialog.r.prefferedSize = [200,50];
        dialog.arrange = dialog.add('button',undefined,'Chop Chop');
        return dialog;
}

If you save this in Photoshop/Presets/Scripts, you should be able to access it through Scripts in the File menu.

The problem with the JSX approach is, it is a bit slow for large subdivisions (100x100).

I'm guessing it will be faster to try with MATLAB/Photoshop communication, but I'll skip that for now.

Achieved the same goal in actionscript 3 using copyPixels() and it's pretty fast.

link|improve this answer
+1 self-answers are good, thanks – msw May 30 '10 at 22:54
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.