Skip to main content
Known Participant
June 6, 2024
Question

bleed AI

  • June 6, 2024
  • 3 replies
  • 650 views

Hey,

im working in a small printing shop for our university, and userdata for printing which arrives me is mostly unproffessional, with no bleed at all.

Yesterday I used Photoshop to extend an image with AI to have a bleed area. What a glorious idea! And I wonder: Is this scriptable for InDesign?

 

As a quick v0.1 version:

  • Only works with image-containers
  • Shows a dialog for how much bleed to add
  • (Hands image to ps, ps extends, image is placed again, container has to be extended by the ammount of the dialog

 

v0.2 

  • reads bleed from document-settings, only throws a dialog if no bleed is set

vX

  • doesnt care if selection is no image, and instead exports the page
This topic has been closed for replies.

3 replies

Community Expert
June 14, 2024

Hi @Jan373823687ed1 ,

also see into this script project by Marc Autret:

 

FillBleed | Fix Image Frames so they Meet the Bleed Edge [Update]
Marc Autret, July 11, 2018
https://indiscripts.com/post/2018/03/fill-bleed-fix-image-frames-so-they-meet-bleed-edge

 

Regards,
Uwe Laubender
( Adobe Community Expert )

EUFjanAuthor
Known Participant
October 21, 2024
rob day
Community Expert
Community Expert
June 6, 2024

Hi @Jan373823687ed1 , I use the script below for fixing InDesign page items that are not bleeding—it doesn’t adjust images.

 

You can use BridgeTalk to open linked images, but it can be difficult coding and there isn’t anything in the Photoshop API that would make AI adjustments, so you would probably  have to build an Action and trigger the action with a BT script.

 

 

 

/*
* set bleeds
* Rob Day 2022
*/

//the tolerance in points
var bt = 10;

//doc bleeds
var tb,bb,rb,lb;

function adjustBleeds(){
    if (app.documents.length == 0) {
        alert("No Documents Open")
        return
    } 
    app.scriptPreferences.measurementUnit = MeasurementUnits.POINTS;
    var d = app.activeDocument;
    var dp = d.documentPreferences;
    d.zeroPoint = [0,0];
    d.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;
    
    //get bleed settings
    tb = dp.documentBleedTopOffset;
    bb = dp.documentBleedBottomOffset;
    rb = dp.documentBleedOutsideOrRightOffset;
    lb = dp.documentBleedOutsideOrRightOffset;
    if (!dp.facingPages) {
        lb = dp.documentBleedInsideOrLeftOffset;
    }
    //the document’s page items
    var pi = d.allPageItems;
    for (var i = 0; i < pi.length; i++){
        if (pi[i].constructor.name == "Rectangle" || pi[i].constructor.name == "TextFrame") {
            setBleed(pi[i])
        } 
    };   
    app.scriptPreferences.measurementUnit = AutoEnum.AUTO_VALUE;
}

app.doScript(adjustBleeds, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Adjust bleeds');


/**
* Sets a page item that is within a tolerance (bt) to the page bleed offsets
* Sets rectangles and text frames only
* @ param a page item 
* @ return void 
*/
function setBleed(pi){
    //check if the page item is on the pasteboard
    if (pi.parentPage == null) {
        return
    }
    var pp = pi.parentPage;
    var px = pp.index;
    var pc = pp.parent.pages.length-1;
    var ps = pp.side;

    //page width and height
    var ph = pp.bounds[2]-pp.bounds[0];
    var pw = pp.bounds[3]-pp.bounds[1];

    var b = pi.geometricBounds;
    var ba = b;
    var ti = [0,0,0,0];
    var sc;
    
    //set top bleed
    if (b[0] < bt) {
        ba[0] = -tb
        if (pi.constructor.name == "TextFrame") {
            sc = 100/pi.absoluteVerticalScale
            ti[0] = (pi.textFramePreferences.insetSpacing[0]+tb+pi.geometricBounds[0])*sc 
            ti[1] = pi.textFramePreferences.insetSpacing[1];    
        } 
    } 
    //set bottom bleed
    if (b[2] > ph-bt) {
        ba[2] = ph + bb;
        if (pi.constructor.name == "TextFrame") {
            sc = 100/pi.absoluteVerticalScale
            ti[2] = (pi.textFramePreferences.insetSpacing[2]+bb)*sc
            ti[0] = pi.textFramePreferences.insetSpacing[0];
        } 
    }
    //set left bleed
    if (ps == PageSideOptions.LEFT_HAND || ps == PageSideOptions.SINGLE_SIDED && px == 0 && b[1] < bt) {
        ba[1] = -lb
        if (pi.constructor.name == "TextFrame") {
            sc = 100/pi.absoluteHorizontalScale
            ti[1] = (pi.textFramePreferences.insetSpacing[1]+lb+pi.geometricBounds[1])*sc
            ti[3] = pi.textFramePreferences.insetSpacing[3];
        } 
    } 
    //set right bleed
    if (ps == PageSideOptions.RIGHT_HAND || ps == PageSideOptions.SINGLE_SIDED && px == pc && b[3] > pw - bt) {
        ba[3] = pw + rb;
        if (pi.constructor.name == "TextFrame") {
            sc = 100/pi.absoluteHorizontalScale
            ti[3] = (pi.textFramePreferences.insetSpacing[3]+rb)*sc
            ti[1] = pi.textFramePreferences.insetSpacing[1];
        } 
    }
    pi.geometricBounds = ba

    if (pi.constructor.name == "TextFrame") {
        pi.textFramePreferences.insetSpacing = ti;
    }
}
m1b
Community Expert
Community Expert
June 6, 2024

Hi @Jan373823687ed1, this is a great idea for a script. It seems to me that it is achievable, providing that in photoshop you can script the generative fill, which I have no idea about. Maybe ask just that part in the photoshop forum.

 

I'll tag @rob day who is very clever with BridgeTalk to get Indesign to talk to Photoshop. Or is there a modern UXP way to do bridgeTalk's job now days?

 

Anyway, cool idea. I hope someone can help you progress with it.

- Mark