5 Replies Latest reply on Sep 14, 2016 9:59 AM by JJMack

    Conditionally Resize Image


      I am trying to find the correct way to proportionally downsize layers in a document only if a layer is larger than a certain size:  Layers smaller than the specified size should remain untouched.


      I tried using Photoshop's Image Processor, but layers smaller than the specified size were scaled up and became pixelated.


      I've begun learning Apple Script with the expectation that a script might be used with Image Processor to exclude scaling so smaller layers aren't scaled.  However, I'm not sure if the script's effect would occur after scaling had already taken place.


      What is the correct way to proportionally scale document layers if a layer is greater than a specified size; while not scaling layers that are smaller than that size?


      Thank you.

        • 1. Re: Conditionally Resize Image
          Chuck Uebele Adobe Community Professional & MVP

          If you're just starting learning coding, I would go with javascript, as more people know it and can help you more. Plus it's cross platform. Not real sure on your question. It sounds like you're trying to scale the entire image then only want certain layers scaled - is that correct? If that's the case, I would increase the canvas size to how big you want the image, the loop through all the layers and do a check on the layer size, then scale them accordingly.

          • 2. Re: Conditionally Resize Image
            C.Outwin Level 1

            Thank you for your quick reply.  I'm not trying to scale the entire image.  Here's some clarification of my objective:


            I want to capture an image of each layer in a document.  The images will appear in table view cells of an iOS application.  When a user taps a cell, the full-sized image will be selected on screen.


            Image Processor comes close to meeting my needs, but I want it to not scale up layers which are smaller than the arguments supplied to the width and height fields of the Resize to Fit option.

            • 3. Re: Conditionally Resize Image
              Chuck Uebele Adobe Community Professional & MVP

              Well, you can do that with the script. I'm not sure what the code would be for Applescript, I can do it in javascript. You would just make a loop to make each layer active, the get the layer's bounds, and resize accordingly.

              • 4. Re: Conditionally Resize Image
                C.Outwin Level 1

                Thank you very much.  I was oriented towards Apple Script after seeing the Adobe Photoshop CS 6 AppleScript Scripting Reference.  I'll follow the steps suggested by your pseudocode and try writing a script for Image Processor.

                • 5. Re: Conditionally Resize Image
                  JJMack Most Valuable Participant

                  The Image Processors Process documents totally the resize it does resize the whole document using the Fit Image Plug-in.  Its a Image size  to fit the resulting document within some canvas size.  The resulting image will still have its current aspect ratio. Only image that have the same aspect ratio as the target areas ratio will have that size canvas. All the others will have a canvas size somewhat smaller.   All layer are resized the same percentage.  The width and height Percentage are the same so the image does not distort.  The resulting document canvas sides will be same size or smaller then the target sides.  It depends on the two aspect ratios involved the Image's aspect ratio and the target area aspect ratio.


                  If you are planing on not resizing all layers the same way you best know you document design well and know the function the layer mask are being used for. Layer's with layer masks, masks  would also need to be resized weather they are linked or not so they will be correct for the resulting document if all layers are being resized. In your case this could be different.  Unlinked layer Masks may be for layers that are below so part of the lower layers show through where the mask is or the layer mask may the to keep the layer position over the canvas fixed..  If the whole document is not being resized things can become complicated.


                  I do not do web development.  But what you seen to want is two view or states of your image. It seems like the may be a good place to use layer comps.