How do i transform a layer with maintain aspect ratio through scripting in Photoshop?

Hi,
     How do i transform a layer with maintain aspect ratio through scripting in Photoshop? I am expecting your reply.
thanks,
Rajiv.s

I don't think your talking apples to apples.  First I do not know of any Maintain Aspect Ratio icon in Photoshop. The only icon I think associated with transform is the anchor point icon in the option bar for transform. I think you may referring to the constrain check box in the image size dialog which you can check when resample is checked. Image size effect all layers in the document and the documents canvas size. The document canvas size will be changed to the values in the images size dialog and all layers will be transformed by percentage the canvas was changes while maintaining the layers position over the canvas and the layers I think may be cropped so only pixels over the canvas remain.
I do not know if you know that layers can be any size and have aspect ratios different then the documents canvas.
In your case it sounds like your describing a template that has a canvas size that is 2000px wide be 3000px high a 2:3 portrait aspect ratio.  Your image file has a landscape aspect. If you place that image into your template place would by default transform the image so the image would fit within the 2000px by 3000px canvas size there would be a white border top and bottom.  You could transform that smart object layer to it actual pixels size activeDocument.activeLayer.resize(100,100, AnchorPosition.MIDDLECENTER); then calculate the size you want to transform its height to. By retrieving the canvas size and the layers boundaries. Divide the canvas height pixel size by the layers pixel height size should give you the percentage you need to use. Make sure you set the ruler units to pixels so your working with pixel values for the canvas and layer size values. The resulting layer will be larger then canvas size keeping the anchor point centered will result in the canvas size masking off both sides.  In effect cropping you landscape to a portrait.  Note cropping a image from one orientation to the other changes the composition drastically.
If your trying to make a composit like collage you may want to look at my Photoshop Collage Toolkit it will fit images to fill a 2000px by 3000px area http://www.mouseprints.net/old/dpr/PhotoCollageToolkit.html
You could also do centered 2:3 crop that is resized to a 3000px

Similar Messages

  • How do I batch resize images with different aspect ratios?

    How do I batch resize images with different aspect ratios?

    poa66 wrote:
    Landscape: I want result to be 1960 x 1103 px and 72 ppi whether the original is 300 ppi or 220 ppi and wether it is 2Mb or 10 Mb. Cropped centered top and bottom.
    There will be a set of Landscapes that that have a narrower aspect ratio the 1960:1103 that would also need the top and bottom cropped like all Portraits would could be.  You need to realize that center cropping Landscape image that have aspect ratios near 1960:1103 will usually produce acceptable compositions.  However Cropping wide panoramas and portraits will only produce acceptable landscape  1960:1103 composition occasionally.
    Here you will see what happens when image have aspect ratio the do not fit the desired aspect ratio.  Where Landscape  are forced to portrait and portrait forced to Landscape.  Here are two Collage I populated with a mixture of image  with different  aspect ratios.   One collage has all 3:2 Landscape places and the other 2:3 Portrait places.
    I create a 1 image 1960x1103 collage 72dpi and create those too. Note the landscape boy foot is cropped off 3:2 is narrow compared to 1960:1103

  • How do i take one layer with multiple selections...

    how do i take one layer with multiple selections and make those selections their own layer?

    Yes sir. It w was really hard to explain. It is discontiguous segments that are separated by transparent areas. And I want those non transparent areas to be on their own layer. I have a photo shop file that has a bunch of buttons on them and they are on a transparent background. It is one layer. I want to select all the buttons and put them on their own layers. I can do this manually by selecting a button and cmd Just to a new layer, but when I have 200 buttons it is a daunting task.
    Sent by MailWise<http://www.mail-wise.com/installation/4> – Your emails, with style.

  • Photoshop CS6 - How can javaScript fill blank layer with color?

    Hello,
    I'm a production artist and I work with PSD files that were created in Adobe Scene7 Image Authoring Tool. These PSDs contain a background layer along with 1-20 alpha channels. My script has to make new blank layers based on the number of alpha channels and then it has to fill the new layers with light gray. The RGB values are 161, 161, 161. I checked the PSCS6 JavaScript Reference pdf, but I don't see a method that would do this for artLayers. (Let me also say that I'm new to javaScript).
    Does anyone know how to fill a blank layer with these RGB values?
    Here's my script so far:
    #target photoshop 
    // declare variable to contain the active document
    var myDoc=app.activeDocument;
    // declare variable to contain the number of alpha channels, excluding the RGB channels
    var alphaChan = myDoc.channels.length - 3;
    // create loop to make new layers based on number of alpha channels and fill each layer with gray
    for (a=0; a<alphaChan; a=+1){
    myDoc.artLayers.add();
    if (myDoc.artLayers.length == (alphaChan + 1)) {
        break;

    var color = new SolidColor();
    color.rgb.red = 161;
    color.rgb.green = 161;
    color.rgb.blue= 161;
    myDoc.selection.fill(color);

  • XmlDataProvider .... is gone completely in my Xaml file. Why? How many different ways to deal with xml data source through WPF

    I followed a procedure described in a book.
    1. insert "Inventory.xml" file to a project "WpfXmlDataBinding" .
    2. add the XML data source through the data panel of "blend for 2013", named it "InventoryXmlDataStore" and store it in the current document.
    3. dragged and droppped the nodes from the Data panel onto the artboard.
    Then I checked my Xaml file against the one provided by the book
    Xaml file by the book:
    <Window.Resources>
    <!-- This part is missing in my xaml file --><XmlDataProvider x:Key="InventoryDataSource"
    Source="\Inventory.xml"
    d:IsDataSource="True"/>
    <!-- This part is missing in my xaml file -->
    <DataTemplate x:Key="ProductTemplate">
    <StackPanel>
    <TextBlock Text="{Binding XPath=@ProductID}"/>
    <TextBlock Text="{Binding XPath=Cost}"/>
    <TextBlock Text="{Binding XPath=Description}"/>
    <CheckBox IsChecked="{Binding XPath=HotItem}"/>
    <TextBlock Text="{Binding XPath=Name}"/>
    </StackPanel>
    </DataTemplate>
    </Window.Resources>
    <Grid>
    <ListBox HorizontalAlignment="Left"
    ItemTemplate="{DynamicResource ProductTemplate}"
    ItemsSource="{Binding XPath=/Inventory/Product}"
    Margin="89,65,0,77" Width="200"/>
    </Grid>
    my Xaml file:
    <Window x:Class="WpfXmlDataBinding.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="922" Width="874">
    <Window.Resources>
    <DataTemplate x:Key="ProductTemplate">
    <StackPanel>
    <TextBlock Text="{Binding XPath=@ProductID}"/>
    <TextBlock Text="{Binding XPath=Cost}"/>
    <TextBlock Text="{Binding XPath=Description}"/>
    <CheckBox IsChecked="{Binding XPath=HotItem}"/>
    <TextBlock Text="{Binding XPath=Name}"/>
    </StackPanel>
    </DataTemplate>
    </Window.Resources>
    <Grid DataContext="{Binding Source={StaticResource InventoryXmlDataStore}}">
    <ListBox HorizontalAlignment="Left" Height="370"
    ItemTemplate="{DynamicResource ProductTemplate}"
    ItemsSource="{Binding XPath=/Inventory/Product}"
    Margin="65,55,0,0" VerticalAlignment="Top" Width="270"/>     
        </Grid>
    </Window>
    All looks quite the same except the <XmlDataProvider ....> part under <Window.Resources>, which is gone completely in my Xaml file.
    1, Why?
    2, How many different ways to deal with xml data source through WPF?
    Thanks, guys.
    (ps My "WpfXmlDataBinding" runs without problem through.)

    Never do yourself down Richard.
    Leave that to other people.
    It's quite common for smart developers to think they're not as good as they are.
    I coach a fair bit and it's a surprisingly common feeling.
    And to repeat.
    Never use anything ends .. provider.  They're for trivial demo apps.  Transform xml into objects and use them.  Write it back as xml.  Preferably, use a database.
    You want to read a little mvvm theory first.
    http://en.wikipedia.org/wiki/Model_View_ViewModel
    Whatever you do, don't read Josh Smiths explanation.  I used to recommend it but it confuses the heck out newbies. Leave that until later.
    Laurent Bugnion did a great presentation at mix10.  Unfortunately that doesn't seem to be working on the MS site, but I have a copy.  Download and watch:
    http://1drv.ms/1IYxl3z
    I'm writing an article at the moment which is aimed at beginners.
    http://social.technet.microsoft.com/wiki/contents/articles/30564.wpf-uneventful-mvvm.aspx
    The sample is just a collection of techniques really.
    I have a sample which involves no real data but is intended to illustrate some aspects of how viewmodels "do stuff" and how you use datatemplates to generate UI.
    I can't remember if I recommended it previously to you:
    https://gallery.technet.microsoft.com/WPF-Dialler-simulator-d782db17
    And I have working samples which are aimed at illustrating line of business architecture.  This is an incomplete step by step series but I  think more than enough to chew on once you've done the previous stuff.
    http://social.technet.microsoft.com/wiki/contents/articles/28209.wpf-entity-framework-mvvm-walk-through-1.aspx
    The write up for step2 is work in progress.
    https://gallery.technet.microsoft.com/WPF-Entity-Framework-MVVM-78cdc204
    Hope that helps.
    Recent Technet articles: Property List Editing;
    Dynamic XAML

  • How to maintain aspect ratio?

    I want export a video in 2.35.1, but want to maintain aspect ratio(and get rid of the black bars).
    How can I do that in Compressor?
    I can only figure out how to compress it. But can’t find any options for maintaining aspect ratio.
    I know this can be done with QuickTime 7, but I don't have it.
    Currently using Compressor 4

    As mishmumken said, custom frame sizes can be
    Specified in Compressor Geometry.
    But I'm concerned that you may not have preserved the aspect ratio
    When you exported from your editor
    Here is a great tutorial that describes how to do that from FCPX.
    Http://library.creativecow.net/articles/payton_t/FCPX_Custom-Resolution-Timeline s/video-tutorial
    Russ

  • How do I maintain aspect ratio of images in a replicator?

    I have these ai files from a company logo I want to use to build up a wall of the cross shapes seen in the screen shot. My problem is that I have not been able to figure out how to have the replicator maintain the square aspect ratio of the image.  What am I missing?
    Thanks,
    Drew

    The only time I've seen something like this is when the original file was saved with an aspect ratio and *non-square* pixels. Adobe applications (Photoshop is the one I know) have presets for video, like NTSC 720x480 in either 16:9 or 4:3 aspect.  Taking the 16:9 as an example, what should be 854x480 pixels is saved as 720x480 and the pixel widths are set to be interpreted as 1.21 times wider. In other applications, this will appear to be about 21% squeezed when viewed as square pixels.
    If this is the case, (or even *close* to the case) here's what you need to do:
    In the Layers list window - at the top -- click the media tab.
    Select the image/AI file.
    In the Inspector, click the Media tab (again...)
    Find the Pixel Aspect Ratio and select (most likely) NTSC D1/DV Anamorphic 
    Motion will automatically set the 1.21 aspect I was trying to explain at the top. If that doesn't work, select one of the other presets or Custom and type in your own aspect "correction" value.
    HTH

  • Maintaining aspect ratio when transforming

    Since I have upgraded to CS6 I've noticed that when transforming an object it does not maintain the aspect ratio even when I am holding shift while transforming. I have to each time check the link button (maintain aspect ratio)

    It'll be because 'Snap Vector Tools and Transforms to Pixel Grid' is enabled in 'Preferences > General', an option that didn't exist before CS6. It's actually being more truthful that way because the transformed layer has to become an integer number of pixels wide and tall, anyway, and that's not going to be a perfectly proportional scale in most cases.
    See what I mean by trying to scale an 11 x 10 pixels layer by 50%. It's impossible for that to be scaled by exactly 50% in width because the result has to be either 5 or 6 pixels wide (it will be 6). When the 'Snap...' preference is disabled (i.e. the pre-CS6 behaviour) you can scale the bounding box by precisely 50% in width but the pixels don't cover precisely 50% of the original width. When the preference is enabled, you won't be misled by being able to scale the bounding box to precisely 50% when the pixels cannot cover precisely 50%.

  • How to use Two main windows with in a page in script ?

    Hi any body explain me...
    How to use Two main windows with in a page in script ?
    with  header data in one main window,
    & Item data in other main window.

    HI..,
    u need to go for <b>SPLITTING THE MAIN WINDOW</b> !!!
    Main windows in page windows allow you to format text in multiple columns. Define an area in the page window, in which to position the main windows.
    Here is the procedure !!
    -->Create a page window and assign it to a page.
    Choose <b>Edit --> Main windows</b>.
    A dialog box appears.
    -->Enter values in the fields <b>Area width</b> and A<b>rea height</b> in accordance with the input guidelines for main windows.
    -->Enter values in the fields <b>Spacing</b> and Number in the <b>Horizontal group</b> if you want to use multiple columns. You can ignore the fields in the Vertical group.
    Determine how many columns and line areas are required for label printing. Then enter the corresponding values in the fields in the <b>Horizontal and Vertical groups</b>.
    -->The value in the field Left margin varies from main window to main window if multiple columns are used. The following applies:
    <b>
    Left margin of current column + Window width + Horizontal spacing = Left margin of next column</b>
    In label printing, the field Upper margin also varies from main window to main window:
    <b>
      Upper margin of current main window +  Window height + Vertical spacing = Upper margin of next main window</b>
    -->Enter a value in the field Start position.
    This is a counter. Enter a starting value which is equal to or greater than 1.
    -->The main windows are added to the list.
    -->Save your form.
    reward if it helps u...
    sai ramesh

  • Pasting from Illustrator to Photoshop doesn't maintain aspect ratio

    I have vector artwork that is not aligned to a pixel grid in Illustrator. In CS5, I would be able to paste the vector object as a smart object into Photoshop file that was larger than the illustrator image and resize larger while holding shift to keep the ratio the same.
    However with Creative Cloud, if I have a square in Illustrator that happens to be 17.3px by 17.3, then paste to Photoshop in a file that has a larger canvas than the paste, I get uneven horizontal and vertical ratios (width = 18; height = 17). It seems to overestimate the width and make it appear fatter horizontally (which is the wrong aspect ratio). This is very noticeable when vector objects (like perfect circles and small icons) get scaled up in Photoshop.
    I have tried unchecking and checking "Snap Vector Tools and transforms to Pixel Grid" but this doesn't seem to fix it.
    The only way I've been able to get this ratio to be kept is to create a new document with the size automatically changed to clipboard dimensions (which are the desired 17x17). When you paste as smart object, it now uses the correct aspect ratio.

    When you paste an object into Photoshop take a look at your options bar to see if the Maintain Aspect Ratio button is checked. I'm guessing that it isn't which is why Illustrator objects are being pasted at different heights and widths. As you can see in the image below, a perfect circle from Illustrator is being placed in Photoshop at 100.05% and 99.44%. By checking the link button between the two percentages the numbers get locked to the same percentage so that the object is pasted in at the correct dimensions.

  • How to fix an error in sequnece setting (aspect ratio)?

    Hi,
    I have been working for a while on a project in CS4. I have created a sequence in it with an aspect ratio (AR) of 4:3 - worked for hours on it - but I should had the sequence created instead in 16:9. I realised it a bit too late...
    So how do I fix it?
    Apparently amending the sequence setting for AR cannot be done - please let me know if there is any way of doing this.
    Someone suggested editing the PRPROJ file of the project - but when I opened it I was unable to detect under the sequence name (I found a few entries with it) where I can easily change the sequence to 16:9.
    So then I found people suggesting I copy/paste all the assets from the sequence into a new one that is correctly configured with 16:9. When I did this - CTRL+A and Copy, then paste into a new sequence in the same project - it copied all the clips and I think also all the transitions. But the key element that it did not copy over were all the changes I have done to the sound - I have been editing via the sound mixer (in Write mode) the sound, and then also made changes to the master track volume levels. These were not copied over.
    I really don't want to have to do the mixing all over again. If someone can explain how I can fix the problem in any way I would be most thankful.
    While I am here asking - another 2 small questions that have been bugging me:
    How I can copy and paste volume keyframes from either the master track or a clip and apply it on another clip/section of the clip that would be very helpful. This would for example be useful if I am able to find a certain volume level that I would like to apply to the desired section without the need to sit and "record" (using the Write function) those settings on the desired area. If there is any means to apply the properties on audio track this way - that would be really useful and time saving.
    A best practice hint: when you try and create a sound level for a project - what PC volume level setting do you set in your PC that you use as a benchmark by which we then work out the sound level that would be created in the project? Obviously if I push my PC volume al the way up I would probably mix my sound in the project too low. And if I set the PC volume too low - than I would probably be setting the overall sound level too high and get distortion. As the movies I created would be burnt onto a DVD - what is the volume level on the PC (if there is any means of establishing a standard volume) that I need to match first before I go and figure out what level of sound the finished DVD would have? Of course I can work on say a 50% and then apply gains and volume increases based on that 50% of the max sound my PC plays out. But that sounds pretty much like a random setting and not optimised for other devices.
    My system:
    Windows 7, 32-bit
    CS4, v. 4.2.1
    This looks like a fairly basic question but I am unable to find a good answer to it...
    Many thanks to the person who shows me how this can be done without me going crazy over the need to start all over again...
    Eroka00

    Hi Ann,
    Your tip saved me a lot of time indeed....!
    So I created a new sequence, made sure it was 16:9, copy pasted all of the assets, but then had to do the following:
    1. Copy/Paste Attributes for all the video clips (these do not transfer);
    2. As you suggested used the whole of the old sequence as a nested sequence in the new one, eliminating the video altogether.
    I still had a nagging issue that the project would not render or export well - but that turned out to be an issue with rendeiring large files (the video was an uncut clip of almost 10GB, andother of 6GB). Splicing these into 10 minute segments and rendering them separately did the trick.
    It's ben amlong Xmas weekend and endless hours spendt on this project. Yaikes!
    Thanks for the workaround idea!

  • Empathy Video Call Doesn't Maintain Aspect Ratio

    I'm using empathy 3.6.3-1 with gtalk, and I noticed that video calls don't seem to preserve aspect ratios. Does anyone else have this problem?

    When you paste an object into Photoshop take a look at your options bar to see if the Maintain Aspect Ratio button is checked. I'm guessing that it isn't which is why Illustrator objects are being pasted at different heights and widths. As you can see in the image below, a perfect circle from Illustrator is being placed in Photoshop at 100.05% and 99.44%. By checking the link button between the two percentages the numbers get locked to the same percentage so that the object is pasted in at the correct dimensions.

  • Maintain aspect ratio on panel re-size

    I think it would be valuable to have a panel attribute "Maintain aspect ratio on resize" that would apply to manual resizing (not maximizing) a panel.
    I know this is doable with panel callbacks and EVENT_PANEL_SIZE but a native solution that shows that constraint while dragging a corner would be better.
    And given the nature of many of our UIs I think this would often be used.
    Any comments before I submit a product suggestion?
    --Ian

    Since this is now a LabVIEW question, I would recommend to post it in the LabVIEW forum!
    The event structure has a "This VI...panel resize" event and you can probably use it to enforce a certain aspect ratio. 
    LabVIEW Champion . Do more with less code and in less time .

  • Resize flash movie while maintaining aspect ratio?

    Hey all,
    We have created an extremely content heavy .swf file (1900 x
    1400) for a presentation that runs full screen on a monitor at a
    screen resolution of 1900 x 1400. I think that was the
    resolution... I've been away from the project for a while and I
    can't remember. anyways....
    now we need to shrink the .swf down to a more reasonable size
    so that we can make a cd rom out of it. Probably needs to be shrunk
    to about 800 x 600. Is there an easy way to shrink the .swf in
    flash from 1900 x 1400 to 800 x 600 while maintaining aspect ratio
    and keeping all items on stage?
    I sure hope so! I'd hate to have to recreate the entire
    thing! It was a HUUUGE project with a ton of content.
    Thanks in advance for any help or suggestions!!!!

    Hey all.... I am just now working on this project.
    I've created my .fla file and I'm trying to load a .swf into
    an empty movie clip. It didn't scale down like I want it to and it
    was still appearing as the normal size file. So I added the
    container._height = 500; and container._width = 800; When I added
    the width and height the .swf inside the empty mc container
    disappeared!!!!! Any idea why???
    Here is my code:
    stop();
    this.createEmptyMovieClip("container",
    this.getNextHighestDepth());
    loadMovie("hlhuntyears.swf", container);
    container._width = 800;
    container._height = 500;
    container._x = 0;
    container._y = 0;
    I export it as an .exe since its going to be a cd rom and
    when I double click the .exe to run it I get a blank screen. But
    when I take out height and width it shows up but not to the correct
    scale. The original file (hlhuntyears.swf) is 1440 x 900 and when I
    run the .exe I can only see a tiny piece of it. Can anybody help??
    please??

  • How to find out web content files linked in folio through scripting

    Hi all,
    Please suggest me, how to find out web content files linked in folio through scripting.
    Regards,
    Moorthy

    @Moorthy – can you tell us a bit more? By mentioning "folio", I think you are referring to Adobe Digitial Publishing Suite (ADPS or short: DPS). If yes:
    1. Do you want to analyze Folio files *.folio and get the linked web content files?
    2. Or do you want to check an InDesign file with an overlay and check what files are linked as web content?
    3. Or something else?
    Where is your base problem?
    Packaging the InDesign files and copy/relinking the web content files after the packaging process?
    Uwe

Maybe you are looking for

  • How do I know if my doc is corrupt?

    Hello, power went out last night when I was working on a big project. When it came back, I got the "This document my be corrupt" message, but could open the doc, print a page, "save as," and continue working. Can I assume all is well? Thanks in advan

  • Itunes freezes, it wont open

    out of nowhere, whenever i started my itunes, it kept on loading and loading. importing .xml files i have patiently waited for 45 mins, yet nothing happened. need help badly.

  • Cannot install latest Firefox update. Seems to download OK but that's it!

    Frequently receive prompts to download/install the latest update. Click to download and it appears to work. Never installs the update. I've restarted/rebooted/downloaded the upgrade several times. Nothing works! Any thoughts?

  • Maximum number of endpoint registrations

    What is the maximum number of video endpoints that can register to a Gatekeeper running on a 7204VXR running IOS 12.2.19?

  • URL change in EPCM.doNavigate

    Hi Devina, one idea, two remarks: 1.) Just try to set the onClientClick programmatically, that is before closing the button (</hbj:button>), call setOnClientClick on the button object. <i>Maybe</i> the encoding only happens by the taglib... (just an