Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Export multiple cropped images on a spread with original linked names and specific dimensions

New Here ,
Nov 01, 2021 Nov 01, 2021

Copy link to clipboard

Copied

I am looking to export multiple cropped images on a spread with original linked names and specific dimensions. Do I need a a script for this? Has anyone done this? 

 

I'll attach a preview so you can see the spread with the containers. 

TOPICS
Import and export, Scripting

Views

86

Likes

Translate

Translate

Report

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 ,
Nov 01, 2021 Nov 01, 2021

Copy link to clipboard

Copied

 

Likes

Translate

Translate

Report

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
Enthusiast ,
Nov 06, 2021 Nov 06, 2021

Copy link to clipboard

Copied

Hi @kevinfabrizi,

I've had a crack at writing a script to solve your challenge. Let me know if this works for you. I've only tested on basic documents, so it might need some tweaking to handle less basic cases.

- Mark

 

/*

    Export All Graphics As JPG
    by m1b
    here: https://community.adobe.com/t5/indesign-discussions/export-multiple-cropped-images-on-a-spread-with-original-linked-names-and-specific-dimensions/m-p/12490323

    Will attempt to export every graphic in a document to a folder, as JPG image at set resolution.
    Filename has pixel dimensions appended.

*/

function main() {

    var exportResolution = 300; // ppi

    exportAllLinkedImagesAsJPG(exportResolution);

    function exportAllLinkedImagesAsJPG(resolution) {
        resolution = resolution || 300;
        var graphics = app.activeDocument.allGraphics;
        for (var i = 0; i < graphics.length; i++) {
            var graphic = graphics[i],
                frame = graphic.parent,
                w = Math.round((frame.visibleBounds[3] - frame.visibleBounds[1]) * (resolution / 72)),
                h = Math.round((frame.visibleBounds[2] - frame.visibleBounds[0]) * (resolution / 72)),
                filename = getFileNameForItem(frame) + '_' + w + 'x' + h;
            exportItemAsJPG({
                item: frame,
                filename: filename,
                resolution: resolution,
                exportPath: '~/Desktop/exported-jpg-' + resolution + 'ppi/'
            });
        }
    }

    function exportItemAsJPG(p) {
        if (p.item == undefined) return;
        p.filename = p.filename || p.item.constructor.name + ' ' + p.item.index;
        p.resolution = p.resolution || 300;
        p.exportPath = p.exportPath || '~/Desktop/exported-jpg-' + p.resolution + 'ppi/';

        // create the folder if necessary
        if (!Folder(p.exportPath).exists) Folder(p.exportPath).create();

        // set jpeg preferences
        app.jpegExportPreferences.exportResolution = p.resolution; // ppi
        app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.high; // low medium high maximum

        // export
        var path = p.exportPath + p.filename + '.jpg';
        p.item.exportFile(
            ExportFormat.jpg,
            File(path),
            false
        );
    }

    function getFileNameForItem(item, keepExtension) {
        var name = item.constructor.name + ' ' + item.id;
        if (item.graphics != undefined) {
            if (item.graphics[0].itemLink != undefined) {
                name = item.graphics[0].itemLink.name.replace(/\.[^.]+$/, '');
            }
        }
        return name;
    }


} // end main

app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Export graphics');

Likes

Translate

Translate

Report

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 Professional ,
Nov 06, 2021 Nov 06, 2021

Copy link to clipboard

Copied

  1. Set up the object caption. Object > Object captions
  2. When you place images activate create static captions

Design and position can be done with Object and Paragraph Styles.

Likes

Translate

Translate

Report

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
Enthusiast ,
Nov 06, 2021 Nov 06, 2021

Copy link to clipboard

Copied

LATEST

Nice! I've never used object captions. Great info!

 

Also I assumed OP wanted the linked image name and dimensions in the *filename*, but you may be right and it should be saved in the jpeg as a visible caption. I'll wait for @kevinfabrizi to clarify.

- Mark

Likes

Translate

Translate

Report

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