Skip to main content
Known Participant
June 12, 2019
解決済み

Photo Collage Toolkit - How to Automatically Scale Images to Cutouts

  • June 12, 2019
  • 返信数 2.
  • 3933 ビュー

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.

    このトピックへの返信は締め切られました。
    解決に役立った回答 JJMack

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

    返信数 2

    JJMack
    Community Expert
    JJMackCommunity Expert解決!
    Community Expert
    June 13, 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
    truematic作成者
    Known Participant
    June 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.

    JJMack
    Community Expert
    Community Expert
    June 15, 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); }     

    }        


    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

    JJMack
    Sahil.Chawla
    Adobe Employee
    Adobe Employee
    June 12, 2019

    Hi there,

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

    Regards,
    Sahil

    truematic作成者
    Known Participant
    June 12, 2019

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