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

Image preview in resize dialog

Community Beginner ,
Apr 25, 2018 Apr 25, 2018

Copy link to clipboard

Copied

Is there any way to remove the image preview in the resize dialog?

Views

1.5K

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

correct answers 1 Correct answer

Community Expert , Apr 25, 2018 Apr 25, 2018

Not as far as i know.

There is a feature request over at Photoshop.com for that.

How To disable Photoshop CC Image size Preview | Photoshop Family Customer Community

Votes

Translate

Translate
Adobe
Community Expert ,
Apr 25, 2018 Apr 25, 2018

Copy link to clipboard

Copied

Not as far as i know.

There is a feature request over at Photoshop.com for that.

How To disable Photoshop CC Image size Preview | Photoshop Family Customer Community

Votes

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
Community Beginner ,
Apr 26, 2018 Apr 26, 2018

Copy link to clipboard

Copied

<profanity removed>. Thanks.

Votes

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 25, 2024 Nov 25, 2024

Copy link to clipboard

Copied

This has caused so many photoshop lockups over the years, I hated it from the day they first included it! I deal with multi GB files and it's a real problem.

Votes

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
Community Expert ,
Nov 25, 2024 Nov 25, 2024

Copy link to clipboard

Copied

@steve32909004c0fh 

 

You have replied to an old topic and the link is no longer available. So just to make sure, are you are talking of Image > Image Size? This could be scripted to various extents...

Votes

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 25, 2024 Nov 25, 2024

Copy link to clipboard

Copied

Hi Stephen,

Yes, I am talking about the preview when in "image size". I have worked in many photo labs and service bureaus since the late 80’s. When Adobe added it we all immediately disliked it. Now that my business is mainly GB+ images, it’s a real pain in the neck. I left the spinning beachball go all night recently due to not wanting to lose my changes and it was still spinning in the morning. I got around it today by flattening my image but this isn’t always possible.

Thank you,
Steve Ouimet

Digital Atelier
1347 16th Street
Los Osos, CA 93402

818-636-4094
www.steveouimet.com <>


Votes

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
Community Expert ,
Nov 26, 2024 Nov 26, 2024

Copy link to clipboard

Copied

@steve32909004c0fh 

 

When resizing, do you size the width or height in px, or a different unit of measure?

Votes

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 26, 2024 Nov 26, 2024

Copy link to clipboard

Copied

I generally use inches or percent.

Votes

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
Community Expert ,
Nov 28, 2024 Nov 28, 2024

Copy link to clipboard

Copied

quote
I generally use inches or percent.
By @steve32909004c0fh


Thanks, do you need to scale the width and height independently, or do you always resize as proportionally constrained to maintain aspect ratio?

 

Do you need to maintain layers?

 

Does your work contain layer styles?

 

I'm finding it challenging to cover all possible variations, so I'm now looking at limiting things for the initial script.

 

EDIT: I'm hopefully past these previous challenges... Moving on!

 

Image Size Sans Preview GUI.gif

Votes

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
Community Expert ,
Nov 30, 2024 Nov 30, 2024

Copy link to clipboard

Copied

The following script re-creates (most) of the functionality of Image > Image Size without a preview, this one using PIXELS as the fixed unit of measure.

 

/*
Image Size Sans Preview as PX.jsx
Stephen Marsh
v1.0, 30th November 2024
https://community.adobe.com/t5/photoshop-ecosystem-discussions/image-preview-in-resize-dialog/td-p/9846795
*/

#target photoshop;

try {

    main();

    function createResizeDialog() {
        // Get current document dimensions
        var doc = app.activeDocument;
        var currentWidth = doc.width.as('px');
        var currentHeight = doc.height.as('px');
        var currentResolution = doc.resolution;
        var currentWidthPixels = doc.width.as('px');
        var currentHeightPixels = doc.height.as('px');

        // Create the main window
        var dialog = new Window('dialog', 'Image Size Sans Preview (v1.0)');
        dialog.orientation = 'column';
        dialog.alignChildren = ['fill', 'top'];
        dialog.preferredSize.width = 325;

        // Add a panel to group interface elements
        var mainPanel = dialog.add('panel', undefined, 'UNITS: PIXELS');
        mainPanel.orientation = 'column';
        mainPanel.alignChildren = ['fill', 'top'];
        mainPanel.margins = [15, 15, 15, 15];

        // Pixel dimension display group
        var pixelDisplayGroup = mainPanel.add('group');
        pixelDisplayGroup.orientation = 'column';
        pixelDisplayGroup.alignChildren = ['fill', 'center'];
        pixelDisplayGroup.add('statictext', undefined, 'Original: ' + currentWidthPixels + ' x ' + currentHeightPixels + ' PX @ ' + currentResolution + ' PPI');

        // Panel separator line
        var separatorLine = mainPanel.add("panel");
        separatorLine.alignment = "fill";
        separatorLine.preferredSize.height = 1;

        // Width input group
        var widthGroup = mainPanel.add('group');
        widthGroup.orientation = 'row';
        widthGroup.alignChildren = ['left', 'center'];
        widthGroup.add('statictext', undefined, 'Width (PX): '); // Fudge the alignment with a spaces
        var widthInput = widthGroup.add('editnumber', undefined, Math.round(currentWidth));
        widthInput.preferredSize.width = 170;
        widthInput.characters = 10;

        // Height input group
        var heightGroup = mainPanel.add('group');
        heightGroup.orientation = 'row';
        heightGroup.alignChildren = ['left', 'center'];
        heightGroup.add('statictext', undefined, 'Height (PX):');
        var heightInput = heightGroup.add('editnumber', undefined, Math.round(currentHeight));
        heightInput.preferredSize.width = 170;
        heightInput.characters = 10;

        // Resolution input group
        var resolutionGroup = mainPanel.add('group');
        resolutionGroup.orientation = 'row';
        resolutionGroup.alignChildren = ['left', 'center'];
        resolutionGroup.add('statictext', undefined, 'Resolution (PPI): ');
        var resolutionInput = resolutionGroup.add('editnumber', undefined, currentResolution);
        resolutionInput.preferredSize.width = 140;
        resolutionInput.characters = 10;
        resolutionInput.helpTip = "The resolution value doesn't change the pixel dimensions!";

        // Aspect ratio calculation
        var originalAspectRatio = currentWidth / currentHeight;

        // Constrain Proportions checkbox
        var constrainCheck = mainPanel.add('checkbox', undefined, 'Constrain Aspect Ratio');
        constrainCheck.value = true;

        // Scale Styles checkbox
        var scaleStylesCheck = mainPanel.add('checkbox', undefined, 'Scale Styles');
        scaleStylesCheck.value = true; // Default to true
        scaleStylesCheck.enabled = constrainCheck.value; // Initially enabled

        // Event listener for Constrain Proportions checkbox
        constrainCheck.onClick = function () {
            if (constrainCheck.value) {
                scaleStylesCheck.enabled = true;
                scaleStylesCheck.value = true; // Reset to true when re-enabled
            } else {
                scaleStylesCheck.enabled = false;
                scaleStylesCheck.value = false; // Disable and uncheck when proportions are disabled
            }
        };

        // Add Interpolation dropdown group
        var interpolationGroup = mainPanel.add('group');
        interpolationGroup.orientation = 'row';
        interpolationGroup.alignChildren = ['left', 'center'];
        interpolationGroup.add('statictext', undefined, 'Interpolation: ');
        var interpolationDropdown = interpolationGroup.add('dropdownlist', undefined, [
            'Nearest Neighbor',
            'Bilinear',
            'Bicubic',
            'Bicubic Smoother',
            'Bicubic Sharper',
            'Bicubic Automatic',
            'Preserve Details',
            'Preserve Details 2.0'
        ]);
        interpolationDropdown.selection = 2; // Default to 'Bicubic'

        // Width input change handler
        widthInput.onChange = function () {
            if (constrainCheck.value) {
                var newWidth = parseFloat(widthInput.text);
                var newHeight = Math.round(newWidth / originalAspectRatio);
                heightInput.text = newHeight.toString();
            }
        };

        // Height input change handler
        heightInput.onChange = function () {
            if (constrainCheck.value) {
                var newHeight = parseFloat(heightInput.text);
                var newWidth = Math.round(newHeight * originalAspectRatio);
                widthInput.text = newWidth.toString();
            }
        };

        // Buttons group
        var buttonGroup = dialog.add('group');
        buttonGroup.orientation = 'row';
        buttonGroup.alignment = 'right';

        // Cancel button
        var cancelButton = buttonGroup.add('button', undefined, 'Cancel');
        cancelButton.onClick = function () {
            dialog.close();
        };

        // OK button
        var okButton = buttonGroup.add('button', undefined, 'OK');
        okButton.onClick = function () {
            try {
                var width = parseFloat(widthInput.text);
                var height = parseFloat(heightInput.text);
                var resolution = parseFloat(resolutionInput.text);

                if (isNaN(width) || width <= 0) {
                    alert('Please enter a valid width.');
                    return;
                }

                if (isNaN(height) || height <= 0) {
                    alert('Please enter a valid height.');
                    return;
                }

                if (isNaN(resolution) || resolution <= 0) {
                    alert('Please enter a valid resolution.');
                    return;
                }

                var interpolation = interpolationDropdown.selection.text;

                resizeImage(
                    width,
                    height,
                    resolution,
                    scaleStylesCheck.value,
                    constrainCheck.value,
                    interpolation
                );

                dialog.close();
            } catch (e) {
                alert('Error: ' + e.toString());
            }
        };

        // Show the dialog
        dialog.show();
    }


    // Functions

    function s2t(s) {
        return app.stringIDToTypeID(s);
    }
    function resizeImage(width, height, resolution, scaleStyles, constrainProportions, interpolation) {
        var descriptor = new ActionDescriptor();
        descriptor.putUnitDouble(s2t("width"), s2t("pixelsUnit"), width);
        descriptor.putUnitDouble(s2t("height"), s2t("pixelsUnit"), height);
        descriptor.putUnitDouble(s2t("resolution"), s2t("densityUnit"), resolution);
        if (constrainProportions !== undefined) {
            descriptor.putBoolean(s2t("constrainProportions"), constrainProportions);
        }
        if (constrainProportions && scaleStyles !== undefined) {
            descriptor.putBoolean(s2t("scaleStyles"), scaleStyles);
        }
        var interpolationTypes = {
            'Nearest Neighbor': s2t("nearestNeighbor"),
            'Bilinear': s2t("bilinear"),
            'Bicubic': s2t("bicubic"),
            'Bicubic Smoother': s2t("bicubicSmoother"),
            'Bicubic Sharper': s2t("bicubicSharper"),
            'Bicubic Automatic': s2t("bicubicAutomatic"),
            'Preserve Details': s2t("preserveDetailsUpscale"),
            'Preserve Details 2.0': s2t("deepUpscale")
        };
        if (interpolation in interpolationTypes) {
            descriptor.putEnumerated(
                s2t("interfaceIconFrameDimmed"),
                s2t("interpolationType"),
                interpolationTypes[interpolation]
            );
        }
        executeAction(s2t("imageSize"), descriptor, DialogModes.NO);
    }

    function main() {
        if (app.documents.length === 0) {
            alert('A document must be open to run this script!');
            return;
        }
        createResizeDialog();
    }

} catch (err) {
    alert("Error!" + "\r" + err + ' ' + err.line);
}

 

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

Votes

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
Community Expert ,
Nov 30, 2024 Nov 30, 2024

Copy link to clipboard

Copied

The following script re-creates (most) of the functionality of Image > Image Size without a preview, this one using PERCENT as the fixed unit of measure.

 

/*
Image Size Sans Preview as PERCENT.jsx
Stephen Marsh
v1.0, 30th November 2024
https://community.adobe.com/t5/photoshop-ecosystem-discussions/image-preview-in-resize-dialog/td-p/9846795
*/

#target photoshop;

try {

    main();

    function createResizeDialog() {
        // Get current document dimensions
        var doc = app.activeDocument;
        var currentResolution = doc.resolution;
        var currentWidthPixels = doc.width.as('px');
        var currentHeightPixels = doc.height.as('px');

        // Create the main window
        var dialog = new Window('dialog', 'Image Size Sans Preview (v1.0)');
        dialog.orientation = 'column';
        dialog.alignChildren = ['fill', 'top'];
        dialog.preferredSize.width = 325;

        // Add a panel to group interface elements
        var mainPanel = dialog.add('panel', undefined, 'UNITS: PERCENT');
        mainPanel.orientation = 'column';
        mainPanel.alignChildren = ['fill', 'top'];
        mainPanel.margins = [15, 15, 15, 15];

        // Pixel dimension display group
        var pixelDisplayGroup = mainPanel.add('group');
        pixelDisplayGroup.orientation = 'column';
        pixelDisplayGroup.alignChildren = ['fill', 'center'];
        var originalPixelsText = pixelDisplayGroup.add('statictext', undefined, 'Original:   ' + currentWidthPixels + ' x ' + currentHeightPixels + ' PX @ ' + currentResolution + ' PPI');

        var separatorLine = pixelDisplayGroup.add("panel");
        separatorLine.alignment = "fill";
        separatorLine.preferredSize.height = 1;

        var newPixelsText = pixelDisplayGroup.add('statictext', undefined, 'New Size: ' + currentWidthPixels + ' x ' + currentHeightPixels + ' PX @ ' + currentResolution + ' PPI');
        originalPixelsText.graphics.font = "dialog-regular:13";
        newPixelsText.graphics.font = "dialog-regular:13";

        // Width input group
        var widthGroup = mainPanel.add('group');
        widthGroup.orientation = 'row';
        widthGroup.alignChildren = ['left', 'center'];
        widthGroup.add('statictext', undefined, 'Width (%):  ');
        var widthInput = widthGroup.add('editnumber', undefined, 100);
        widthInput.preferredSize.width = 170;

        // Height input group
        var heightGroup = mainPanel.add('group');
        heightGroup.orientation = 'row';
        heightGroup.alignChildren = ['left', 'center'];
        heightGroup.add('statictext', undefined, 'Height (%): ');
        var heightInput = heightGroup.add('editnumber', undefined, 100);
        heightInput.preferredSize.width = 170;

        // Resolution input group
        var resolutionGroup = mainPanel.add('group');
        resolutionGroup.orientation = 'row';
        resolutionGroup.alignChildren = ['left', 'center'];
        resolutionGroup.add('statictext', undefined, 'Resolution (PPI): ');
        var resolutionInput = resolutionGroup.add('editnumber', undefined, currentResolution);
        resolutionInput.preferredSize.width = 138; // visually fudge the width
        resolutionInput.helpTip = "The resolution value doesn't change the pixel dimensions!";

        // Function to update pixel dimension text
        function updatePixelDimensions() {
            var widthPercent = parseFloat(widthInput.text) / 100;
            var heightPercent = parseFloat(heightInput.text) / 100;
            var resolution = parseFloat(resolutionInput.text);

            var newWidthPixels = Math.round(currentWidthPixels * widthPercent);
            var newHeightPixels = Math.round(currentHeightPixels * heightPercent);

            newPixelsText.text = 'New Size: ' + newWidthPixels + ' x ' + newHeightPixels + ' PX @ ' + resolution + ' PPI';
        }

        // Constrain Proportions checkbox
        var constrainCheck = mainPanel.add('checkbox', undefined, 'Constrain Aspect Ratio');
        constrainCheck.value = true;

        // Scale Styles checkbox
        var scaleStylesCheck = mainPanel.add('checkbox', undefined, 'Scale Styles');
        scaleStylesCheck.value = true; // Default to true
        scaleStylesCheck.enabled = constrainCheck.value; // Initially enabled

        // Event listener for Constrain Proportions checkbox
        constrainCheck.onClick = function () {
            if (constrainCheck.value) {
                scaleStylesCheck.enabled = true;
                scaleStylesCheck.value = true; // Reset to true when re-enabled
            } else {
                scaleStylesCheck.enabled = false;
                scaleStylesCheck.value = false; // Disable and uncheck when proportions are disabled
            }
        };

        // Add Interpolation dropdown group
        var interpolationGroup = mainPanel.add('group');
        interpolationGroup.orientation = 'row';
        interpolationGroup.alignChildren = ['left', 'center'];
        interpolationGroup.add('statictext', undefined, 'Interpolation: ');
        var interpolationDropdown = interpolationGroup.add('dropdownlist', undefined, [
            'Nearest Neighbor',
            'Bilinear',
            'Bicubic',
            'Bicubic Smoother',
            'Bicubic Sharper',
            'Bicubic Automatic',
            'Preserve Details',
            'Preserve Details 2.0'
        ]);
        interpolationDropdown.selection = 2; // Default to 'Bicubic'

        // Width input change handler
        widthInput.onChange = function () {
            if (constrainCheck.value) {
                var newWidthPercent = parseFloat(widthInput.text);
                var newHeightPercent = newWidthPercent;
                heightInput.text = newHeightPercent.toString();
            }
            updatePixelDimensions();
        };

        // Height input change handler
        heightInput.onChange = function () {
            if (constrainCheck.value) {
                var newHeightPercent = parseFloat(heightInput.text);
                var newWidthPercent = newHeightPercent;
                widthInput.text = newWidthPercent.toString();
            }
            updatePixelDimensions();
        };

        // Resolution input change handler
        resolutionInput.onChange = updatePixelDimensions;

        // Buttons group
        var buttonGroup = dialog.add('group');
        buttonGroup.orientation = 'row';
        buttonGroup.alignment = 'right';

        // Cancel button
        var cancelButton = buttonGroup.add('button', undefined, 'Cancel');
        cancelButton.onClick = function () {
            dialog.close();
        };

        // OK button
        var okButton = buttonGroup.add('button', undefined, 'OK');
        okButton.onClick = function () {
            try {
                var widthPercent = parseFloat(widthInput.text) / 100;
                var heightPercent = parseFloat(heightInput.text) / 100;
                var resolution = parseFloat(resolutionInput.text);

                var widthPixels = currentWidthPixels * widthPercent;
                var heightPixels = currentHeightPixels * heightPercent;

                if (isNaN(widthPercent) || widthPercent <= 0) {
                    alert('Please enter a valid width percentage.');
                    return;
                }

                if (isNaN(heightPercent) || heightPercent <= 0) {
                    alert('Please enter a valid height percentage.');
                    return;
                }

                if (isNaN(resolution) || resolution <= 0) {
                    alert('Please enter a valid resolution.');
                    return;
                }

                var interpolation = interpolationDropdown.selection.text;

                resizeImage(
                    widthPixels,
                    heightPixels,
                    resolution,
                    scaleStylesCheck.value,
                    constrainCheck.value,
                    interpolation
                );

                dialog.close();
            } catch (e) {
                alert('Error: ' + e.toString());
            }
        };

        // Update pixel dimensions initially
        updatePixelDimensions();

        // Show the dialog
        dialog.show();
    }


    // Functions

    function s2t(s) {
        return app.stringIDToTypeID(s);
    }

    function resizeImage(width, height, resolution, scaleStyles, constrainProportions, interpolation) {
        var descriptor = new ActionDescriptor();
        descriptor.putUnitDouble(s2t("width"), s2t("pixelsUnit"), width);
        descriptor.putUnitDouble(s2t("height"), s2t("pixelsUnit"), height);
        descriptor.putUnitDouble(s2t("resolution"), s2t("densityUnit"), resolution);
        if (constrainProportions !== undefined) {
            descriptor.putBoolean(s2t("constrainProportions"), constrainProportions);
        }
        if (constrainProportions && scaleStyles !== undefined) {
            descriptor.putBoolean(s2t("scaleStyles"), scaleStyles);
        }
        var interpolationTypes = {
            'Nearest Neighbor': s2t("nearestNeighbor"),
            'Bilinear': s2t("bilinear"),
            'Bicubic': s2t("bicubic"),
            'Bicubic Smoother': s2t("bicubicSmoother"),
            'Bicubic Sharper': s2t("bicubicSharper"),
            'Bicubic Automatic': s2t("bicubicAutomatic"),
            'Preserve Details': s2t("preserveDetailsUpscale"),
            'Preserve Details 2.0': s2t("deepUpscale")
        };
        if (interpolation in interpolationTypes) {
            descriptor.putEnumerated(
                s2t("interfaceIconFrameDimmed"),
                s2t("interpolationType"),
                interpolationTypes[interpolation]
            );
        }
        executeAction(s2t("imageSize"), descriptor, DialogModes.NO);
    }

    function main() {
        if (app.documents.length === 0) {
            alert('A document must be open to run this script!');
            return;
        }
        createResizeDialog();
    }

} catch (err) {
    alert("Error!" + "\r" + err + ' ' + err.line);
}

 

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

Votes

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
Community Expert ,
Nov 30, 2024 Nov 30, 2024

Copy link to clipboard

Copied

The following script re-creates (most) of the functionality of Image > Image Size without a preview, this one using INCHES as the fixed unit of measure. 

 

/*
Image Size Sans Preview as INCHES.jsx
Stephen Marsh
v1.0, 30th November 2024
https://community.adobe.com/t5/photoshop-ecosystem-discussions/image-preview-in-resize-dialog/td-p/9846795
*/

#target photoshop;

try {

    main();

    function createResizeDialog() {
        // Get current document dimensions
        var doc = app.activeDocument;
        var currentWidthInches = doc.width.as('in');
        var currentHeightInches = doc.height.as('in');
        var currentResolution = doc.resolution;
        var currentWidthPixels = doc.width.as('px');
        var currentHeightPixels = doc.height.as('px');

        // Create the main window
        var dialog = new Window('dialog', 'Image Size Sans Preview (v1.0)');
        dialog.orientation = 'column';
        dialog.alignChildren = ['fill', 'top'];
        dialog.preferredSize.width = 325;

        // Add a panel to group interface elements
        var mainPanel = dialog.add('panel', undefined, 'UNITS: INCHES');
        mainPanel.orientation = 'column';
        mainPanel.alignChildren = ['fill', 'top'];
        mainPanel.margins = [15, 15, 15, 15];

        // Pixel dimension display group
        var pixelDisplayGroup = mainPanel.add('group');
        pixelDisplayGroup.orientation = 'column';
        pixelDisplayGroup.alignChildren = ['fill', 'center'];
        var originalPixelsText = pixelDisplayGroup.add('statictext', undefined, 'Original:   ' + currentWidthPixels + ' x ' + currentHeightPixels + ' PX @ ' + currentResolution + ' PPI');

        var separatorLine = pixelDisplayGroup.add("panel");
        separatorLine.alignment = "fill";
        separatorLine.preferredSize.height = 1;

        var newPixelsText = pixelDisplayGroup.add('statictext', undefined, 'New Size: ' + currentWidthPixels + ' x ' + currentHeightPixels + ' PX @ ' + currentResolution + ' PPI');
        originalPixelsText.graphics.font = "dialog-regular:13";
        newPixelsText.graphics.font = "dialog-regular:13";

        // Width input group
        var widthGroup = mainPanel.add('group');
        widthGroup.orientation = 'row';
        widthGroup.alignChildren = ['left', 'center'];
        widthGroup.add('statictext', undefined, 'Width (IN): '); // Fudge the alignment with a space
        var widthInput = widthGroup.add('editnumber', undefined, currentWidthInches);
        widthInput.preferredSize.width = 175;
        //widthInput.characters = 10;

        // Height input group
        var heightGroup = mainPanel.add('group');
        heightGroup.orientation = 'row';
        heightGroup.alignChildren = ['left', 'center'];
        heightGroup.add('statictext', undefined, 'Height (IN):');
        var heightInput = heightGroup.add('editnumber', undefined, currentHeightInches);
        heightInput.preferredSize.width = 175;
        //heightInput.characters = 10;

        // Resolution input group
        var resolutionGroup = mainPanel.add('group');
        resolutionGroup.orientation = 'row';
        resolutionGroup.alignChildren = ['left', 'center'];
        resolutionGroup.add('statictext', undefined, 'Resolution (PPI):');
        var resolutionInput = resolutionGroup.add('editnumber', undefined, currentResolution);
        resolutionInput.preferredSize.width = 145;
        //resolutionInput.characters = 10;
        resolutionInput.helpTip = "The resolution value changes the pixel dimensions!";


        // Aspect ratio calculation
        var originalAspectRatio = currentWidthInches / currentHeightInches;

        // Function to update pixel dimension text
        function updatePixelDimensions() {
            var widthInches = parseFloat(widthInput.text);
            var heightInches = parseFloat(heightInput.text);
            var resolution = parseFloat(resolutionInput.text);

            var newWidthPixels = Math.round(widthInches * resolution);
            var newHeightPixels = Math.round(heightInches * resolution);

            newPixelsText.text = 'New Size: ' + newWidthPixels + ' x ' + newHeightPixels + ' PX @ ' + resolution + ' PPI';
        }

        // Constrain Proportions checkbox
        var constrainCheck = mainPanel.add('checkbox', undefined, 'Constrain Aspect Ratio');
        constrainCheck.value = true;

        // Scale Styles checkbox
        var scaleStylesCheck = mainPanel.add('checkbox', undefined, 'Scale Styles');
        scaleStylesCheck.value = true; // Default to true
        scaleStylesCheck.enabled = constrainCheck.value; // Initially enabled

        // Event listener for Constrain Proportions checkbox
        constrainCheck.onClick = function () {
            if (constrainCheck.value) {
                scaleStylesCheck.enabled = true;
                scaleStylesCheck.value = true; // Reset to true when re-enabled
            } else {
                scaleStylesCheck.enabled = false;
                scaleStylesCheck.value = false; // Disable and uncheck when proportions are disabled
            }
        };

        // Add Interpolation dropdown group
        var interpolationGroup = mainPanel.add('group');
        interpolationGroup.orientation = 'row';
        interpolationGroup.alignChildren = ['left', 'center'];
        interpolationGroup.add('statictext', undefined, 'Interpolation: ');
        var interpolationDropdown = interpolationGroup.add('dropdownlist', undefined, [
            'Nearest Neighbor',
            'Bilinear',
            'Bicubic',
            'Bicubic Smoother',
            'Bicubic Sharper',
            'Bicubic Automatic',
            'Preserve Details',
            'Preserve Details 2.0'
        ]);
        interpolationDropdown.selection = 2; // Default to 'Bicubic'

        // Width input change handler
        widthInput.onChange = function () {
            if (constrainCheck.value) {
                var newWidth = parseFloat(widthInput.text);
                var newHeight = newWidth / originalAspectRatio;
                heightInput.text = newHeight.toString();
            }
            updatePixelDimensions();
        };

        // Height input change handler
        heightInput.onChange = function () {
            if (constrainCheck.value) {
                var newHeight = parseFloat(heightInput.text);
                var newWidth = newHeight * originalAspectRatio;
                widthInput.text = newWidth.toString();
            }
            updatePixelDimensions();
        };

        // Resolution input change handler
        resolutionInput.onChange = updatePixelDimensions;

        // Buttons group
        var buttonGroup = dialog.add('group');
        buttonGroup.orientation = 'row';
        buttonGroup.alignment = 'right';

        // Cancel button
        var cancelButton = buttonGroup.add('button', undefined, 'Cancel');
        cancelButton.onClick = function () {
            dialog.close();
        };

        // OK button
        var okButton = buttonGroup.add('button', undefined, 'OK');
        okButton.onClick = function () {
            try {
                var widthInches = parseFloat(widthInput.text);
                var heightInches = parseFloat(heightInput.text);
                var resolution = parseFloat(resolutionInput.text);
                var widthPixels = widthInches * resolution;
                var heightPixels = heightInches * resolution;

                if (isNaN(widthInches) || widthInches <= 0) {
                    alert('Please enter a valid width.');
                    return;
                }

                if (isNaN(heightInches) || heightInches <= 0) {
                    alert('Please enter a valid height.');
                    return;
                }

                if (isNaN(resolution) || resolution <= 0) {
                    alert('Please enter a valid resolution.');
                    return;
                }

                var interpolation = interpolationDropdown.selection.text;

                resizeImage(
                    widthPixels,
                    heightPixels,
                    resolution,
                    scaleStylesCheck.value,
                    constrainCheck.value,
                    interpolation
                );

                dialog.close();
            } catch (e) {
                alert('Error: ' + e.toString());
            }
        };

        // Update pixel dimensions initially
        updatePixelDimensions();

        // Show the dialog
        dialog.show();
    }


    // Functions

    function s2t(s) {
        return app.stringIDToTypeID(s);
    }
    function resizeImage(width, height, resolution, scaleStyles, constrainProportions, interpolation) {
        var descriptor = new ActionDescriptor();
        descriptor.putUnitDouble(s2t("width"), s2t("pixelsUnit"), width);
        descriptor.putUnitDouble(s2t("height"), s2t("pixelsUnit"), height);
        descriptor.putUnitDouble(s2t("resolution"), s2t("densityUnit"), resolution);
        if (constrainProportions !== undefined) {
            descriptor.putBoolean(s2t("constrainProportions"), constrainProportions);
        }
        if (constrainProportions && scaleStyles !== undefined) {
            descriptor.putBoolean(s2t("scaleStyles"), scaleStyles);
        }
        var interpolationTypes = {
            'Nearest Neighbor': s2t("nearestNeighbor"),
            'Bilinear': s2t("bilinear"),
            'Bicubic': s2t("bicubic"),
            'Bicubic Smoother': s2t("bicubicSmoother"),
            'Bicubic Sharper': s2t("bicubicSharper"),
            'Bicubic Automatic': s2t("bicubicAutomatic"),
            'Preserve Details': s2t("preserveDetailsUpscale"),
            'Preserve Details 2.0': s2t("deepUpscale")
        };
        if (interpolation in interpolationTypes) {
            descriptor.putEnumerated(
                s2t("interfaceIconFrameDimmed"),
                s2t("interpolationType"),
                interpolationTypes[interpolation]
            );
        }
        executeAction(s2t("imageSize"), descriptor, DialogModes.NO);
    }

    function main() {
        if (app.documents.length === 0) {
            alert('A document must be open to run this script!');
            return;
        }
        createResizeDialog();
    }

} catch (err) {
    alert("Error!" + "\r" + err + ' ' + err.line);
}

 

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

Votes

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
Community Expert ,
Nov 30, 2024 Nov 30, 2024

Copy link to clipboard

Copied

The following script re-creates (most) of the functionality of Image > Image Size without a preview, this one using CM as the fixed unit of measure.

 

/*
Image Size Sans Preview as CM.jsx
Stephen Marsh
v1.0, 30th November 2024
https://community.adobe.com/t5/photoshop-ecosystem-discussions/image-preview-in-resize-dialog/td-p/9846795
*/

#target photoshop;

try {

    main();

    function createResizeDialog() {
        // Get current document dimensions
        var doc = app.activeDocument;
        var currentWidthCm = doc.width.as('cm');
        var currentHeightCm = doc.height.as('cm');
        var currentResolution = doc.resolution;
        var currentWidthPixels = doc.width.as('px');
        var currentHeightPixels = doc.height.as('px');

        // Create the main window
        var dialog = new Window('dialog', 'Image Size Sans Preview (v1.0)');
        dialog.orientation = 'column';
        dialog.alignChildren = ['fill', 'top'];
        dialog.preferredSize.width = 325;

        // Add a panel to group interface elements
        var mainPanel = dialog.add('panel', undefined, 'UNITS: CENTIMETERS');
        mainPanel.orientation = 'column';
        mainPanel.alignChildren = ['fill', 'top'];
        mainPanel.margins = [15, 15, 15, 15];

        // Pixel dimension display group
        var pixelDisplayGroup = mainPanel.add('group');
        pixelDisplayGroup.orientation = 'column';
        pixelDisplayGroup.alignChildren = ['fill', 'center'];
        var originalPixelsText = pixelDisplayGroup.add('statictext', undefined, 'Original:   ' + currentWidthPixels + ' x ' + currentHeightPixels + ' PX @ ' + currentResolution + ' PPI');

        var separatorLine = pixelDisplayGroup.add("panel");
        separatorLine.alignment = "fill";
        separatorLine.preferredSize.height = 1;

        var newPixelsText = pixelDisplayGroup.add('statictext', undefined, 'New Size: ' + currentWidthPixels + ' x ' + currentHeightPixels + ' PX @ ' + currentResolution + ' PPI');
        originalPixelsText.graphics.font = "dialog-regular:13";
        newPixelsText.graphics.font = "dialog-regular:13";

        // Width input group
        var widthGroup = mainPanel.add('group');
        widthGroup.orientation = 'row';
        widthGroup.alignChildren = ['left', 'center'];
        widthGroup.add('statictext', undefined, 'Width (CM): ');
        var widthInput = widthGroup.add('editnumber', undefined, currentWidthCm);
        widthInput.preferredSize.width = 170;

        // Height input group
        var heightGroup = mainPanel.add('group');
        heightGroup.orientation = 'row';
        heightGroup.alignChildren = ['left', 'center'];
        heightGroup.add('statictext', undefined, 'Height (CM):');
        var heightInput = heightGroup.add('editnumber', undefined, currentHeightCm);
        heightInput.preferredSize.width = 170;

        // Resolution input group
        var resolutionGroup = mainPanel.add('group');
        resolutionGroup.orientation = 'row';
        resolutionGroup.alignChildren = ['left', 'center'];
        resolutionGroup.add('statictext', undefined, 'Resolution (PPI): ');
        var resolutionInput = resolutionGroup.add('editnumber', undefined, currentResolution);
        resolutionInput.preferredSize.width = 144;
        resolutionInput.helpTip = "The resolution value changes the pixel dimensions!";

        // Aspect ratio calculation
        var originalAspectRatio = currentWidthCm / currentHeightCm;

        // Function to update pixel dimension text
        function updatePixelDimensions() {
            var widthCm = parseFloat(widthInput.text);
            var heightCm = parseFloat(heightInput.text);
            var resolution = parseFloat(resolutionInput.text);

            var newWidthPixels = Math.round(widthCm * resolution / 2.54);
            var newHeightPixels = Math.round(heightCm * resolution / 2.54);

            newPixelsText.text = 'New Size: ' + newWidthPixels + ' x ' + newHeightPixels + ' PX @ ' + resolution + ' PPI';
        }

        // Constrain Proportions checkbox
        var constrainCheck = mainPanel.add('checkbox', undefined, 'Constrain Aspect Ratio');
        constrainCheck.value = true;

        // Scale Styles checkbox
        var scaleStylesCheck = mainPanel.add('checkbox', undefined, 'Scale Styles');
        scaleStylesCheck.value = true;
        scaleStylesCheck.enabled = constrainCheck.value;

        // Event listener for Constrain Proportions checkbox
        constrainCheck.onClick = function () {
            if (constrainCheck.value) {
                scaleStylesCheck.enabled = true;
                scaleStylesCheck.value = true;
            } else {
                scaleStylesCheck.enabled = false;
                scaleStylesCheck.value = false;
            }
        };

        // Add Interpolation dropdown group
        var interpolationGroup = mainPanel.add('group');
        interpolationGroup.orientation = 'row';
        interpolationGroup.alignChildren = ['left', 'center'];
        interpolationGroup.add('statictext', undefined, 'Interpolation: ');
        var interpolationDropdown = interpolationGroup.add('dropdownlist', undefined, [
            'Nearest Neighbor',
            'Bilinear',
            'Bicubic',
            'Bicubic Smoother',
            'Bicubic Sharper',
            'Bicubic Automatic',
            'Preserve Details',
            'Preserve Details 2.0'
        ]);
        interpolationDropdown.selection = 2;

        // Width input change handler
        widthInput.onChange = function () {
            if (constrainCheck.value) {
                var newWidth = parseFloat(widthInput.text);
                var newHeight = newWidth / originalAspectRatio;
                heightInput.text = newHeight.toString();
            }
            updatePixelDimensions();
        };

        // Height input change handler
        heightInput.onChange = function () {
            if (constrainCheck.value) {
                var newHeight = parseFloat(heightInput.text);
                var newWidth = newHeight * originalAspectRatio;
                widthInput.text = newWidth.toString();
            }
            updatePixelDimensions();
        };

        // Resolution input change handler
        resolutionInput.onChange = updatePixelDimensions;

        // Buttons group
        var buttonGroup = dialog.add('group');
        buttonGroup.orientation = 'row';
        buttonGroup.alignment = 'right';

        // Cancel button
        var cancelButton = buttonGroup.add('button', undefined, 'Cancel');
        cancelButton.onClick = function () {
            dialog.close();
        };

        // OK button
        var okButton = buttonGroup.add('button', undefined, 'OK');
        okButton.onClick = function () {
            try {
                var widthCm = parseFloat(widthInput.text);
                var heightCm = parseFloat(heightInput.text);
                var resolution = parseFloat(resolutionInput.text);
                var widthPixels = widthCm * resolution / 2.54;
                var heightPixels = heightCm * resolution / 2.54;

                if (isNaN(widthCm) || widthCm <= 0) {
                    alert('Please enter a valid width.');
                    return;
                }

                if (isNaN(heightCm) || heightCm <= 0) {
                    alert('Please enter a valid height.');
                    return;
                }

                if (isNaN(resolution) || resolution <= 0) {
                    alert('Please enter a valid resolution.');
                    return;
                }

                var interpolation = interpolationDropdown.selection.text;

                resizeImage(
                    widthPixels,
                    heightPixels,
                    resolution,
                    scaleStylesCheck.value,
                    constrainCheck.value,
                    interpolation
                );

                dialog.close();
            } catch (e) {
                alert('Error: ' + e.toString());
            }
        };

        // Update pixel dimensions initially
        updatePixelDimensions();

        // Show the dialog
        dialog.show();
    }


    // Functions

    function s2t(s) {
        return app.stringIDToTypeID(s);
    }
    function resizeImage(width, height, resolution, scaleStyles, constrainProportions, interpolation) {
        var descriptor = new ActionDescriptor();
        descriptor.putUnitDouble(s2t("width"), s2t("pixelsUnit"), width);
        descriptor.putUnitDouble(s2t("height"), s2t("pixelsUnit"), height);
        descriptor.putUnitDouble(s2t("resolution"), s2t("densityUnit"), resolution);
        if (constrainProportions !== undefined) {
            descriptor.putBoolean(s2t("constrainProportions"), constrainProportions);
        }
        if (constrainProportions && scaleStyles !== undefined) {
            descriptor.putBoolean(s2t("scaleStyles"), scaleStyles);
        }
        var interpolationTypes = {
            'Nearest Neighbor': s2t("nearestNeighbor"),
            'Bilinear': s2t("bilinear"),
            'Bicubic': s2t("bicubic"),
            'Bicubic Smoother': s2t("bicubicSmoother"),
            'Bicubic Sharper': s2t("bicubicSharper"),
            'Bicubic Automatic': s2t("bicubicAutomatic"),
            'Preserve Details': s2t("preserveDetailsUpscale"),
            'Preserve Details 2.0': s2t("deepUpscale")
        };
        if (interpolation in interpolationTypes) {
            descriptor.putEnumerated(
                s2t("interfaceIconFrameDimmed"),
                s2t("interpolationType"),
                interpolationTypes[interpolation]
            );
        }
        executeAction(s2t("imageSize"), descriptor, DialogModes.NO);
    }

    function main() {
        if (app.documents.length === 0) {
            alert('A document must be open to run this script!');
            return;
        }
        createResizeDialog();
    }

} catch (err) {
    alert("Error!" + "\r" + err + ' ' + err.line);
}

 

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

Votes

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
Community Expert ,
Nov 30, 2024 Nov 30, 2024

Copy link to clipboard

Copied

LATEST

Votes

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