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

Looking for a way to quickly remove white spaces between sections of an image in Photoshop

New Here ,
Oct 13, 2019 Oct 13, 2019

Hi !

I have images of comics, which I want to make less heavy. The comic is one single column of images which reads from top to bottom, and the images have a ton of white space between them. It makes each image file unnecessarily tall. But I have hundreds of such "pages" so it's unthinkable for me to go through each one, and manually move the images closer together.

I was wondering if there was maybe a plugin or a function I'm not aware of, that could automate the process ? I know it's very specific.

Thank you for your help !

TOPICS
Actions and scripting
1.5K
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
Adobe
Community Expert ,
Oct 13, 2019 Oct 13, 2019

Are each of the squares and spacing of the comics the same size?

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 ,
Oct 13, 2019 Oct 13, 2019

Also how is the file structure: flat- one layer, many layers, or many layer in layersets for each frame?

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
New Here ,
Oct 13, 2019 Oct 13, 2019
Unfortunately the squares are of variable size. And it's all flat on one layer.
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 ,
Oct 13, 2019 Oct 13, 2019

Are each of the files consistent? can you post an example?

 

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 ,
Oct 13, 2019 Oct 13, 2019

Some sample images would be helpful.  You may be able to use the magic wand ins contiguous mode to select the white borders and  clear then the use script to split the comic cell into layers. Split to layers Once you have the layers you could export the layers to files and trim the transparency or write a script to align the layers in the stack to the bounds of the layer above one and other. Then trim the documents transparency.

JJMack
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 ,
Oct 13, 2019 Oct 13, 2019
LATEST

Okay, I think I came up with a way to do this. It's using the crop and straighten function. So if your frames all have a border around them, this should work. Attahced is a sample of the file before and the resulting file after. Right now the script closes the main file and leaves the resulting file open, a save function can be added, depending on what type of file you want to save and where. It might be able to be batched - haven't tried that yet. Just see if it works on one file first. Oh, and you can change the margin size by editing the margin variable in the script. Right now it's set for 20 px.

comic tighten.jpg

 

 

#target photoshop
app.preferences.rulerUnits = Units.PIXELS;
var doc = activeDocument;
var dName = doc.name.split('.')[0];
var dRes = doc.resolution
var margin = 20

cropS ();

doc.close(SaveOptions.DONOTSAVECHANGES);
var dNum = app.documents.length;

var doc1 = app.documents[0];
var newHeight = margin * (dNum +1) + doc1.height.value * dNum;
makeNewFile (doc1.width.value + margin*2, newHeight, dRes);
var targetDoc = activeDocument;
var transHeight = margin

for(var i=0;i<dNum;i++){
    var curDoc = activeDocument = app.documents[0];
    var curHeight = curDoc.height.value;
    curDoc.layers[0].duplicate (targetDoc.layers[0], ElementPlacement.PLACEBEFORE);
    curDoc.close(SaveOptions.DONOTSAVECHANGES);
    activeDocument = targetDoc;
    var mLayer = targetDoc.layers[0];
    mLayer.translate (margin - mLayer.bounds[0].value, transHeight - mLayer.bounds[1].value);
    transHeight += margin + curHeight;
    
    }

targetDoc.flatten();

function cropS (){
    var idCropPhotosAutozerozerozeroone = stringIDToTypeID( "CropPhotosAuto0001" );
    executeAction( idCropPhotosAutozerozerozeroone, undefined, DialogModes.NO );    
    }

function makeNewFile (w,h,res){
    app.documents.add(w,h,res,dName,NewDocumentMode.RGB)
    }

 

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