Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Cutting image in parts

Explorer ,
Apr 23, 2017 Apr 23, 2017

I have an image,  i  want to get 9 by 7 equal rectangles as layers, the size of the image is different.

this could be portrait as also landscape.

the 63 rectangles should be in 63 layers.

Thanks to the experts!!!

5.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Apr 23, 2017 Apr 23, 2017

Nope, but you could run this script and it will create your layers...

#target photoshop

if(documents.length){

var startRulerUnits = preferences.rulerUnits;

preferences.rulerUnits = Units.PIXELS;

doc = app.activeDocument;

app.displayDialogs = DialogModes.NO;

doc.flatten();

var tilesAcross =9;

var tilesDown =7;

var tileWidth = parseInt(doc.width/tilesAcross);

var tileHeight = parseInt(doc.height/tilesDown);

ProcessFiles(tilesDown,tilesAcross,tileWidth,tileHeight);

app.preferences.rulerUnits = startRulerUnits; 

...
Translate
Adobe
Community Expert ,
Apr 23, 2017 Apr 23, 2017

View > New Guide Layout.

Select Slice tool.

Click Slices from Guides.

File > Export > Save for Web.

Choose optimization settings and click Save. Photoshop will put all slices into a folder, each as a separate image.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 23, 2017 Apr 23, 2017

Is there any possibility, that these slices are automatically as layers in the image file?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 23, 2017 Apr 23, 2017

Nope, but you could run this script and it will create your layers...

#target photoshop

if(documents.length){

var startRulerUnits = preferences.rulerUnits;

preferences.rulerUnits = Units.PIXELS;

doc = app.activeDocument;

app.displayDialogs = DialogModes.NO;

doc.flatten();

var tilesAcross =9;

var tilesDown =7;

var tileWidth = parseInt(doc.width/tilesAcross);

var tileHeight = parseInt(doc.height/tilesDown);

ProcessFiles(tilesDown,tilesAcross,tileWidth,tileHeight);

app.preferences.rulerUnits = startRulerUnits;     

}

function ProcessFiles(Down,Across,offsetX,offsetY){

    try{

var newName = activeDocument.name.match(/(.*)\.[^\.]+$/)[1];

}catch(e){var newName="UntitledChop"}

TLX = 0;    TLY = 0;    TRX = offsetX;    TRY = 0;

BRX = offsetX;    BRY = offsetY;    BLX = 0;    BLY = offsetY;

    for(var a = 0; a < Down; a++){

        for(var i = 0;i <Across; i++){

            var NewFileName = newName +"#"+a+"-"+i;

                activeDocument.selection.select([[TLX,TLY],[TRX,TRY],[BRX,BRY],[BLX,BLY]], SelectionType.REPLACE, 0, false);

                    executeAction( charIDToTypeID( "CpTL" ), undefined, DialogModes.NO );

                activeDocument.activeLayer.name = NewFileName;

                app.activeDocument.selection.deselect();

                activeDocument.activeLayer = activeDocument.artLayers.getByName("Background");

TLX = offsetX * (i+1) ;    TRX  = TLX + offsetX;    BRX = TRX;    BLX = TLX;       

        }

TLX = 0;    TLY = offsetY * (a +1); TRX = offsetX;    TRY = offsetY * (a +1);

BRX = offsetX;    BRY = TRY + offsetY; BLX = 0;    BLY = (offsetY * (a +1)+offsetY);   

    }

};

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 23, 2017 Apr 23, 2017

SuperMerlin

this is nearly the best result. i have some gaps in the image.

Please take a look at the image.

Counter is perfect.

Screenshot 2017-04-23 20.55.07.png

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 23, 2017 Apr 23, 2017

Are you viewing at 100% (1:1)? If not, view at 100% and report back.

If you merge all layers to a single layer (not flatten), do the lines disappear?

For future reference: a similar but different script – Photoshop script to cut images into new layers of a given size · GitHub

/* modification of a script by Oisin Conolly (digitalbiscuits.co.uk),

* found on StackOverflow (http://goo.gl/Ko9Ik) */

// x and y size of the slices we want to take

var xSize = 110;

var ySize = 30;

// set the ruler type

if (app.preferences.rulerUnits != Units.PIXELS) {

    app.preferences.rulerUnits = Units.PIXELS;

}

// keep a reference to the document and original layer

var docRef = app.activeDocument;

var layerRef = docRef.activeLayer;

for (y = 0; y<docRef.height; y+=ySize) {

    for (x = 0; x<docRef.width; x+=xSize) {

        // activate the original layer

        docRef.activeLayer = layerRef;

        // make the selection

        docRef.selection.select(Array (Array(x, y), Array(x, y+ySize), Array(x+xSize,y+ySize), Array(x+xSize,y)), SelectionType.REPLACE, 0, false);

        // copy the selection

        docRef.selection.copy();

        // create new layer

        docRef.artLayers.add();

        // deselect so that the paste hits 0,0 like we want it to for the animation

        docRef.selection.deselect();

        // and paste it

        docRef.paste();

    }

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 24, 2017 Apr 24, 2017
LATEST

Thank you, looked at it on 100%, no gaps.

Best regards.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 23, 2017 Apr 23, 2017

View it at 100% and you will see the gaps dissapear.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 23, 2017 Apr 23, 2017

There's the Photoshop command File > Scripts > Load Files into Stack, which will combine multiple images into a layered file. The resulting image will be the canvas size of one sliced image.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 24, 2017 Apr 24, 2017

Thanks for this answer:)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 23, 2017 Apr 23, 2017

It's certainy possible to slice your image into sections and then save them out as slices. Does this video help?

how to slice picture in photoshop - YouTube

this will save each image seperately in a folder of your choice.

Placing them on individual layers would probably have to be done manually from there.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines