Skip to main content
Participant
March 29, 2021
Question

Is there a way for the canvas to resize itself dynamically?

  • March 29, 2021
  • 4 replies
  • 360 views

 

This is primarily a use case for creating web content.

 

SnagIt has a feature that I find incredibly useful.
I create a new canvas, then I drop 2,3,10 etc pictures or content on it
and the canvas expands so all of them will fit. 
Then I can move around and position each picture, once done, 
I manually adjust the canvas to the borders of content. 

 

Is this possible in Photoshop?
I understand that in most usec cases the size of the canvas is essential
and content must be adjusted to fit the canvas. 

 

I think I have found a way to resize it manually but x number of pixel I have to guess at, 
and then manually try to do the same. 

  

I would it as click and drag at least 

 

 

 

 
 
This topic has been closed for replies.

4 replies

JJMack
Community Expert
Community Expert
March 29, 2021

I do that do the daily in with Photoshop and I have automated the process more or less.  I copy what I want to add to my document canvas to the clipboard then I press a function key. The F key plays an Action I recorded it has one step.  A script I wrote. The script switches to my self expandable document.  If the document is not open the script Creates a new expandable document and paste in the clipboard.  Then the script makes the document canvas size the size of the layer that was pasted in and the layer positioned to align with the documents  canvas. The bottom layer that was created during for the creation of the expandable document is then deleted.  If the Document was open when the script switches to the document it then paste in the clipboard image and expands the document canvas on the bottom the height of the pasted in image layer and if the image pasted in wider then the document canvas, canvas is added to the right side so the document so the width will be as wide as the pasted in image. The script then positions the pasted in layer over the expanded canvas area.  So the answer to your question is yes photoshop can do what you want. However  Adobe does not provide a automate process to do the processing you want done.  

 

If expansion downward and to the right suits your needs you can use my script. "appendClipboard.jsx"

 

 

/* ==========================================================
// 2013  John J. McAssey (JJMack) 
// ======================================================= */
// This script is supplied as is. It is provided as freeware. 
// The author accepts no liability for any problems arising from its use.

// I set a shortcut key in my case F5 to this Photoshop script mainly for doing Window screen capturing of:
// desktop displays, Active window and selected area copy to clipboard. The script log the cardboard into a document with the name clipboard. 

/*
<javascriptresource>
<about>$$$/JavaScripts/AppendClipboard/About=JJMack's Append Clipboard into Clipboard document.^r^rCopyright 2014 Mouseprints.^r^rJJMack's Script.^r
NOTE:New Clipboard Document will be open if necessary</about>
<category>JJMack's Script</category>
</javascriptresource>
*/

// enable double-clicking from Mac Finder or Windows Explorer
#target photoshop // this command only works in Photoshop CS2 and higher

// bring application forward for double-click events
app.bringToFront();

if (!documents.length) {
	NewCliboardDoc (); 
	app.activeDocument.suspendHistory('appendClipboard','main(true)'); // New document opened proceed
	}
else { 	//locate Document clipboard
	for (var i=0;i<app.documents.length;i++) { 
		app.activeDocument=app.documents[i];
		if (app.activeDocument.name == "Clipboard"){break;}
		}
	if (app.activeDocument.name != "Clipboard"){
		NewCliboardDoc ();
		app.activeDocument.suspendHistory('appendClipboard','main(true)'); // New document opened proceed
		}
	else {app.activeDocument.suspendHistory('appendClipboard','main(false)'); }	// Old Clipboard Document found
	}

///////////////////////////////////////////////////////////////////////////////
//                            main function                                  //
///////////////////////////////////////////////////////////////////////////////
function main(newFile) {
	// declare local variables
	var orig_ruler_units = app.preferences.rulerUnits;
	app.preferences.rulerUnits = Units.PIXELS;			// Set the ruler units to PIXELS

	try { 
		activeDocument.paste(); 					    // past in clipboard may fail enclose in try
		var LB = app.activeDocument.activeLayer.bounds;	// Get the bounds of the work layer
		var LWidth = (LB[2].value) - (LB[0].value);		// Area width
		var LHeight = (LB[3].value) - (LB[1].value);	// Area height
		// BOTTOMCENTER BOTTOMLEFT BOTTOMRIGHT MIDDLECENTER MIDDLELEFT MIDDLERIGHT TOPCENTER TOPLEFT TOPRIGHT
		if(newFile) {
			app.activeDocument.resizeCanvas(LWidth, LHeight, AnchorPosition.TOPLEFT);
			app.activeDocument.layers[1].remove();
			}
		else {
			if (LWidth>=app.activeDocument.width) {	app.activeDocument.resizeCanvas(LWidth, app.activeDocument.height + LHeight, AnchorPosition.TOPLEFT);}
			else {app.activeDocument.resizeCanvas(app.activeDocument.width, app.activeDocument.height + LHeight, AnchorPosition.TOPLEFT);}
			}
		app.activeDocument.selection.selectAll();		// select all
		// Left('AdLf'); Right('AdRg'); Top('AdTp'); Bottom('AdBt'); Center Horizontal('AdCH'); Center Vertical('AdCV');
		align("AdLf");align("AdBt");					//Align to selection Left bottom
		app.activeDocument.selection.deselect();
		SetViewFitonScreen();
		//app.purge(PurgeTarget.CLIPBOARDCACHE);
		}
	catch(e) { 
		if(newFile) app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
		alert("Clipboard Empty"); 
		}		

	app.preferences.rulerUnits = orig_ruler_units;			// Reset units to original settings
	}
///////////////////////////////////////////////////////////////////////////////
//                           main function end                               //
///////////////////////////////////////////////////////////////////////////////
function NewCliboardDoc () {
	// app.documents.add([width][, height][, resolution][, name][, mode][, initialFill][, pixelAspectRatio][, bitsPerChannel][, colorProfileName])
	var Clipboard = app.documents.add( null, null, 100, "Clipboard", NewDocumentMode.RGB, null, null, null, "sRGB IEC61966-2.1");
	}

function align(method) {
	var desc = new ActionDescriptor();
			var ref = new ActionReference();
			ref.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
		desc.putReference( charIDToTypeID( "null" ), ref );
		desc.putEnumerated( charIDToTypeID( "Usng" ), charIDToTypeID( "ADSt" ), charIDToTypeID( method ) );
	executeAction( charIDToTypeID( "Algn" ), desc, DialogModes.NO );
	};

function SetViewFitonScreen() {
    var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putEnumerated(charIDToTypeID('Mn  '), charIDToTypeID('MnIt'), charIDToTypeID('FtOn'));
    desc1.putReference(charIDToTypeID('null'), ref1);
    executeAction(charIDToTypeID('slct'), desc1, DialogModes.NO);
};

 

 

 

 

JJMack
Participating Frequently
March 29, 2021
Chuck Uebele
Community Expert
Community Expert
March 29, 2021

You can use the trim or reveal all command.

jane-e
Community Expert
Community Expert
March 29, 2021

Hi

There is no auto-size for the Canvas in Photoshop. What I do it use the Crop tool and drag to resize the Canvas really big while I'm working, then use it again at the end for the final size.

~ Jane