Skip to main content
Participating Frequently
June 28, 2021
Question

Keeping Aspect ratio when Pasting

  • June 28, 2021
  • 2 replies
  • 4271 views

Hello there.

 

I usually work on a Mac, but recently I've had to use a PC for isolation reasons.

 

At work we use a specific file size which is 530x500pixel apsect 1.46.

 

On a Mac, after changing setting to not Resize Image During Place, I can paste anyimage fro the WEB or place an image from the Mac finder and it'll keep it's aspec ratio making it look as it should in the 1.46 document.

 

For some reason, I can't get it to work on PC. The image always looks stretched. I have to create a new document, paste the image in there THEN copy/paste the image into the 530x500 document.

 

Anyone out there know the fix?

 

Thank you

This topic has been closed for replies.

2 replies

JJMack
Community Expert
Community Expert
June 28, 2021

Place is not pasting pixel you have copied to the Clipboard.  Place is creating smart object for Images files. In this processing there are two conditions where Place may scale the smart Object created for the Smart object for the Layers pixels. Still the layer should have the image files images  Aspect Ratio 1.46 if that the aspect ratio the image in the file has.   The scaling Place does is a constrained scaling the aspect ration will remain unchanged. Place is not like Paste or Duplicate layer or Dragging layers between documents.  Place may degrade the image scaling it.  

 

You can Script Place so it will not scale. You would insure the Current Document Print Resolution has the same Print resolution as the image file  being Placed in and also Photoshop's preferences Resize during Place is not set. 

 

Here is one attempt:

 

// June 2019  John J. McAssey (JJMack) 
// This attempt to add an Additional Photoshop Place Embedded No Degrade feature under menu file scripts listed under Image Processor
// File>Scripts>placeImageNoDegrade... Embedded Image without a Degrading Resizing based on file print DPI setting.
// The Photoshop Preferences Resize During Place if set will scale large object to be scaled to fit on canvas
// The function placeImageNoDegrade(file) is designed for use in scripts to place in image files a default size and not lose image quality.
// This Script supports PSD, Tiff, Jpeg, PNG and Camera Raw file placement.  However, Camera RAW files have no print DPI 
// for they are not printable.  This script assumes your default Camera RAW work-flow conversion is to a 300DPI resolution
// The following Image Filetype are not supported for Photoshop support is not what it should be IMO or the file poor or to large to embed
// or are not commonly used by me.: PSB SVG AI BMP GIF EPS PDF DCS DICOM  IFF Jpeg2000 PCX PDF Pixar PBM Targa   etc...
// This script is supplied as is. It is provided as freeware. 
// The author accepts no liability for any problems arising from its use.
/* Help ]
<javascriptresource>
<name>$$$/JavaScripts/placeImageNoDegrade/Menu=placeImageNoDegrade...</name>
<about>JJMack's placeImageNoDegrade Copyright 2019 Mouseprints Place without degrading image quality</about>
<category>aaaThisPutsMeAtTheTopOfTheMenu</category>
<enableinfo>true</enableinfo>
</javascriptresource>
*/
if (!documents.length) alert('There are no documents open.', 'No Document');
else {
	if (!CheckVersion(13)) { alert("Photoshop version CS6+ is required.")}
	else {
		var imageFile;
		imageFile = selectFile ();
		if (imageFile==null) alert("No Image Files Selected", 'Cancelled');
		else if (!imageFile.name.match(/\.(crw|nef|raf|orf|mrw|dcr|mos|raw|pef|srf|dng|x3f|cr3|cr2|erf|sr2|kdc|mfw|arw|nrw|rw2|rwl|iiq|3fr|fff|srw|gpr|dxo|heic|arq|cr3|psd|psb|jpg|jpe|jpeg|png)$/i) ) alert(imageFile.name, 'Not a Supported Image Filetype');
		else placeImageNoDegrade(imageFile);
	}
}
//////////////////////////////////////////////////////////////////////////////////
//		                    	Helper Functions	            				//
//////////////////////////////////////////////////////////////////////////////////
function CheckVersion(PSV) {
	var numberArray = version.split(".");
	if ( numberArray[0] < PSV ) { return false; 	}
	return true;
}
function selectFile (multi) {   
	if (multi == true) {var theString = "please select Image files"}   
	else {var theString = "please select one image file"};   
	if ($.os.search(/windows/i) != -1) {var theFiles = File.openDialog (theString, '*.crw;*.nef;*.raf;*.orf;*.mrw;*.dcr;*.mos;*.raw;*.pef;*.srf;*.dng;*.x3f;*.CR3;*.cr2;*.erf;*.sr2;*.kdc;*.mfw;*.arw;*.nrw;*.rw2;*.rwl;iiq;*.3fr;*.fff;*.srw;*.gpr;*.dxo;*.heic;*.arq;*.cr3;*.psd;*.psb;*.tif;*.tiff;*.jpg;*.jpe;*.jpeg;*.png', multi)}   
	else {var theFiles = File.openDialog (theString, getFiles, multi)};  ////// filter files  for mac //////    
	function getFiles (theFile) {   
		if (theFile.name.match(/\.(crw|nef|raf|orf|mrw|dcr|mos|raw|pef|srf|dng|x3f|cr3|cr2|erf|sr2|kdc|mfw|arw|nrw|rw2|rwl|iiq|3fr|fff|srw|gpr|dxo|heic|arq|cr3|psd|psb|tif|tiff|jpg|jpe|jpeg|png)$/i) || theFile.constructor.name == "Folder") return true;   
	};   
	return theFiles   
};	
function placeImageNoDegrade(file) {
	var	orig_resolution = app.activeDocument.resolution;	// Get document Resolution (Read only change via image resize)
	var orig_ruler_units = app.preferences.rulerUnits;		// Save Units
	app.preferences.rulerUnits = Units.PIXELS;				// Set the ruler units to PIXELS
	// Thanks to SuperMerlin gets image Files Print resolution
	if (file.name.match(/\.(crw|nef|raf|orf|mrw|dcr|mos|raw|pef|srf|dng|x3f|cr3|cr2|erf|sr2|kdc|mfw|arw|nrw|rw2|rwl|iiq|3fr|fff|srw|gpr|dxo|heic|arq|cr3)$/i))  printDPI= 300; 
	else {
		if ( !ExternalObject.AdobeXMPScript ) ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');  
		var xmpf = new XMPFile( File(file).fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_READ );  
		var xmp = xmpf.getXMP();  
		if(xmp.doesPropertyExist(XMPConst.NS_TIFF, "XResolution")){  
			var res = xmp.getProperty(XMPConst.NS_TIFF, "XResolution");  
			res = res.toString().split("/");  
			printDPI= res[0]/res[1]	
		}
		else printDPI= 72;
	}
	if(orig_resolution!=printDPI) app.activeDocument.resizeImage(null, null, printDPI, ResampleMethod.NONE);
	// Place in the file
	var idPlc = charIDToTypeID( "Plc " );
	    var desc5 = new ActionDescriptor();
	    var idnull = charIDToTypeID( "null" );
	    desc5.putPath( idnull, new File( file ) );
	    var idFTcs = charIDToTypeID( "FTcs" );
	    var idQCSt = charIDToTypeID( "QCSt" );
	    var idQcsa = charIDToTypeID( "Qcsa" );
	    desc5.putEnumerated( idFTcs, idQCSt, idQcsa );
	    var idOfst = charIDToTypeID( "Ofst" );
	        var desc6 = new ActionDescriptor();
	        var idHrzn = charIDToTypeID( "Hrzn" );
	        var idPxl = charIDToTypeID( "#Pxl" );
	        desc6.putUnitDouble( idHrzn, idPxl, 0.000000 );
	        var idVrtc = charIDToTypeID( "Vrtc" );
	        var idPxl = charIDToTypeID( "#Pxl" );
	        desc6.putUnitDouble( idVrtc, idPxl, 0.000000 );
	    var idOfst = charIDToTypeID( "Ofst" );
	    desc5.putObject( idOfst, idOfst, desc6 );
	executeAction( idPlc, desc5, DialogModes.NO );
	if(orig_resolution!=printDPI) app.activeDocument.resizeImage(null, null, orig_resolution, ResampleMethod.NONE);
	app.preferences.rulerUnits = orig_ruler_units;				// Reset units to original settings	
	return app.activeDocument.activeLayer;
}			 

A second attempt with an interactive transform to allow the user to scale the smart object for their needs.

// June 2019  John J. McAssey (JJMack) 
// This attempt to add an Additional Photoshop Place Embedded No Degrade feature under menu file scripts listed under Image Processor
// File>Scripts>placeImageNoDegradeInteractive... Embedded Image without a Degrading Resizing based on file print DPI setting.
// The Photoshop Preferences Resize During Place if set will scale large object to be scaled to fit on canvas then an
// Interactive transform enable you to adjust the Smart Object layers associated transform for the document composite use.
// This Script supports PSD, Tiff, Jpeg, PNG and Camera Raw file placement.  However, Camera RAW files have no print DPI 
// for they are not printable.  This script assumes your default Camera RAW work-flow conversion is to a 300DPI resolution
// The following Image Filetype are not supported for Photoshop support is not what it should be IMO or the file poor or to large to embed
// or are not commonly used by me.: PSB SVG AI BMP GIF EPS PDF DCS DICOM  IFF Jpeg2000 PCX PDF Pixar PBM Targa   etc...
// This script is supplied as is. It is provided as freeware. 
// The author accepts no liability for any problems arising from its use.
/* Help 
<javascriptresource>
<name>$$$/JavaScripts/placeImageNoDegradeInteractive/Menu=placeImageNoDegradeInteractive...</name>
<about>JJMack's placeImageNoDegradeInteractive  Copyright 2019 Mouseprints  Place without degrading image quality with an Interactive Transform</about>
<category>aaaThisPutsMeAtTheTopOfTheMenu</category>
<enableinfo>true</enableinfo>
</javascriptresource>
*/
if (!documents.length) alert('There are no documents open.', 'No Document');
else {
	if (!CheckVersion(13)) { alert("Photoshop version CS6+ is required.")}
	else {
		var imageFile;
		imageFile = selectFile ();
		if (imageFile==null) alert("No Image Files Selected", 'Cancelled');
		else if (!imageFile.name.match(/\.(crw|nef|raf|orf|mrw|dcr|mos|raw|pef|srf|dng|x3f|cr3|cr2|erf|sr2|kdc|mfw|arw|nrw|rw2|rwl|iiq|3fr|fff|srw|gpr|dxo|heic|arq|cr3|psd|psb|jpg|jpe|jpeg|png)$/i) ) alert(imageFile.name, 'Not a Supported Image Filetype');
		else placeImageNoDegradeInteractive(imageFile);
	}
}
//////////////////////////////////////////////////////////////////////////////////
//		                    	Helper Functions	            				//
//////////////////////////////////////////////////////////////////////////////////
function CheckVersion(PSV) {
	var numberArray = version.split(".");
	if ( numberArray[0] < PSV ) { return false; 	}
	return true;
}
function selectFile (multi) {   
	if (multi == true) {var theString = "please select Image files"}   
	else {var theString = "please select one image file"};   
	if ($.os.search(/windows/i) != -1) {var theFiles = File.openDialog (theString, '*.crw;*.nef;*.raf;*.orf;*.mrw;*.dcr;*.mos;*.raw;*.pef;*.srf;*.dng;*.x3f;*.CR3;*.cr2;*.erf;*.sr2;*.kdc;*.mfw;*.arw;*.nrw;*.rw2;*.rwl;iiq;*.3fr;*.fff;*.srw;*.gpr;*.dxo;*.heic;*.arq;*.cr3;*.psd;*.psb;*.tif;*.tiff;*.jpg;*.jpe;*.jpeg;*.png', multi)}   
	else {var theFiles = File.openDialog (theString, getFiles, multi)};  ////// filter files  for mac //////    
	function getFiles (theFile) {   
		if (theFile.name.match(/\.(crw|nef|raf|orf|mrw|dcr|mos|raw|pef|srf|dng|x3f|cr3|cr2|erf|sr2|kdc|mfw|arw|nrw|rw2|rwl|iiq|3fr|fff|srw|gpr|dxo|heic|arq|cr3|psd|psb|tif|tiff|jpg|jpe|jpeg|png)$/i) || theFile.constructor.name == "Folder") return true;   
	};   
	return theFiles   
};	

function placeImageNoDegradeInteractive(file) {
	var	orig_resolution = app.activeDocument.resolution;	// Get document Resolution (Read only change via image resize)
	var orig_ruler_units = app.preferences.rulerUnits;		// Save Units
	app.preferences.rulerUnits = Units.PIXELS;				// Set the ruler units to PIXELS
	// Thanks to SuperMerlin gets image Files Print resolution
	if (file.name.match(/\.(crw|nef|raf|orf|mrw|dcr|mos|raw|pef|srf|dng|x3f|cr3|cr2|erf|sr2|kdc|mfw|arw|nrw|rw2|rwl|iiq|3fr|fff|srw|gpr|dxo|heic|arq|cr3)$/i)) printDPI= 300; 
	else {
		if ( !ExternalObject.AdobeXMPScript ) ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');  
		var xmpf = new XMPFile( File(file).fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_READ );  
		var xmp = xmpf.getXMP();  
		if(xmp.doesPropertyExist(XMPConst.NS_TIFF, "XResolution")){  
			var res = xmp.getProperty(XMPConst.NS_TIFF, "XResolution");  
			res = res.toString().split("/");  
			printDPI= res[0]/res[1]	
		}
		else printDPI= 72;
	}
	
	if(orig_resolution!=printDPI) app.activeDocument.resizeImage(null, null, printDPI, ResampleMethod.NONE);
	// Place in the file
	var idPlc = charIDToTypeID( "Plc " );
	    var desc5 = new ActionDescriptor();
	    var idnull = charIDToTypeID( "null" );
	    desc5.putPath( idnull, new File( file ) );
	    var idFTcs = charIDToTypeID( "FTcs" );
	    var idQCSt = charIDToTypeID( "QCSt" );
	    var idQcsa = charIDToTypeID( "Qcsa" );
	    desc5.putEnumerated( idFTcs, idQCSt, idQcsa );
	    var idOfst = charIDToTypeID( "Ofst" );
	        var desc6 = new ActionDescriptor();
	        var idHrzn = charIDToTypeID( "Hrzn" );
	        var idPxl = charIDToTypeID( "#Pxl" );
	        desc6.putUnitDouble( idHrzn, idPxl, 0.000000 );
	        var idVrtc = charIDToTypeID( "Vrtc" );
	        var idPxl = charIDToTypeID( "#Pxl" );
	        desc6.putUnitDouble( idVrtc, idPxl, 0.000000 );
	    var idOfst = charIDToTypeID( "Ofst" );
	    desc5.putObject( idOfst, idOfst, desc6 );
	executeAction( idPlc, desc5, DialogModes.NO );
	try { app.runMenuItem(charIDToTypeID(("FrTr"))); }			// Free Transform
	catch(e) {};
	if(orig_resolution!=printDPI) app.activeDocument.resizeImage(null, null, orig_resolution, ResampleMethod.NONE);
	app.preferences.rulerUnits = orig_ruler_units;				// Reset units to original settings
	return app.activeDocument.activeLayer;
}	

 

JJMack
Participating Frequently
June 28, 2021

It works on Mac. I can drop an image from Finder onto the document and it keeps the aspect. I can copy/paste images from Chrome, Safari, Images and it pastes it as it should be. 

 

I want the same on PC.

JJMack
Community Expert
Community Expert
June 28, 2021

Copy and Paste, drag and drop, Duplicate layer are not creating smart object layers they just add a Raster pixels layer. No Scaling is done more or less a straight pixels layer copy or merges pixel layers copy.  Place is a different Process.   Place is File oriented and even support RAW and Vector files.  Copy Paste, Drag and Drop Layers and Duplicate layer Pixel are layer oriented image files are not supported. Place creates Smart Object Layers using Images files content. Scaling may be done during Place processing.

 

Finder does not run on PC.  On Widows one would use Windows File Explorer and when you drag an image file from Windows File Explored  and drop it on an open Document in Photoshop.  Photoshop will Place the File into the document as a smart object layer Place may scale the smart object. If you want to paste in a layer open the file in Photoshop and  duplicate the layers copy paste the composite or drag the layers you want into the document you want the images in.    Place may scale during its processing.

JJMack
c.pfaffenbichler
Community Expert
Community Expert
June 28, 2021

Just to make sure: What are View > Pixel Aspect Ratio of the receiving and the placed image? 

Participating Frequently
June 28, 2021

It's set to PAL WIDESCREEN (1.46) which is the aspect ratio of the document. 

c.pfaffenbichler
Community Expert
Community Expert
June 28, 2021

For both images?