Conditionally to resize images - error

I'm trying to conditionally to resize images according to their range of pixel, but when I run my script all my images are sizing up 900 pixels, regardless of the size.

I think my conditional is poorly written, can someone help me

Thank you!

TK

#target photoshop
app.bringToFront ();

function fitImage (newImgSize) {}


var doc = activeDocument;


If (doc.width > doc.height) {doc.resizeImage (newImgSize, null, null, ResampleMethod.BICUBICSHARPER) ;}}
If (doc.width < doc.height) {doc.resizeImage (null, newImgSize, null, ResampleMethod.BICUBICSHARPER) ;}}
If (doc.width == doc.height) {doc.resizeImage (newImgSize, newImgSize, null, ResampleMethod.BICUBICSHARPER) ;}}

}


var doc = app.activeDocument;

If (parseInt (doc.height, 10) > "1200px") {fitImage (1 800 300) ;}

ElseIf (parseInt (doc.width, 10) > "1200px") {fitImage (1 800 300) ;}

else {fitImage (900 300) ;}

Problems with UnitValues. Try this for the right of the conditional part:

if (doc.height.as("px")   > 1200) {fitImage
(1800,300);}

else
 if  (doc.width.as("px") > 1200) {fitImage (1800,300);}

else
{fitImage (900,300);}

Tags: Photoshop

Similar Questions

  • AppleScript to resize images in Photoshop CS4 will not work in CS6 - help!

    Hi people.

    I am new to this lark script and hope someone can help...

    Our Nigel, unfortunately is no longer with us, wrote a cunning to convert script photographs large size smaller using Photoshop CS4.

    The workflow is the following:

    You open Photoshop

    You have two files, one with the original files and the other which is empty.

    You drag the folder with the original files on the .app and he asks a destination folder (tell you him to use the empty folder).

    The images are then opened one by one, resized, some tape removed and are then registered to the empty folder (formerly).

    Lovely jubbly.

    The problem is when you try to use this app with Photoshop CS6 - it fails at the point of backup files in the new folder which gives this error:

    Adobe Photoshop CS6 has been an error: "unable to get document"075.jpg". (- 1728)

    I fiddled with the script a little and it seems don't not like the section "with options" command 'Save document' (it works fine if I completely remove the fuse "with options" - but I need than LZW compression).  I have trawled through a few similar questions on these forums, but have not been able to track down the problem. It probably doesn't help that I'm not a programmer (just try to translate as I oppose using the Photoshop CS6 AppleScript reference guide).

    Did everyone there knows the problem please?

    The script is below.

    on Open ()pourla)

    set theDestination of (choose folder with guest 'set the destination for the files processed...) ") as text

    tell application "Finder"

    set isContainer to fake

    set theItem to agenda 1 of pourla as string

    if last character of theItem is ":" then

    set list of files to files of all of the content of agenda 1 of pourla

    on the other

    set list of files to pourla

    end if

    Repeat with x in list of files

    set Dittos to x as texte

    set theFileName to name of x as texte

    set outFilePath to theDestination & theFileName

    if theFileName ends by ".db" then

      --

    on the other

    tell application "Adobe Photoshop CS6"

    -I was skilled enough change the foregoing of "Adobe Photoshop CS4".

    set units of the rule of parameters to units of mm

      Open alias theFile

    set theWidth to width of document theFileName

    set theHeight to height of document theFileName

    if theWidth > theHeight then

    Resize image document theFileName width 65 resolution 400 resample method bicubic

    on the other

    Resize image document theFileName height 65 resolution 400 resample method bicubic

    end if

    convert document theFileName profile ' Coated FOGRA39 (ISO 12647-2: 2004) " intent perceptive with blackpoint compensation without dithering .

    { adjust layer of art 'History' of the document theFileName with curves with options { }class:curves points of the curve: {{0, 0}, {128, 128}, {243, 255}}}

    { Save document theFileName in outFilePath like TIFF adding tiny extension with options { }byte order:Mac OS embed the color profile:fake image compression:LZW} without copy

    close document 1 saving no

    fin say

    fin if

    -display outFilePath dialog box

    fin Repeat

    fin say

    end open

    file name

    Try this.

    game of myOptions to {class:TIFF to save options, the byte order:Mac OS, embed the color profile:false, image compression:LZW}

    Save document theFileName in outFilePath as TIFF with options myOptions by adding the extension lowercase without copy

    HTH.

  • Help with solution of Liz Castro iBooks bug when resizing images in epub for iPad

    Hello world.

    I create an epub for iPad with small images that will expand when they are tapped. I read Liz Castro book and blog article and learned the bug with iBooks and the solution, which, like an HTML novice, I found it difficult to understand.  It took me some time to make it work, but I just wanted to share my (imperfect) progress for other laity or secular and ask for help!

    I just add this in my template.css

    {div. Group}
    Width: 50%! important;
    }
    img {width: 100%;}

    and in each of my html chapters where there is an image, I removed the img src reference that has been automatically generated by Indesign and added this...

    < div class = "group" >
    < img src = "exampleimage.jpeg" alt = "This is an example" / > "
    < / div >

    I rezipped my files, transferred to my iPad, and the images appear small and expand when double-tapped. Fantastic! Thanks to Liz Castro. It is a bigger step.

    But it is not perfect. I would like my image to be aligned to the centre and to ensure that there is some space between the text and the image. My images are now aligned to the left, and there is no space between them and the text preceding and following them, so that it looks like a mess on the page. Before I changed the code it worked well, after I changed it it does not work. When I initially exported the InDesign file, on the Image taitouche set the spacing to the Center and 2ems has added to the image and check the box to Insert a Page break before and after a page break.

    To remedy this, I added the following to the div.group in css

    text-align: center;

    top of the margin: 2em;

    margin-bottom: 2em;

    When I converted it to an epub I've seen there is no center of the image, but there was a margin at the top and bottom. While the file opens in the problem of Sigil that it won't transfer to iBooks on the iPad, which I think means that there is a coding error.


    Is anyone know how can I Center of the image and add some space between him and the text?

    Any help would be highly appreciated.

    Some things to consider:

    1 centering and space above and below your div can be done in CSS with:

    {div. Group}
    Width: 50%! important;

    top of the margin: 1.0em.

    margin-bottom: 1.0em;

    text-align: center ;}

    There might be other ways improve to achieve this. I am not an expert in CSS or HTML; I know that what has worked for me in previous projects.

    2. in iBooks, there is a bug (or "feature") which causes the iBooks to ignore text-align for some items (such as

    ) if iBooks preferences are set to full Justification = WE. Instead of being centered, these items will be left-aligned (or perhaps justified? I have not tested). This is the default setting, so most users likely to leave like that. (the elements are not affected by this bug.)

    This is detailed in one of the blog posts from Liz Castro and also on the blog of Walt Shiel:

    http://www.pigsgourdsandwikis.com/2010/06/beating-iBooks-bugs.html

    http://waltshiel.com/2010/06/23/one-solution-to-iBooks-1-1-centering-problem/

    One of them is to wrap the text inside such an element in the empty tags .

    3. I don't know what is your target audience, but keep in mind that iBooks is far behind Amazon and BN.com in terms of volume sales. Kindle and the Nook do not support resizing images (again, in any case), so unless your book depends on this photo processing to deliver his message, you could put a lot of time and effort in a feature that few readers (yet, cases) can take advantage of.

    4. If you use Twitter, you can follow the hashtag #eprdctn - it is used by a small community of designers in the ebook to exchange information on the evolving ebook design world.

    5. other good sources of information:

    http://ebookarchitects.com/

    http://www.kindleformatting.com/ (I know it is not related to iBooks, but it is full of good info)

  • Resize image code does not work for some jpg files

    Hello. I use the code to resize images and store them on the server below. However, with some jpg files, resizing produces a reddish tint on the picture. Any ideas of what could be the cause? Here's the original image: http://www.unctv.org/tWxkBbq_10M6wKRRL/PNCWWD01.jpg and here of what happened later: http://www.unctv.org/tWxkBbq_10M6wKRRL/PABDFC01__1289231445291.jpg
    Photoshop CS5 is used to produce the input JPG for this app. thank you.
    public BufferedImage resizeVeryHigh(InputStream inputStream, File resizedFile) throws IOException {
      BufferedImage bufferedImage = null;
      try {
          Image newImage = ImageIO.read(inputStream);
          int newWidth = (int)this.targetWidth;
          ImageIcon imageIcon = new ImageIcon(newImage);
          Image image = imageIcon.getImage();
          Image resizedImage = null;
    
          int iWidth = image.getWidth(null);
          int iHeight = image.getHeight(null);
    
          // This code ensures that all the pixels in the image are loaded.
          Image temp = new ImageIcon(resizedImage).getImage();
    
          // Create the buffered image.
          bufferedImage = new BufferedImage(temp.getWidth(null), temp.getHeight(null), BufferedImage.TYPE_INT_RGB);
    
          // Copy image to buffered image.
          Graphics g = bufferedImage.createGraphics();
    
          // Clear background and paint the image.
          g.setColor(Color.white);
          g.fillRect(0, 0, temp.getWidth(null), temp.getHeight(null));
          g.drawImage(temp, 0, 0, null);
          g.dispose();
    
          // Encodes image as a JPEG data stream
          FileOutputStream out = new FileOutputStream(resizedFile);
          JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
          JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bufferedImage);
          param.setQuality(1.0f, true);
          encoder.setJPEGEncodeParam(param);
          encoder.encode(bufferedImage);
      }
      catch (Exception e) {
            this.error = e.getMessage();
      }
          return bufferedImage;
    }
    Published by: oneworld95 on November 8, 2010 11:34

    I don't know anything about the jpeg encoder, but I do not see the code which makes no sense to me:

    Image resizedImage = null;
    
    int iWidth = image.getWidth(null);
    int iHeight = image.getHeight(null);
    
    // This code ensures that all the pixels in the image are loaded.
    Image temp = new ImageIcon(resizedImage).getImage();
    

    What is so as to create an ImageIcon from an image zero?

    int newWidth = (int)this.targetWidth;
    

    I don't see where actually use you this variable, then how the image does get resized?

    To learn more create a [url http://sscce.org] NBS, which illustrates the incorrect behavior and maybe someone will take a look.

  • Dialog box controls 'Settings' 'automatic resizing Image.

    I have a signature that contains an avatar image (size 120px by 120px)
    Whenever I have 'send', one 'Auto Resize Image' > 'Settings' dialog box appears
    How can I bypass this until it becomes annoying.
    Most emails (98%) are not all other images embedded or attached.
    It started to happen after the upgrade to the latest version of Thunderbird, has never been a problem before.

    Doesn't sound like a standard Thunderbird pop up as I fell on it.

    Do you by chance an addon /extension as Auto Resize Image?

    If so, disable it and retest to see if the message stops.
    Make sure you use a current version.
    check to see if there are some parameters you can use to "do not ask again" or similar. Cannot say exactly as I do not use it.

    I use the standard settings of TB to settle for sizing when I insert an image initially.

  • IMAQ Cast Image error

    Hi guys!

    So I installed a program using a camera and an analysis of the image. It works fine on another computer, but during the installation of this second system, I get:

    The research I found: http://forums.ni.com/t5/LabVIEW/imaq-cast-image-error/m-p/3217035/highlight/true#M934230

    This suggests that it is a matter of licensing. However, I have activated the license on this computer.

    What should do?

    /Y

    Thus, it is fixed.

    It seems that I needed two NI Vision Acquisition Module AND NI Vision Development software and then enable them both to get the program running.

    Both can be installed under license with the license of the develop module.

    /Y

  • Image errors bad C:\progra~1\wia6eb~1\datamngr\datamngr.dll isn't is either not designed to run on Windows or it contains an error.

    Image errors bad C:\progra~1\wia6eb~1\datamngr\datamngr.dll isn't is either not designed to run on Windows or it contains an error. Etc.  Error messages starts to appear during startup and continues after desktop is visible.  It also happens when I try to open other things on the computer.  I ran malwarebytes, it found nothing.  I ran a registry cleaner, it did not help.  Operating system is Windows 7 and I use an Acer Netbook with no cd/dvd drive can not use a disk to reinstall.  How can I fix anything which causes these error messages?  Please notify.

    Get ccleaner run and then go to tools / boot. If it appears here delete the entry

  • Get 'bad image' errors at startup on XP

    You don't know if it's OK jst the chip but discovers this channel via Google after trying two registry fix downloads that were purchased.  Problem - suddenly 2 days ago I found that I couldn't get into XP without having to cancel about 15 messages in 'Bad Image'.  As noted that not a single program at fault, I would be grateful for any advice on how to fix the problem please.

    Separated from the:

    http://answers.Microsoft.com/en-us/Windows/Forum/windows_xp-performance/Windows-XP-bad-image-start-up-message/54e44de9-ea47-4489-AC15-243a66eedb2a

    Halima, thank you very much.  While waiting for a response, I noticed that I had a common feature of many messages 'bad image' to cancel on each startup was "Bearshare" in the description of the DLL, so I re-installed the program again and then typed "problems of Bearshare bad Image" in google, which led me to this site - http://www.geekstogo.com/forum/topic/294780-bad-image-errors/

    where I downloaded their "Revo Uninstaller" which allowed me to perform a deep unistall of Bearshare.  After reboot, I haven't lived any other message 'Bad Image'.  I hope that it will still be the case, but I'll keep your advice in case I need to try something else.  Thanks again.

    Geoff

  • Bad image error

    I am constantly bad image errors as soon as I turn on my computer until I turn it off. It displays in the form: Windows\system32\AVGRSSTX. DLL. I don't know how to stop or fix this problem.

    It is a problem with AVG http://forums.avg.com/ww-en/avg-free-forum?sec=thread&act=show&id=119251&type=0

    My recommendation is that you uninstall AVG using the appropriatehttp://www.avg.com/gb-en/download-tools removal tool

    You can then reinstall AVG or other program antivirus.

  • I just downloaded updates for 2014 PS on mac OS 10.7.5. Now, he opens all the images - error message cannot open because the open parts are incorrect?

    I just downloaded updates for 2014 PS on mac OS 10.7.5. Now, he opens all the images - error message cannot open because the open parts are incorrect?

    Hi Akash.

    Download Installer Camera Raw and it seems to have solved the problem.

    Thanks for your time.

    Concerning

    Peter DeBeer

  • Dynamically resize images on a webApp list page

    Hello world

    I used the following code to dynamically resize images for a webApp event list page:

    < img src = "{tag_image list_value}? Action = thumbnail & width = 384 & height = 253 & algorithm proportional ="/ >

    It works perfectly but when I click on the image, it is not a link to the event details page.

    Adding dynamic code I got the following only:

    list {tag_image}

    This made the image and when you click on it it went to the detail page, then is it possible to revise the dynamic code so that it renders an image which, when clicked, navigates to the page of detail?

    Would be very grateful for any advice.

    Thanks in advance.

    You encapsulate your image in an html anchor where the attribute href has the tag url for this layout in it.

  • Resize image in 300 x 300 pixels and maintain proportions?

    Hello

    How to resize images in 400 x 400 pixels while retaining the proportions when not all images already is a square. There will be white borders/edges on the sides of some of the images.

    How I did it now is to resize the image to 400 x 400 pixels through image processor and manually put images result in white 400 x 400 square. It's a lot of time when there are a lot of images to process.

    Thanks for all the answers!

    Then you crop the images to a square first 1:1 aspect ratio. Or use fit image to go up to 300 x 300 and then canvas size 300 x 300 allows you to add the missing painting. The image processor will only make the picture Fit part so you can have the pro Image Processor resize before using your actions to add the missing painting.  Or batch just an action the do both the adjustment of image and canvas size.

  • Items 11.  Resize image tool does not work.  I tried to chat online with Adobe - no help.

    I recently got a new computer (pc) and decided to download 11 elements instead of the old version that was on my old computer.   I discovered that the image resize tool does not work, even if the other functions seem to work well.

    I tried an online chat with Adobe.  Their suggestion was to buy another picture of them for $10 service. / month!

    You talk of Image > resize > Image size?

  • Did someone resize images to fit the tool frame Rectangle InDesign?

    My question is based on some booklets we have created in the past. We have some very large images every 300 dpi, but when shrunk down, they seem to have effective equal to or greater than 500 PPI. Part of me that feels when the effective dpi is great, that I should go back to photoshop and resize images, hopefully save the size of the PDF file after export. So, my questions are, did someone even resize images more to the rectangle frame to keep ppi around 300 or two, they do not do this more and let InDesign to manage this process when exporting to PDF?

    Thank you all,

    Mike

    Best quality is to resize in Photoshop and sharpen here, because InDesign doesn't have the choice of the method of sharpening. But to be honest, in the majority of cases where I do resampling in InDesign, when you export to PDF.

  • How to resize images to a specific size of lot? (URGENT!)

    I do not know how to batch resize photos using adobe bridge and then Tools > photoshop > image... processor and resize, but what I want to know is how to resize images to a size specific width and height of the lot without having to keep proportion.

    For now, I have a bunch of photos that are 2896 x 1944 pixels, but I need to resize up to 1920 x 1080 for a sequence of stop motion. But photoshop wants to keep in proportion and resizes 1608 x 1080, which is not what I want but I don't want to make them one at a time. so please help

    THX

    But photoshop wants to keep in proportion and resizes 1608 x 1080, which is not what I want but I don't want to make them one at a time. so please help

    You can do this by registering your own action in Photoshop (in the action panel) and use the image size command while unchecking the option to constrain the proportions. Then, you can fill in the size in pixels and include a save as command to close a document and a new location. Then select files in Bridge and via tools / Photoshop /Batch perform this action.

    However, if you do not change the proportions of your original photos will appear very tense because you change the proportions, I'm not sure that's what you want.

    You could also record an action to trim the originals of this size, leaving the look of the original image, only less at low, high or both. In doing so, all files are cropped to the same location that you saved the harvest on the first file.

Maybe you are looking for

  • Cut the beginning of the audio clip

    Hi all The music of music audio I am wanting to use a pause of a few seconds before it is actually. Is there some way I can adjust the audio clip, so I can get it to start bang on? I tried pulling on the handle on the side to shorten but he cut a sma

  • Re: First steps after the purchase of a laptop?

    HelloWe bought a Satellite A500-GL for my 17yo son. I could ask for advice on what needs to be done on the laptop it whips away before he spends hours playing with it! I know there will be some user guides etc there to do this, but there not the pati

  • print the front but no graphics

    Hi all I print a repair ticket on a system printer by using the configuration of VI "automatically printed front whenever VI ends the execution."  I had a problem where at the end of printing he issued a form of power, but who was using a default dri

  • M620 IO CARDS

    Hello We have a client and that he wants to buy two new servers M620 blade with the following configuration:Fabric A - Broadcom 57810S NDCFabric B - Broadcom 57810S NICFabric C - Qlogic QME2572 In the meantime, he has the following configuration of t

  • Classic BlackBerry how to Auto BCC on classic blackberry?

    Hello I recently upgraed to classic bold9900. When sending emails to the devce I am no more able to Auto BCC myslef and receive messages sent in Outlook for archiving. I have read several articles, but I have not found a simple solution but for the p