Skip navigation
Currently Being Moderated

How to resize layer in percentage relative to image size?

May 2, 2013 11:14 AM

Tags: #layer #percentage #resize #image_size



Say I have an image that is 100x100 pixles. And I want to take one of the layers and resize it to 50% of the image size, so that it is 50 pixles. How can I accomplish that?


The reason I ask, is that have multiple images all with different size. But I have a signature (ie. watermark) that is always the same size. I want to be able to place this signature, and then resize it to XX% of the image it was placed on. That way, it should always have the same proportions.


Thanks in advance!

  • Currently Being Moderated
    May 2, 2013 11:09 AM   in reply to shaibn

    You can scale by percentage of the original layer size going to Edit > Transform > Scale. In the transform options menu, there is an option to scale by percentage - just make sure that you click on the link icon between the Height and Width fields to maintain the aspect ratio of your layer.


    Screen Shot 2013-05-02 at 10.47.42 AM.jpg Screen Shot 2013-05-02 at 10.47.53 AM.jpg


    However, if you wanted to scale a layer relative to the canvas size, I think you would need to do some scripting or use actions... you might want to ask around on the Photoshop General Discussion or Photoshop Scripting forums to see if anyone has a solution.




    (Edited - misinterpreted original question)

    Mark as:
  • Currently Being Moderated
    May 2, 2013 11:13 AM   in reply to shaibn

    I went ahead and moved this thread over to the Photoshop General Discussion forum. You may want to repost your original question on the Scripting forum so that I'm not bouncing you all over the place

    Mark as:
  • Currently Being Moderated
    May 2, 2013 11:32 AM   in reply to shaibn

    If you want to batch process, Picture Processor will let you add your logo/watermark @ a  percentage of the document....


    Mark as:
  • JJMack
    5,979 posts
    Jan 9, 2006
    Currently Being Moderated
    May 2, 2013 12:12 PM   in reply to shaibn

    Layers can be any size and a layer may be a different size then its current size like a placed image that was scaled by Photoshop during the place operation so the image would fit within the canvas.  In fact all smart object layers have a transform associated with them the transform may be 100% is which case the layer would be its actual size.


    So yes to do what you want would require a little scripting and you need better think a bit more about the process there are so mays thing possible. Like how you want to handle aspect ratio mismatches. Understand layer may have transparency may have been rotated some arbitrary amount so its bounds and its pixels will be different in size.  Now the script may not have to handle all possibilities if you know the layer will not contain transparency caused by rotation or edge area pixels being deleted.  You process may only need to handle a subset of what is possible if you know you will never  have some of the possibilities your process need not handle them for the will never exist in you environment.


    In my Photo Collage Toolkit Scripts I resize placed images to at least fill the area they are to populate center it over that area and mask off any aspect ratio mismatch.  The scripts do not do any automated rotation and any transparence in place image was done for some reason by the user. Why they did this could only be guessed at by the scripts. So they do nothing for only the user know why. Your the user know what you have to handle.

    Mark as:
  • JJMack
    5,979 posts
    Jan 9, 2006
    Currently Being Moderated
    May 2, 2013 12:38 PM   in reply to shaibn

    shaibn wrote:


    I looked into using it, but I didn't find it would work with my current actions. Which are to place the watermark, save the image, then remove the watermark, resize the image, save it again and then remove the watermark again, resize the image and place the watermark again and save it again.

    If all those save are for the same image file format or a mixture of image file formats the perfect script for you would be the Image Processor Pro plug-in script downloadable from  Russell Browns web site.  Once installed you will find it under menu File>Automate>Image Processor Pro... All your action needs to do is add the watermark.  It need do no resizing of images and no saving of images the what the script does. You action does not need to remove the watermark. Each image will start from a copy of the original image you can have the image processor pro do the resize before or after your action(s) is played.

    Mark as:
  • Currently Being Moderated
    May 2, 2013 12:37 PM   in reply to shaibn

    Here is the basics, after the logo has been placed ...



    activeDocument.suspendHistory('Logo Resize', 'main()');
    function main(){
    if(!documents.length) return;
    /////////////////////////////// Amend to suit /////////////////////////////////
    var Percent = 25; /* Resize logo to percentage of smallest side of doc */
    var OffsetX = -10; /* Move logo10 pixels to the left */
    var OffsetY = -10; /* Move 10 pixels up. */
    var Opacity = 100; /* Opacity of logo */
    var startRulerUnits = app.preferences.rulerUnits;
    app.preferences.rulerUnits = Units.PIXELS;
    var myDoc = activeDocument;
    var LB = myDoc.activeLayer.bounds; 
    var docHeight = myDoc.height;
    var docWidth = myDoc.width;
    var LHeight = Math.abs(LB[3].value) - Math.abs(LB[1].value);
    var LWidth = Math.abs(LB[2].value) - Math.abs(LB[0].value);    
    var percentageHeight = ((docHeight/LWidth)*Percent); 
    var percentageWidth = ((docWidth/LWidth)*Percent);
    if(docWidth < docHeight){
    var LB = myDoc.activeLayer.bounds;
    var X = docWidth - Math.abs(LB[2].value);
    var Y = docHeight - Math.abs(LB[3].value);
    X += OffsetX;
    Y += OffsetY;
    app.preferences.rulerUnits = startRulerUnits;
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points