Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8248637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:15:22+00:00 2026-06-07T23:15:22+00:00

I have a script that is attempting to: scan an InDesign document for all

  • 0

I have a script that is attempting to:

  • scan an InDesign document for all images
  • send all images to Photoshop via the  BridgeTalk  object
  • resize all of the images to 600px width (maintaining aspect-ratio mathematically)
  • export all of the images from Photoshop to a new folder

It seems as if I might need to adjust the DPI of each image programmatically, because Photoshop is crashing before even one image is resized. The error suggests that the temporary memory is overloaded by this script, and I assume it has something to do with the image quality and/or size… Here is the error message:

General Photoshop error occurred. This functionality may not be
available in this version of Photoshop.
Error in Line 1:
Could not complete the command because the scratch disks are full.


Here is the relevant code that transforms image size:

function resaveInPS(imagePaths, imagesFolder)
{
    /*
     * NOTE:  no single-line comments are allowed in this function, because it is not read line-by-line by BridgeTalk, but as a single String;
     *        only multi-line comments will work, because they are terminated at each end
     */

    BridgeTalk.bringToFront("photoshop"); /* switch view from InDesign to Photoshop */

    app.displayDialogs = DialogModes.NO; /* Photoshop statement, prevents status alerts from interrupting */

    var imagePath = "";
    var fileName = "";
    var largerImage = "";

    for(var i = 0; i < imagePaths.length; i++)
    {
        imagePath = imagePaths[i].fullName;
        fileName = imagePaths[i].name;
        largerImage = fileName.substr(0, fileName.length - 4); /* getting rid of the file extension:  Photoshop will handle the file extension */

        var photoshopDoc = "";
        photoshopDoc = app.open(new File(imagePath) );

        var currentWidth = photoshopDoc.width; /* in inches */
        var currentHeight = photoshopDoc.height; /* in inches */

        currentWidth.convert("px"); /* now in pixels */
        currentHeight.convert("px"); /* now in pixels */

        var newWidth = 600; /* defining the desired exported image width here */
        var ratio = newWidth / currentWidth;
        var newHeight = ratio * currentHeight; /* maintaining aspect ratio of the resized image's height here */

        alert("The currentHeight is " + currentHeight + ".\n\nThe ratio is " + ratio + ".\n\nThe newHeight is " + newHeight + ".");

        photoshopDoc.resizeImage(newHeight, newWidth); /* (height, width) */
        photoshopDoc.resizeCanvas(newHeight, newWidth); /* (height, width) */

        var saveOptions = new TiffSaveOptions(); /* handling the file extension here */
        photoshopDoc.saveAs(new File(imagesFolder + "/" + largerImage), saveOptions); /* saving the new image in the folder here, with the file extension */
        photoshopDoc.close(SaveOptions.DONOTSAVECHANGES); /* close the Photoshop document without saving */
        app.purge(PurgeTarget.ALLCACHES); /* clears the clipboard, history, and undo cache in Photoshop; Note: does NOT delete the temporary files! */

    } /* end of for loop */

    app.displayDialogs = DialogModes.ALL; /* resume normal dialogs after saving the file and closing the document */
    app.purge(PurgeTarget.ALLCACHES); /* clears the clipboard, history and undo cache in Photoshop; Note:  does NOT delete the temporary files! */

} // end of function ResaveInPS

NOTE  —  My usage of the statement  app.purge(PurgeTarget.ALLCACHES)  does not seem to have much of an effect, as the error is still occurring…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T23:15:24+00:00Added an answer on June 7, 2026 at 11:15 pm

    So, I was incorrectly assuming that type-coercion would apply to unit-values, but of course it wouldn’t because “pixel” is not a default Javascript type.

    Without applying  new UnitValue  to  var ratio, ratio is coerced to type  Number  (though  currentWidth  is instantiated with a “pixel” unit-type). Also,  var newWidth  remains a type  Number as it was.


    Here is the corrected code, starting with the line  var currentWidth  and ending with  resizeCanvas :

            var currentWidth = photoshopDoc.width; /* in inches */
            var currentHeight = photoshopDoc.height; /* in inches */
    
            currentWidth.convert("px"); /* now in pixels */
            currentHeight.convert("px"); /* now in pixels */
    
    
            var newWidth = new UnitValue(600, "px"); /* defining the desired exported image width here */
            var ratio = new UnitValue(newWidth / currentWidth, "px");
            var newHeight = new UnitValue(ratio * currentHeight, "px"); /* maintaining aspect ratio of the resized image's height here */
    
            /*alert("The currentHeight is " + currentHeight + ".\n\nThe ratio is " + ratio + ".\n\nThe newHeight is " + newHeight + ".");*/
    
            photoshopDoc.resizeImage(newWidth, newHeight); /* (width, height) */
            photoshopDoc.resizeCanvas(newWidth, newHeight); /* (width, height) */
    

    Also, I got the parameters of the methods  resizeImage  and  resizeCanvas  backwards! This is the correct order for both:  (width, height).


    — thanks to @Mark for pointing me in the right direction.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This script is attempting to: create a new folder scan an InDesign document for
I have a PHP script that creates large complex tables. I am attempting to
I have been attempting to write a VBA Script that can parse out other
I have a script that recursively loops through all the sub directories and compresses
I have a script that submits data via an ajax POST. It is called
I have following script that executes all the .reg files in the current directory.
I have a simple PHP script that I am attempting a cross-domain CORS request:
I have a master script that is attempting to execute additional scripts against a
I have a Perl script that I'm attempting to set up using Perl Threads
I have script that reads remote file content and writes it to local server.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.