steve_bright1 Posted July 12, 2006 Share Posted July 12, 2006 (edited) The title just about sums it up - I have a number of images which are ofvarying aspect ratios. I want to automatically (in a Photoshop action) crop theends of each image, leaving the central square. I would then resize in theusual manner to make a thumbnail.The long side of all images have the same length, but I don't think thatreally helps as the dimensions of the resultant square will be the same as theoriginal short side. There's a mix of vertical and horizontal orientations.I've been pondering over this for quite a while, but I'm stumped and Ihaven't had any luck googling for it.Thanks in advance for your help.Steve Edited November 8, 2018 by William Michael Link to comment Share on other sites More sharing options...
pico_digoliardi Posted July 12, 2006 Share Posted July 12, 2006 If you have Photoshop we can post an automation (action or droplet) for you. Maybe someone else can suggest an alternate program. Link to comment Share on other sites More sharing options...
godfrey Posted July 12, 2006 Share Posted July 12, 2006 Just create an action to do the cropping per your desires and save as to a new file, then call that action via batch. I do this all the time. If you create the crop action independently, you can embed it into another script, or you can have a single action that does the entire crop and save as a monolithic piece. <br><br> Here's a pair I made just now for you as examples:<br> <a href="http://homepage.mac.com/godders/squares.atn" target=new> http://homepage.mac.com/godders/squares.atn</a> <br><br> For simplicity sake, I made two, one for Horizontals and the other for Verticals. Install them into Photoshop CS2. Then open Bridge on a folder of JPEG images you want to squareify, select all the horizontals, use the menu item to choose Photoshop batch, set up a destination folder and override the output file name, tell it to go. Do the same for the verticals when that's done. <br><br> It's best to write your own script and make it do precisely what you want, but this is a rough demonstration that works. I applied it to a folder of 30 H and 30 V JPEG files, it produced another folder of 60 square files for me. <br><br> Godfrey Link to comment Share on other sites More sharing options...
godfrey Posted July 12, 2006 Share Posted July 12, 2006 LOL ... just playing with my simple scripts and I see the limitations ... It works well when I have a set of pictures of identical resolution that matches the action I created, but is pretty hopeless when handing it a bunch of images that vary in size and resolution. <br><br> I suspect this means that you want to script <br> - rendering the image files to fit particular size and resolution density Image->Image Size... with resampling<br> - apply a standard crop to that result <br><br> fun fun fun<br> Godfrey Link to comment Share on other sites More sharing options...
sravan Posted July 12, 2006 Share Posted July 12, 2006 I have an idea that might work. Do an action that will 1. First change the canvas size to a square format. This should still keep the center of the image at the center 2. Do a resize using just the resolution setting 3. Do a crop using again the canvas size setting. This should work ok with different sizes and resolutions as long as the size are not too widely different. Link to comment Share on other sites More sharing options...
awindsor Posted July 12, 2006 Share Posted July 12, 2006 Steve, I have the same problem with actions all the time. You can script Photoshop using JavaScript and these scripts can access image properties such as width and height. See http://www.rags-int-inc.com/PhotoTechStuff/PscsScripts/ and http://partners.adobe.com/public/developer/photoshop/sdk/index_scripting.html Hope that helps. I am not very good at JavaScript programming but can probably help you out if you need assistance. Link to comment Share on other sites More sharing options...
awindsor Posted July 12, 2006 Share Posted July 12, 2006 Actually you can use either Applescript or Visual Basic to do this too. Both of these are apparently easier to work with than JS. I have a Mac and use AppleScript but have never used Visual Basic. The advantage of JavaScript is that it will work on either platform. Link to comment Share on other sites More sharing options...
awindsor Posted July 13, 2006 Share Posted July 13, 2006 If you use a Mac here is an Applescript to do exactly what you want. You should be able translate it to VBScript. I tested it on my copy of PS7. Watch the line breaks introduced here. I retyped it here (rather than lik my latop up) so watch out for typos. tell application "Adobe Photoshop 7.0" --just be a little careful try set docRef to current document on error display dialog "must have an open document" end try set docWidth to width of docRef set docHeight to height of docRef if docWidth > docHeight then set minDimension to docHeight else set minDimension to docWidth end if crop docRef bounds {(docWidth-minDimension)/2 , (docHeight-minDimension)/2 , (docWidth+minDimension)/2 , (docHeight+minDimension)/2 } Link to comment Share on other sites More sharing options...
steve_bright1 Posted July 17, 2006 Author Share Posted July 17, 2006 I am mortified that I haven't responded to you sooner, I think I must have had email notifications turned off. Pico: I have Photoshop CS and an action would be great if you could provide one, but I'm not sure it's possible with a 'straight' action. Godfrey: Thanks for your suggestions, but I really want to be able to do this without having to separate them into horizontal and vertical photos. Sravan: I don't think this is going to work as the images have varying aspect ratios. Alistair: I think you're right and I'll have to do it with scripting. I'm on a PC so I'll probably use Javascript and build on your Applescript statement. Many thanks to you all for your help. Link to comment Share on other sites More sharing options...
awindsor Posted July 17, 2006 Share Posted July 17, 2006 Javascript has a big advantage over either of the two other scripting languages because Javascript scripts can be embedded in Photoshop actions. At least on PS 7 I don't know how to embed Applescript scripts. Link to comment Share on other sites More sharing options...
awindsor Posted July 18, 2006 Share Posted July 18, 2006 Steve, If you run into problems don't hesitate to contact me. I don't know the JavaScript object model off the top of my head but I have the right source and it should be a matter of minute to whip up a script that works. Link to comment Share on other sites More sharing options...
shawn_taylor2 Posted April 11, 2012 Share Posted April 11, 2012 <p>Hey folks,</p> <p>I know there are some solutions presented here already, but I thought I would contribute mine. I made an action called <a href="http://dl.dropbox.com/u/838533/Live%20-%20DO%20NOT%20REMOVE/Square%20Thumbnails%20%28h%20%2B%20v%29.atn">Square Thumbnails (h+v).atn</a> that automates this process as much as possible without using outside scripts.</p> <p>It creates full-frame thumbnails at 256px x 256 px. To solve the horizontal/vertical orientation issue, it actually creates 2 thumbnails of each photo, one correctly cropped and one not correctly cropped, and puts them in a "h" and a "v" folder. The background of the incorrectly cropped thumbnails is red so you can tell from the finder when it's not the right one, and ignore it or delete it manually.</p> <p>Save Location, Thumbnail Size, and Export Quality are all configurable by opening up an image and double clicking on the individual action item and editing as needed, but if 256px square and on the desktop works for you, that's not needed.</p> <p>Hope it helps someone.</p> <p>Shawn Taylor - <a href="http://www.shawntaylorphoto.com">Photographer</a> and co-founder of <a href="http://www.foliomob.com">Foliomob.com</a></p> Link to comment Share on other sites More sharing options...
httpswww.southernman.co Posted November 8, 2018 Share Posted November 8, 2018 Auto crop image is awesome. I stumbled across this post yesterday after struggling to find anything to make all my e-commerce pictures square using the longest side of the image. This is the only solution I could find. That's everyone. Link to comment Share on other sites More sharing options...
john_wheeler6 Posted November 9, 2018 Share Posted November 9, 2018 Hi Steve. The description of Auto Crop looks like it does the job and I hever have used it yet here are the steps that will record properly to do what you want 1) Load image 2) Duplicate Layer Cmd J (Cntl + J for PC) 3) Transform second Layer and rotate 90 degrees either direction 4) Cmd click on Layer Thumbnail of Duplicate Layer to create selection (Cntl click on Layer Thumbnail for PC) 5) Delete Duplicate Layer 6) Image > Crop 7) Optionally Cmd + D to remove selection (Cntl + D on PC) 8) Size and save image as desired using Image > Image Size (with desired parameters) This gives you a square iamge cropped exactly in the center of the image no matter if you started with portrait or landscape image. Hope this helps Link to comment Share on other sites More sharing options...
William Michael Posted November 9, 2018 Share Posted November 9, 2018 NOTE: the original post was written in 2006. Link to comment Share on other sites More sharing options...
john_wheeler6 Posted November 9, 2018 Share Posted November 9, 2018 Thanks William, I just keyed off of recent posts and did not notice the thread was 12 years old. Are you trying to tell me I am just a bit late? :):):);) Link to comment Share on other sites More sharing options...
William Michael Posted November 11, 2018 Share Posted November 11, 2018 haha just a little bit late. john, it is easy to do. This conversation was reinvigorated by a post a few days ago, (which has subsequently been deleted), that (now deleted) response pushed the thread to the top, so, understandably, you thought it was a recent conversation. Anyway we know know about "auto crop". WW Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now