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

Photo Collage Toolkit - How to Automatically Scale Images to Cutouts

New Here ,
Jun 12, 2019 Jun 12, 2019

Hello,

I am trying to use JJMacks Photo Collage Toolkit.  I would like to know if there is a way to automatically scale the images to cutouts in the collage templates.  If anyone has accomplished this, please share some advice on how to go about it.  Thank you.

3.7K
Translate
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 , Jun 12, 2019 Jun 12, 2019

The scripts in my toolkit will resize your images to fill the image areas in your Collage template they are being populated into.  The image composition in the collage will look like a centered aspect ratio crop that was resized to fill the image area in the collage.  Image that are populated into collage template should have aspect ratios that are close the the Aspect Ratio of the area that they will be places into.  Populating landscape images  into portrait area or a portrait images  into a l

...
Translate
Adobe
Adobe Employee ,
Jun 12, 2019 Jun 12, 2019

Hi there,

I am looping in JJMack, as he might be able to you out with this query.

Regards,
Sahil

Translate
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 ,
Jun 12, 2019 Jun 12, 2019

Thank you for the pointer!  Hope he chimes in...

Translate
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 ,
Jun 12, 2019 Jun 12, 2019

The scripts in my toolkit will resize your images to fill the image areas in your Collage template they are being populated into.  The image composition in the collage will look like a centered aspect ratio crop that was resized to fill the image area in the collage.  Image that are populated into collage template should have aspect ratios that are close the the Aspect Ratio of the area that they will be places into.  Populating landscape images  into portrait area or a portrait images  into a landscape area will result in image composition that will be unacceptable for to much of you image content will be masked off.  You can populate any size image they will be resized for the collage image area.  However, for best results your Image should have the same Aspect ratio as the area they will be populated into.  They are your images and they are your templates make then work well together..

JJMack
Translate
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 ,
Jun 13, 2019 Jun 13, 2019

Thanks for your reply.  I am moving portrait image on to a portrait cutout, but will further adjust the dimensions to see if I can get the desired resizing.  I also found a script on the forum that might work.  Will try it out in the next few days and report back.

Translate
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 ,
Jun 13, 2019 Jun 13, 2019

If all you image have the same portrait Aspect ratio. Like image from your  3:2 aspect ratio DSLR Camera  therefore a  2:3 portrait image.  When you create your templates make Image locations areas have a 2:3 Aspect ratio.  The scripts will place your images into  those 2:3 aspect ratio area perfectly.  No Image content will be masked off.   Its all about Aspect Ratios. Your Images Aspect Aspect Ratios and the Collages Template  Image locations Aspect Ratio.  If the two Aspect Ratios match the resizing will be perfect.

If they do not match the Placed image will look like a centered Aspect Ratio Crop that has been sized for the Collage Image area. What the Script do is resize the image to fill collage image area. Thar resize makes either the width or the height will be the correct size.  The other dimension will be larger then the image area dimension.  This excess image content is masked off to constrain the image  toe the Collages image area.  The mask is  like a virtual Crop.

JJMack
Translate
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 ,
Jun 14, 2019 Jun 14, 2019

Understood - the images I am trying to fit are all different size images that were sized for web, so all over the place in ratio but all portrait.

I have tried different sizes on the Image Locations - still not satisfied with the results and have an idea.  Where would I change the function of the centered Aspect Ratio Crop?  Instead of cropped and masked off by the border of the Image Location, I think it would be possible to replace the crop function with a scale function to fit the image to image location based on width + height?  In this case, nothing would be cropped.  Your thoughts would be appreciated, thank you.

Translate
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 ,
Jun 14, 2019 Jun 14, 2019

My scripts use place and place can degrade images if you are not careful.  If your image files do not have a Print DPI Resolution that you Template has  Place will scale you image which will degrade their quality.  That is how Adobe Programmed Photoshop Place feature. Do not ask me why they did that.  They don't scale when you use copy and paste between documents.  or  Drag and Drop  of layers between document or duplicate layers from one document to an other.  Only place scaled  based on the two resolutions. IMO Adobe should not do this.

As for Aspect Ratio  Alpha channels are like a selections. Selections have a rectangular selection bounds. The max width and the max height  width:height.  A image has a rectangular Canvas width:height.    So an image has a width:height Aspect Ratio as do the collages image location.   If they have the same aspect ratio the resize will be perfect no image content will be lost.   If the Aspect  Ratios are not the same the image resize will be done to fill the collages imag are the width or the height will be a  perfect fit.   However the resized image other dimension will be larger then the Collage's Image location.  So the Image is masked with the Collage's Alpha channel selection.  The image will have the size and shape of you collages image alpga channel need not be a rectangle.  No actual cropping is done.

There your images you create them the with some aspect ratio the  Collages templates you create you create the image locations Alpha Channels.    If the alpha channel Selection bounds matches your image file canvases aspect ratio the resize will be perfect.  The only problem I know users have had with image sizes some users used PNG file that have Transparent Boarders and the  expected these boarders to be in the resized collage's Images.  The Problem is Place Trims off transparent borders so  would copy paste the transparent borders would not be in the clipboard.   The only solution is to remove the transparent boarders without actually removing the transparent boarders by simply adding two 1% opacity pixels. One in the top left corner and one in the bottom right corner of the canvas in the PNG.  No one will ever see these two pixels.

All the scripts do is resize your image to fill the collage images area and masked the Image to your image area shape.   You control all Aspect Ratio.

JJMack
Translate
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 ,
Jun 14, 2019 Jun 14, 2019

JJMack  wrote

There your images you create them the with some aspect ratio the  Collages templates you create you create the image locations Alpha Channels.

Thank you for providing these useful scripts and for your helpful advice.  This was my last resort, which you reiterated with your suggestion.  To make this work for my use case, I will need to resize the images with canvases that are all the same ratio first and then this should work perfectly.  Thanks again, and wish you good health and many blessings!

Translate
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 ,
Jun 14, 2019 Jun 14, 2019

If you resize the image to fit the area the images will not fill the area.  That would be easy to do you have the script change the resize. It is not an option I would want to include,  However if you look at the BatchMockup script in my package  fit to area is an option when the edit mode is used.  You can look at the coed and see the two different resizes.  One to Fill the area the other to fit into the area.  To make it an Option in all the Collage scripts you would also need to update the all the Scripts Dialog to include the option in ScriptUI

You compare the two aspect ratio aspect ratios to know which side toe resize to.

Capture.jpg

JJMack
Translate
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 ,
Jun 14, 2019 Jun 14, 2019

Ok, so I can simply transcribe the following from BatchMockup script to the scripts I want to have this option?

function editContents(newFile, theSO, rotateForBestFit, fitImage) {     

    try {     

        var lyrVis = theSO.visible;  

        app.activeDocument.activeLayer = theSO;   

        var smartObject = openSmartObject (theSO);          // open smart object; 

        smartObject.flatten();   

        smartObject.activeLayer.isBackgroundLayer=0;        // Make it a normal Layer 

        smartObject.selection.selectAll(); 

        smartObject.selection.clear();                      // Clear 

        var objWidth=smartObject.width.value; 

        var objHeight=smartObject.height.value;     

        app.load(newFile);                                  // load it into a document 

        try { 

            var objFile= app.activeDocument;                // image document 

            if (rotateForBestFit) { 

                if (objFile.width.value<objFile.height.value&&objWidth>objHeight ) { objFile.rotateCanvas(-90.0);  } // Rotate portraits 

                if (objFile.height.value<objFile.width.value&&objHeight>objWidth ) { objFile.rotateCanvas(-90.0);  } // Rotate landscapes 

                } 

            if (!fitImage) {         

                if (objFile.width.value/objFile.height.value > objWidth/objHeight) { objFile.resizeImage(null, objHeight, null, ResampleMethod.BICUBIC); } // wider 

                else {objFile.resizeImage(objWidth, null, null, ResampleMethod.BICUBIC);} // same aspect ratio or taller 

            } 

            else{ 

                if (objFile.width.value/objFile.height.value > objWidth/objHeight) {objFile.resizeImage(objWidth, null, null, ResampleMethod.BICUBIC);  }  // wider 

                else {objFile.resizeImage(null, objHeight, null, ResampleMethod.BICUBIC);} 

            } 

            objFile.resizeCanvas(objWidth, objHeight, AnchorPosition.MIDDLECENTER);  

            try{ 

                mrkLayer = objFile.artLayers.add();             // Add a Layer 

                mrkLayer.name = "TL BR Stamp";                  // Name Layer 

                mrkLayer.blendMode = BlendMode.OVERLAY;         // blend mode 

                mrkColor = new SolidColor;                       

                mrkColor.rgb.red = 128; 

                mrkColor.rgb.green = 128; 

                mrkColor.rgb.blue = 128; 

            } 

            catch(e){} 

            try{ 

                var selectedRegion = Array(Array(0,0), Array(1,0), Array(1,1), Array(0,1));  // Top Right 

                objFile.selection.select(selectedRegion);        

                objFile.selection.fill(mrkColor); 

                var selectedRegion = Array(Array(objWidth-1,objHeight-1), Array(objWidth,objHeight-1), Array(objWidth,objHeight), Array(objWidth-1,objHeight)); // Bottom Right 

                objFile.selection.select(selectedRegion);        

                objFile.selection.fill(mrkColor);    

            } 

            catch(e){} 

            objFile.selection.selectAll(); 

            try {objFile.selection.copy(true); }            //copy merge resized image into clipboard 

            catch(e){objFile.selection.copy(); }            //copy resized image into clipboard 

            objFile.close(SaveOptions.DONOTSAVECHANGES);    //close image without saving changes         

            smartObject.paste();                            //paste change smart object content from beinng empty 

        } 

        catch(e) { objFile.close(SaveOptions.DONOTSAVECHANGES); } // close image without saving changes smart oblect is empty though 

        if (smartObject.name.indexOf(".jpg")!=0) smartObject.flatten();  

        smartObject.close(SaveOptions.SAVECHANGES); //close and save 

        theSO.visible = lyrVis;  

        return app.activeDocument.activeLayer     

    }      

    catch(e) { alert(e); }     

}        

Translate
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 ,
Jun 14, 2019 Jun 14, 2019

No you would need to add the Fit image options to all the dialog in all the Collages populating scripts dialogs.  The in the logic in the scripts where the resize is done, you  would need to test the option to see which resize should  be done. The fill area or the fit into area.  Then in each case compare the two aspect ratios involved to see which of the four resizes should be done.  The dialog aand logic in the following scripts would need to be modified. An  ottion like in the mockup scripts

BatchMultiImageCollage.jsx

BatchOneImageCollage.jsx

BatchPicturePackage.jsx

BatchPicturePackageNoRotate.jsx

BatchReplaceOneObject.jsx

CollageTemplateBuilder.jsx

InteractivePopulateCollage.jsx

PopulateCollageTemplate.jsx

PopulatePicturePackage.jsx

ReplaceCollageImage.jsx

TestCollageTemplate.jsx

Capture.jpg

JJMack
Translate
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 ,
Jun 17, 2019 Jun 17, 2019

I experimented with the dialog and options for the script that I am using the most, InteractivePopulateCollage:

Capture_photoshop_collage_toolkit_custom_script.PNG

I could not change the logic in the script code to make the dialog checkbox of "fit image" behave the way I intended. 

What I ended up doing is commenting out the original code and flipping the var percentageChange functions in this part of the script to accomplish what I need for now.  It works with my particular sets of images and scripts right now, but JJMack's suggestion would be much more elegant if I could get it to work.  Unfortunately, my coding knowledge is not up to that task, but I would be happy to try it if someone can share some pointers.

Regardless, quite happy for the workaround and thankful for JJMack's PhotoCollageToolkit.  Plus, I learned how to paste this code snippet in a nice way(Advanced Editing - >> - Syntax Highlighting - Plain) .

if (LWidth/LHeight<SWidth/SHeight) //{ // Smart Object layer Aspect Ratio less the Canvas area Aspect Ratio

//var percentageChange = ((SWidth/LWidth)*100);  // Resize to canvas area width

//activeDocument.activeLayer.resize(percentageChange,percentageChange,AnchorPosition.MIDDLECENTER);

//}

{

var percentageChange = ((SHeight/LHeight)*100); // resize to canvas area height

activeDocument.activeLayer.resize(percentageChange,percentageChange,AnchorPosition.MIDDLECENTER);

}

else //{

//var percentageChange = ((SHeight/LHeight)*100); // resize to canvas area height

//activeDocument.activeLayer.resize(percentageChange,percentageChange,AnchorPosition.MIDDLECENTER);

//}

{ // Smart Object layer Aspect Ratio less the Canvas area Aspect Ratio

var percentageChange = ((SWidth/LWidth)*100);  // Resize to canvas area width

activeDocument.activeLayer.resize(percentageChange,percentageChange,AnchorPosition.MIDDLECENTER);

}

Translate
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 ,
Jun 17, 2019 Jun 17, 2019
LATEST

As I wrote it is not an option I would consider adding to my scripts. I do not like collage with partly filled image.  I outlined the code in red that does exactly what you want to do.  I also listed all the collage scripts you would need to change.  The you of course need to change all their dialog to add the fit image option then in the code test the option is not set fill the image are if set fit the image to the area however, What will be in the area depends on the template.  The code I posted. You would need  to use the variable names used the the current code for  filling the area. The script use different variable names then the code I posted from my mockup script you need  variable names used in the collage script an the test for  the fit image need to use  the correct dialog name the one for the scripts dialog. Each script uses a different dialog.

JJMack
Translate
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 ,
Jun 14, 2019 Jun 14, 2019

Sorry, your image on your reply did not show on the email.  I see and will try it, thank you again.

Translate
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