Highlighted

Can I control the dimensions of a JPEG export out of indesign or just export resolution?

Explorer ,
Mar 12, 2020

Copy link to clipboard

Copied

Can I control the dimensions of a JPEG export out of indesign or just export resolution? Something like this?

 

if(app.activeDocument.width.value>app.activeDocument.height.value){//Landscape
     app.activeDocument.resizeImage(
                     new UnitValue(800, "px"),
                     currentHeight,
                     currentResolution,
                     ResampleMethod.BILINEAR);
  }else
  {//Portrait
       app.activeDocument.resizeImage(
                    //currentHeight,
                     new UnitValue(600, "px"),
                     currentHeight,
                     currentResolution,
                     ResampleMethod.BILINEAR);
                     }

 

Adobe Community Professional
Correct answer by Laubender | Adobe Community Professional

Hi David,

first resize the object you want to export, then export with the appropriate resolution.

 

If we talk whole pages or spreads also consider an intermediate export to PDF/X-4 with transparency intact and no downsampling. Either process the exported PDF with PhotoShop or place the PDF in a new InDesign document, resize the page and the placed PDF to the desired size and export to JPEG as last step.

 

Here DOM documentation of InDesign's jpegExportPreferences:

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#JPEGExportPreference.html#d1e414061

 

Regards,
Uwe Laubender

( ACP )

Views

295

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

Can I control the dimensions of a JPEG export out of indesign or just export resolution?

Explorer ,
Mar 12, 2020

Copy link to clipboard

Copied

Can I control the dimensions of a JPEG export out of indesign or just export resolution? Something like this?

 

if(app.activeDocument.width.value>app.activeDocument.height.value){//Landscape
     app.activeDocument.resizeImage(
                     new UnitValue(800, "px"),
                     currentHeight,
                     currentResolution,
                     ResampleMethod.BILINEAR);
  }else
  {//Portrait
       app.activeDocument.resizeImage(
                    //currentHeight,
                     new UnitValue(600, "px"),
                     currentHeight,
                     currentResolution,
                     ResampleMethod.BILINEAR);
                     }

 

Adobe Community Professional
Correct answer by Laubender | Adobe Community Professional

Hi David,

first resize the object you want to export, then export with the appropriate resolution.

 

If we talk whole pages or spreads also consider an intermediate export to PDF/X-4 with transparency intact and no downsampling. Either process the exported PDF with PhotoShop or place the PDF in a new InDesign document, resize the page and the placed PDF to the desired size and export to JPEG as last step.

 

Here DOM documentation of InDesign's jpegExportPreferences:

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#JPEGExportPreference.html#d1e414061

 

Regards,
Uwe Laubender

( ACP )

Views

296

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
Adobe Community Professional ,
Mar 12, 2020

Copy link to clipboard

Copied

Hi David,

first resize the object you want to export, then export with the appropriate resolution.

 

If we talk whole pages or spreads also consider an intermediate export to PDF/X-4 with transparency intact and no downsampling. Either process the exported PDF with PhotoShop or place the PDF in a new InDesign document, resize the page and the placed PDF to the desired size and export to JPEG as last step.

 

Here DOM documentation of InDesign's jpegExportPreferences:

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#JPEGExportPreference.html#d1e414061

 

Regards,
Uwe Laubender

( ACP )

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
Reply
Loading...
Explorer ,
Mar 12, 2020

Copy link to clipboard

Copied

excellent, thank you.

 

 

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
Reply
Loading...
Adobe Community Professional ,
Mar 12, 2020

Copy link to clipboard

Copied

Looks like your example code is for Photoshop. If you want to export an object or page to a specific pixel dimension, you could try something like this InDesign script, which exports the active page as JPEG with the output image width set to 600 pixels:

 

 

 

 

//the export pixel width
var targetWidthPixels = 600;

var doc = app.activeDocument;
with(doc.viewPreferences){
    horizontalMeasurementUnits = MeasurementUnits.INCHES;
    verticalMeasurementUnits = MeasurementUnits.INCHES;
}

//get the page width in inches
var pw=doc.documentPreferences.pageWidth;

//calulate the resolution needed to export the jpeg as 1500px wide
//if the page is 8.5" x 11", the output pixel dimensions will be 600px x 776px
var resout= targetWidthPixels/pw;

//the active page
var pg=app.activeWindow.activePage.name;

//set the res preference and page range
 with(app.jpegExportPreferences){
     exportResolution = resout;
     pageString = pg;
     antiAlias = true;
     embedColorProfile = true;
     jpegColorSpace = JpegColorSpaceEnum.RGB;
     //add other properties as needed
}
 
//export the JPEG
doc.exportFile(
		ExportFormat.jpg,
		File(Folder.desktop + "/ExportJPG.jpg"), 
		false
);

 

 

 

 

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
Reply
Loading...
Adobe Community Professional ,
Mar 12, 2020

Copy link to clipboard

Copied

This includes your Landscape/Portrait conditional

 

 

//the target export pixel dimension for the long side
var targetPixelDim = 800;
var resout;

var doc = app.activeDocument;
with(doc.viewPreferences){
    horizontalMeasurementUnits = MeasurementUnits.INCHES;
    verticalMeasurementUnits = MeasurementUnits.INCHES;
}

//get the page dimensions in inches
var pw=doc.documentPreferences.pageWidth;
var ph=doc.documentPreferences.pageHeight;

//calulate the resolution needed to export the long dimension as 800px
if (pw > ph) {
	resout = targetPixelDim/pw;
}else{
    resout = targetPixelDim/ph;
}



//the active page
var pg=app.activeWindow.activePage.name;

//set the res preference and page range
 with(app.jpegExportPreferences){
     exportResolution = resout;
     pageString = pg;
     antiAlias = true;
     embedColorProfile = true;
     jpegColorSpace = JpegColorSpaceEnum.RGB;
     //add other properties as needed
}
 
//export the JPEG
doc.exportFile(
		ExportFormat.jpg,
		File(Folder.desktop + "/ExportJPG.jpg"), 
		false
);

 

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
Reply
Loading...
Explorer ,
Mar 12, 2020

Copy link to clipboard

Copied

Rob this is great! thanks. 

 

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
Reply
Loading...