Script to make landscape and portrait images square

I am new to scripting and could use a little help.
We are currently rebuilding our enitre website from the ground up. New look, new products, new images (about 2,800 of them). Here is where it gets tricky.
Some of the photos are landscape and others are portrait. I have resized the images to the required 200 pixels wide, but we are now running into the issue where they also need to be 200 pixels high. I could just separate them into two folders, landscape and portrait, and run two different actions, but I would prefer to run an if/than script if possible. Can someone tell me if this is possible in Photoshop? These are images of products, so there is no background.
If the image is larger than 200 pixels high, reduce the image to 200 pixels high. Then, enlarge the canvas to 200 pixels.
If the image is smaller than 200 pixels high, Then enlarge the canvas to 200 pixels high.
These are all 72 dpi, RGB images. Any help would be greatly appreciated.

I have found this JaveScript that does what I need on the PC side, but keep getting an error when it tries to save the image. Is anyone able to recreate this into AppleScript with a correct save function... I am running a MAC, so I need an AppleScript. My coworker has Photoshop on the PC and is trying to use this JavaScript below.
//  resize canvas  & export JPG
#target photoshop
app.bringToFront();
// Save current dialog preferences
var startDisplayDialogs = app.displayDialogs;    
// Save current unit preferences
app.displayDialogs = DialogModes.NO
// Source and Destination Folders
var inputFolder = Folder.selectDialog("Select the Source folder");
var outputFolder = Folder.selectDialog("Select the Destination folder");
ProcessImages();
function ProcessImages() {
  var filesOpened = 0;
   if ( inputFolder == null || outputFolder == null) {
   if ( inputFolder == null) {
            alert("No Source folder selected");
    if ( outputFolder == null) {
       alert("No Destination folder selected");
   }else{
var fileList = inputFolder.getFiles();
  for ( var i = 0; i < fileList.length; i++ ) {
       if ( fileList[i] instanceof File && ! fileList[i].hidden) {
                 open( fileList[i] );
                 ResizeCanvas();
                 filesOpened++; 
  return filesOpened;
function ExportJpeg(filePrefix, fileSuffix){
try
var docRef = app.activeDocument;
var docName = app.activeDocument.name.slice(0,-4);
var jpegOptions = new JPEGSaveOptions();
jpegOptions.quality = 8
docRef.flatten()
docRef.bitsPerChannel = BitsPerChannelType.EIGHT
jpegFile = new File( outputFolder + "//"  + filePrefix + docName + fileSuffix );
//Save Document As
docRef.saveAs(jpegFile, JPEGSaveOptions, true, Extension.LOWERCASE);
catch (e)
alert("Error when attempting to save the image. \r\r" + e);
return;
function ResizeCanvas()
   function CanvasSize() {
      var docRef = app.activeDocument;
      var docWidth = docRef.width.as("px");
      var docHeight = docRef.height.as("px");  
      if (docWidth < docHeight)
            docRef.resizeCanvas(docWidth = docHeight, docWidth, AnchorPosition.MIDDLECENTER);
      else if (docWidth > docHeight)
            docRef.resizeCanvas(docHeight = docWidth, docHeight, AnchorPosition.MIDDLECENTER);
      else if (docWidth == docHeight)
var docRef = app.activeDocument;
var savedState = docRef.activeHistoryState;
CanvasSize();
app.displayDialogs = DialogModes.NO;
ExportJpeg("", ".jpg");
docRef.activeHistoryState = savedState;
docRef.close(SaveOptions.DONOTSAVECHANGES);
docRef = null;
// Reset preferences
app.displayDialogs = startDisplayDialogs;
alert("Operation Complete!" + "\n" + "Images were successfully exported to:" + "\n" + "\n" + outputFolder.toString().match(/([^\.]+)/)[1] + "/");

Similar Messages

  • I need to make Landscape and portrait in the same file ? plz I don't want to go back to word

    Hi there I am trying to have page in landscape and portrait in the same file, but I couldn't, however, if there is a way where we can perform it please advise me as I need to do that for my thesis. Am happy to work only in pages if this feature is not in pages, please find us a solution.
    Regards
    Mohammed

    Export te document to PDf. Open it in Preview. Here you can rotate the a page to horisontal.

  • Printing landscape and portrait orientations in LR

    I have usually been printing from Qimage or QTR for my black and white, despite having heard good things about LR's print module.
    This afternoon I thought I would give LR a whirl at printing. I had a series of 4 photos (3 portrait orientation, 1 landscape) selected which I wanted to print one per page. In Print they all appeared oriented in the most logical fashion as I paged through the 4 pages (i.e. the longest dimension of the image ran down the longest dimension of the paper).
    I then selected my profile for my paper and hit Print... to go into my printer settings (Epson 3800) for that paper. These latter settings exist for both landscape and portrait orientations of my papers. As I had both landscape and portrait images I wished to print and the settings for the printer driver dialog are identical for both apart from the media orientation, I chose the landscape to get a quick feedback on whether LR would be able to handle a mixed bag of portrait and landscape images.
    As I feared, my first print (which was an image in portrait orientation) came out with the long axis of the image squeezed into the short dimension of the paper....so LR saw the choice I had made of a landscape orientation within the printer driver as a hard and fixed choice. Does this mean one can only do print runs of either portrait or landscape oriented images in LR and never combine the two?
    I realize there may be an easy answer to this as I've really not used LR for printing till now.
    Thanks for input,
    Dave M

    Thanks DJ-G....I can't swear but I am almost positive I had Rotate to Fit checked....indeed that would explain why when paging through the 4 pages in LR they were rotated to fit in the correct orientation. I'll check again. I do understand with Custom Package etc. we can print landscape and portrait when printing multiple images on the same page but my specific concern is printing one image per page and whether LR can handle a series of such prints in one print job if the images are a mix of landscape and portrait orientations.
    DM

  • Landscape and portrait phots?

    Hi
    I want to use some phots to make a youtube video the photos are both landscape and portrait , but when i add the media it only shows the photos in one orientation (landscape) any advice gratefully recieved

    Before you import the photos into your project, go to your preferences (under the Edit menu on a PC) and uncheck Scale Stills to Frame Size.
    Also make sure your photos are sized to no larger than 1000x750 pixels or they are going to be way to large to work with. You may need to resize them once youv'e added them.
    Unless your concern is that the portrait photos are coming in sideways. If that's the case, you'll need to open them in Photoshop Elements, rotate them 90 degrees and then resave them. Note that, although many photos will appear to be oriented correctly in the Organizer or in Windows, they still may not actually be oriented correctly until you open them in Photoshop.

  • Landscape and Portrait Orientation Problems

    Hello everyone,
    I am working on my first iBook using iBook Author. I am having a heck of a time understanding how to make something look good in both Landscape and Portrait orientation.
    For example, I am curious how to make the spaces between paragraphs disappear in portrait view, if I had to use them in order to make the landscape view look proper in terms of formatting. In depth, if I have a text for a section in the book that I need to have at the top of the next column, I am putting my cursor before the text and pressing enter a few times in order to move it along and onto the next column so it is at the top of the page.
    Here is a picture of what I am talking about:
    The highlighted text has been shifted down so it will be at the top of the next page.
    Now this is what it looks like in Portrait orientation:
    There are way too many empty lines between them. Also, you will notice at the top that Not Getting In the Way is also too close to the text above it. Correcting that by putting a space between the lines will screw up the Landscape formatting.
    Also, adding pictures makes it even MORE difficult to keep both formatted properly and clean.
    Any advice would be INCREDIBLE.
    Thank you everyone!

    Layout in landscape. Edit in portrait....assuming you've not disabled support for it.
    Preview/check in both.
    See the tips in this forum and
    Publishing With iBooks Author
    http://shop.oreilly.com/product/0636920025597.do 

  • How do i have landscape and portrait slides in the same keynote file?

    how do i create landscape and portrait slides in the same keynote file?

    You cant, its one or the other not both, the slide size setting is for the whole presentation, not for individual slides.
    The slide format is chosen to match the display the presentation is shown on. I have presentations showing on vertical, horizontal, square, circular and iregular shaped screens with rear projection, but a single format must still be set.

  • Landscape and portrait mode in Epub

    Hey!
    When I export from Indesign to .epub with a fixed layout - is there a way to use it in landscape and portrait mode on an Ipad or Iphone? Mine stays in landscape.

    @Steve – don't think so…
    @Kaz Till – do you mean the following:
    1. Without setting "auto":
    2. After setting "auto":
    Don't think, that this is to the advantage of the reader…
    Uwe

  • Change landscape-and-portrait-folio to landscape-only

    Is it possible after mistakenly having produced a folio with landscape-and-portrait-mode setting it back to landscape-only?
    In the new content viewer, if a folio is set for both landscpae and folio, but only one layout exists, it shows a grey empty page in the second alignment (before it didn't change the alignment and the picture wasn't changed when turning the iPad).
    Now, when you create a new folio, you are asked if this is landscape-and-portrait or portrait-only respectively landscpae-only. We mistakenly have chosen both-alignments and are now having the problem of the empty grey mode in portrait.
    Can this be changed after upload the layouts? Is this also happening within the app itself?

    Hi Bhaskar,
    thanks for your help. My intention is to create a single-orientation layout, but I created a both-orientations-layouts. Before v20 (or 19?) when just uploading one of the orientation into that folio, content viewer and the branded app just showed one orientation and fixed the layout within the iPad. Now, if you choose both-orientations and just upload a single one, you are getting a grey screen in the missing orientation.
    I wasn't aware of this fact (maybe because german customers weren't invited to sprint v20 presentation) but I'm afraid that you are right an  have to created the folio completely from the ground (which is a lot of more work with import function not running )
    Maybe this solves my push notification error with one of my folios I have
    Richard

  • Investigate book with both landscape and portrait pages

    I've an old book where I sucessfully swapped landscape and portrait pages, but there are complications why I cannot use it as a model for my current project. Since I no longer remember how I accomplished this, I have to investigate how to build a book with both landscape and portrait pages.
    I know about paragraph tags set to use a new page. Also a table on Reference page which lists Paragraph Tag Name, Right-Handed Master Page, Left-Handed Master Page, Range Indicator.
    But this doesn't seem to be enough; something is not working.
    Could you please point me toward resources which discuss how to do this?
    Thank you kindly,
    Theresa

    I think there was a big discussion of this already either here on the forum or over at the Frameusers.com list (I forget which). Try googling -

  • 10.8 Printer Orientation Problem (Landscape and Portrait)

    I recently upgraded from 10.6 to 10.8 and am using a DS40 Dye Sub printer for event green screen photography.  The software is Photokey 5 pro.  The printer orientation worked fine with 10.6 providing landscape orientation prints perfectly.  With 10.8 I have to select the opposite orientation i.e. select portrait to obtain a correctly printed landscape orientated print and vice versa.  I then try to save the orientation, even though it is opposite as a preset so that I don't have to keep changing it for each print, and it won't save. It keep defaulting back to landscape and producing a portrait print.
    Any help would be appreciated.  Like I said I can live with an opposite orientation work around, however, if it won't save it is very time consuming to have to make the change for each print especially at an event where I am printing 100's of photos.
    Thank you!!!
    Meyer

    Matt,
    DNP corporation just released the driver for 10.8.  I have been waiting for months.  The driver for 10.6 worked fine on my friends mac book unfortunately I had already updated to 10.8 and had to wait for the printer driver release. I have wasted more paper trying every possible configuration both for the printer driver in Photokey 5 pro page setup.  Very frustrating when it everything worked fine prior to 10.8.  Any thoughts?

  • Chapter titles in landscape and portrait?

    I would like my chapter titles to appear slightly differently in landscape and in portrait views. Is this possible?

    >working fine for the most part
    Any time you start seeing gremlins like this, you may be working with a corrupted book, so be careful.
    Be sure the font is iOS compatible and that the text string is not being cut-off...reduce the font size to test.
    Best to try in another fresh book to see if you can replicate. If that occurs, consider sending feedback to let Apple know, thanks.
    Ken

  • Mix landscape and portrait in one report

    Is it possible to have a container report have a mix of subreports that are portrait and some landscape?   Is it possible to embedd the printer portrait/landscape control characters on each subreport so it prints properly?   ...or something to print sideways for landscape subreports.
    I am using VS 2008, Crystal 2008, Vista Business ...this is a windows application - not a web app.
    When I mention container report, this is just a report that I use as a container for subreports.
    Thanks,
    Jeff

    Jeff, thinking about how to do this I realize that there will not be a way to get this done, not for subreports. For individual sections without subreports, yes. E.G.; this can not be done in the designer and typically, if it can not be done in the designer, it can not be done at runtime.
    While there is a way of setting a particular section to print a different orientation than the rest of the report, if there is a subreport in the section, the section's orientation property will not be passed on to the subreport.
    Alternatively, if a main report is set to portrait orientation and the subreport is set to landscape, the subreport will print landscape, on a portrait oriented page, thus resulting in data being cut off. In the reverse scenario, main report is landscape, subreport portrait, the subreport will print portrait on a landscape oriented paper and as above, data will be cut off.
    Ludek

  • Landscape and portrait mode

    My iPad is slow between rotating from landscape o portrait mode at the home screen. In apps though it is very fast. Anybody know why? It hasn't always been like this

    Hi,
    Try restarting your iPad.
    Press and hold the Sleep/Wake button until the red slider appears. Slide your finger across the slider to turn off iPad. To turn iPad back on, press and hold the Sleep/Wake until the Apple logo appears.
    See if that made a difference.
    If not, you may have an app that needs "force quitting" ...
    Try this... Press and hold the Sleep/Wake button on top of iPad for a few seconds until a red slider appears, then press and hold the Home button until the application quits.
    Try again. If it's still slow, connect your iPad to your computer, launch iTunes. Check available storage at the bottom of the iTunes window. Might be a good idea to have at least 10% free space available.
    Carolyn

  • Making a photographic book in landscape and portrait mode in iBooks author

    Hello, I am making a photographic book with the iBooks author and I have a problem that I cannot resolve. The book is only with photos, without text and I am putting every photo on a whole page. I made around 15 pages in landscape orientation and now I want to make the same thing with the same photos in portrait, but I don't know how to arrange the photos to match when the ipad is flipped. The whole idea is that I want people to see different crops of the photos when they flip the iPad. I hope that you understood me and will eventually come up with solution...  Really thanks!

    Hi user_1,
    If you are looking to reshape the graph based on whether the user has selected portrait or landscape mode, you could use a property node for your graph that executes in the same case as the print orientation, in which you reshape the graph using plotareasize or another property. I've attached an example of this.
    Hope this helps!
    -Sam F, DAQ Marketing Manager
    Learn about measuring temperature
    Learn how to take voltage measurements
    Learn how to measure current
    Attachments:
    ReShapeGraphExample.vi ‏19 KB

  • A script to batch rename and relink images?

    Hello, everyone!
    First of all, I did search for this before asking and found many similar scripts for this, but as I don't know how to make or edit scripts, I couldn't use them...
    I work at a company that makes school books. Each InDesign file we make can have hundreds of images, of varied extensions (.ai, .eps, .tif, .psd).
    We now need to rename those images to a default naming system we defined. This is taking hours, even days to do manually.
    Those images currently have varied names, so we'd need to ignore what's there, we just need a configurable prefix (like "EF6_ESP_C1_"), then a 4-digit number starting at 0001 and numbering the rest (if there's say a .tif and then a .ai, it'd have to be 0001.tif and 0002.ai), then the extension it already had.
    Preferably, but not required, if it could read that the image already had an "EQ" in the file name, it could rename them to another prefix and count those separately from 0001, as we work Equation images separately, but if this can't be done or is too difficult to do, then just have them named and numbered with the others.
    Could anyone be so kind as to help me with this? Thank you very much!

    Try this,
    var doc = app.activeDocument,
        links = doc.allGraphics, count = 1, eqcount = 1, a = "0000";
    for(var i=links.length-1;i>=0;i--)
            if(links[i].itemLink.name.match(/^EQ.+/))
                    var ext = links[i].itemLink.name.substr(links[i].itemLink.name.lastIndexOf(".")),
                        old = File(links[i].itemLink.filePath),
                        eqnum = (eqcount++).toString(),
                        newname = "EQ_EF6_ESP_C1_" + a.substring(0, a.length - eqnum.length) + eqnum + ext;
                    old.rename(newname);
                    links[i].itemLink.relink(File(old.toString().replace(links[i].itemLink.name,newname)))
            else
                    var ext = links[i].itemLink.name.substr(links[i].itemLink.name.lastIndexOf(".")),
                        old = File(links[i].itemLink.filePath),
                        num = (count++).toString(),
                        newname = "EF6_ESP_C1_" + a.substring(0, a.length - num.length) + num + ext
                    old.rename(newname);
                    links[i].itemLink.relink(File(old.toString().replace(links[i].itemLink.name,newname)))
    Please note:It is not reversible.
    Regards,
    Chinna

Maybe you are looking for