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

Cropping script help

Community Beginner ,
Oct 06, 2015 Oct 06, 2015

Copy link to clipboard

Copied

I need a script to crop any images to this size 3000 x 2247 at 72 DPi can any one help me out please

TOPICS
Actions and scripting

Views

620

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
Participant ,
Oct 06, 2015 Oct 06, 2015

Copy link to clipboard

Copied

What are you mean by "any images"? All layers from current document or all images from folder?

And whats happened after cropping?

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 ,
Oct 06, 2015 Oct 06, 2015

Copy link to clipboard

Copied

After cropping image size will be 3000 x 2247 at 72 DPi . Ex. if the image size is 5400 X 4500 with 300dpi after running the script it changes to 3000 x 2247 at 72 DPi .. this is what i wanted buddy.

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
Participant ,
Oct 06, 2015 Oct 06, 2015

Copy link to clipboard

Copied

resizeAndCrop(3000, 2247);

function resizeAndCrop(newWidth, newHeight) {

    var doc = app.activeDocument,

        originalRulerUnits = preferences.rulerUnits;

    preferences.rulerUnits = Units.PIXELS;

    var docW = doc.width.value,

        docH = doc.height.value;

    resizeImage();

    resizeCanvas();

    // Image Size

    function resizeImage() {

        var desc1 = new ActionDescriptor();

        if (docW < docH) {

            desc1.putUnitDouble(charIDToTypeID('Wdth'), charIDToTypeID('#Pxl'), newWidth);

        } else {

            desc1.putUnitDouble(charIDToTypeID('Hght'), charIDToTypeID('#Pxl'), newHeight);

        }

        desc1.putUnitDouble(charIDToTypeID('Rslt'), charIDToTypeID('#Rsl'), 72);

        desc1.putBoolean(stringIDToTypeID("scaleStyles"), true);

        desc1.putBoolean(charIDToTypeID('CnsP'), true);

        desc1.putEnumerated(charIDToTypeID('Intr'), charIDToTypeID('Intp'), stringIDToTypeID("automaticInterpolation"));

        executeAction(stringIDToTypeID('imageSize'), desc1, DialogModes.NO);

    }

    // Canvas Size

    function resizeCanvas() {

        var desc1 = new ActionDescriptor();

        if (docW < docH) {

            desc1.putUnitDouble(charIDToTypeID('Hght'), charIDToTypeID('#Pxl'), newHeight);

        } else {

            desc1.putUnitDouble(charIDToTypeID('Wdth'), charIDToTypeID('#Pxl'), newWidth);

        }

        desc1.putEnumerated(charIDToTypeID('Vrtc'), charIDToTypeID('VrtL'), charIDToTypeID('Cntr'));

        desc1.putEnumerated(charIDToTypeID('Hrzn'), charIDToTypeID('HrzL'), charIDToTypeID('Cntr'));

        desc1.putEnumerated(stringIDToTypeID("canvasExtensionColorType"), stringIDToTypeID("canvasExtensionColorType"), charIDToTypeID('BckC'));

        executeAction(stringIDToTypeID('canvasSize'), desc1, DialogModes.NO);

    }

    preferences.rulerUnits = originalRulerUnits;

}

or just crop

resizeCanvas(3000, 2247);

function resizeCanvas(newWidth, newHeight) {

    var desc1 = new ActionDescriptor();

    desc1.putUnitDouble(charIDToTypeID('Wdth'), charIDToTypeID('#Pxl'), newWidth);

    desc1.putUnitDouble(charIDToTypeID('Hght'), charIDToTypeID('#Pxl'), newHeight);

    desc1.putEnumerated(charIDToTypeID('Vrtc'), charIDToTypeID('VrtL'), charIDToTypeID('Cntr'));

    desc1.putEnumerated(charIDToTypeID('Hrzn'), charIDToTypeID('HrzL'), charIDToTypeID('Cntr'));

    desc1.putEnumerated(stringIDToTypeID("canvasExtensionColorType"), stringIDToTypeID("canvasExtensionColorType"), charIDToTypeID('BckC'));

    executeAction(stringIDToTypeID('canvasSize'), desc1, DialogModes.NO);

}

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 ,
Oct 06, 2015 Oct 06, 2015

Copy link to clipboard

Copied

I have alignment to add in this will get back to you buddy much appreciated thanks for your help mate.

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 ,
Oct 08, 2015 Oct 08, 2015

Copy link to clipboard

Copied

Hey nvkz Nemo the images which have to resize has an size of 2175 x 2850 with 300 dpi .. i need those images to be resized with the size of 3000 x 2247 with 72 dpi with center alignment

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
Participant ,
Oct 08, 2015 Oct 08, 2015

Copy link to clipboard

Copied

I don't very well understand you.

hardy11111 the code in the my previous post resize and crop any images to 3000 x 2247 (72 dpi).

If you are need only resize you can use File > Automate > Fit Image

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 ,
Oct 08, 2015 Oct 08, 2015

Copy link to clipboard

Copied

resizing is fine nemo .. can you add a code which center align the image ?

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 ,
Oct 08, 2015 Oct 08, 2015

Copy link to clipboard

Copied

hi nemo can you contact me via skype  or gmail ? yogeshwaran1991@gmail.com skyp id = yogeshwaran1991

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 ,
Oct 08, 2015 Oct 08, 2015

Copy link to clipboard

Copied

hi nemo can you contact me via skype  or gmail ? yogeshwaran1991@gmail.com skyp id = yogeshwaran1991

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 ,
Oct 06, 2015 Oct 06, 2015

Copy link to clipboard

Copied

hardy11111 wrote:

After cropping image size will be 3000 x 2247 at 72 DPi . Ex. if the image size is 5400 X 4500 with 300dpi after running the script it changes to 3000 x 2247 at 72 DPi .. this is what i wanted buddy.

Of the 5400x4500 pixels which pixels do you want cropped off. Or do you want the image resized to fit within the 300x2247 pixels area so it composition does not change then add pixels to the resize image to add borders. the add the missing pixels.

If the later a simple action will do the trick

Step 1 Automate Fit Image 3000 width 2247 height

Step 2 Canvas size 3000 width 2247 height

Step 3 Image size resample not checked set dpi to 72.

JJMack

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 ,
Oct 08, 2015 Oct 08, 2015

Copy link to clipboard

Copied

Hey JJMack the images which have to resize has an size of 2175 x 2850 with 300 dpi .. i need those images to be resized with the size of 3000 x 2247 with 72 dpi with center alignment

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 ,
Oct 08, 2015 Oct 08, 2015

Copy link to clipboard

Copied

LATEST

hardy11111 wrote:

Hey JJMack the images which have to resize has an size of 2175 x 2850 with 300 dpi .. i need those images to be resized with the size of 3000 x 2247 with 72 dpi with center alignment

In that case you are putting a portrait aspect ratio image onto a Lanscape canvas. There will be big boarders on both sides.  Your 2175x2850 images will be downsized to 1715x2247 and then 642.5pixel wide canvas borders will be added to the left and right sides.  The action I described will do that and it can be batched.

Capture.jpg

JJMack

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