Resampling a b&w image

Hey guys, do you think it would be okay if I upsampled/resampled a black and white image (some from newspapers, some are not) and it be fairly okay for print? For that matter, does resampling an image do reasonably well enough for print?

When you say B&W image, do you reaaly mean a 1-bit (bitmap mode, in Photoshop parlance) image where pixels are either 100% black or 100% white, or do you mean a continuous tone grayscale?
Bitmap mode images can SOMETIMES be upsampled acceptably, but it will depend on the image. They won't get less jaggy. And are you saying the images are scans? Can you rescan at higher resolution to start? Newspaper images are halftones, just dots of different sizes but all 100% density, so bitmap mode is certainly appropriate for them.
I typically scan a halftone as grayscale, though, at 1200 ppi, then sharpen and adjust the levels to clean it up before converting to 1200 ppi bitmap using the 50% threshold method.
Upsampling color or grayscale is really a last resort. The image never improves by upsampling and it usually shows some sort of interpolation artifacts.

Similar Messages

  • 'Resampling' images

    I'm using Photoshop Starter Edition 3.0 on Windows XP and I want to resize images (or 'resample') so that the image takes up less bandwidth when I upload it to a website.
    But I can't find any drop-down menus or links in the programme to resize. How do I change the image so that it is 800x600, without cropping any of the image?

    You can use the email facility to do this. From Prefs you can setit to just save attachments to a folder and then "email" the images, selecting the size you want.

  • Resampling/sharpening script for single images

    I ask a lot of questions in this forum, but rarely have anything to offer back. Here's an offering that may come in useful in certain situations.
    Muppet Mark, a talented Applescript writer, has put together a script to my specifications for resampling and sharpening single images in InDesign. It works in CS2, 3 and 4.
    The operation is as follows:
    1. You select the image in InDesign.
    2. The script resamples to an effective ppi (at printed size) of 300.
    3. The script then calls on an Action SHARPEN which applies sharpening via a Smart Unsharp Mask. An edge mask is also applied.
    The process is non-destructive, so if the default sharpening is not quite right, it can easily be changed by opening the image in PS.
    The script, action and details of operation (148 kB) can be downloaded from:
    http://www.mediafire.com/?mij5dnyhtcl
    A CS4 test file (88 MB) to see the effect of the script can be downloaded from:
    http://www.mediafire.com/?yeymmdievnv

    Let me be the first to thank you. Not sure when I'll get a chance to test it, but it could come in handy.

  • How can I convert an image created in Photoshop into a format that Java's ImageIO library will take?

    Hi all,
    I've been trying to write an image resize tool to use the Lancoz resample algorithm to resize images to a high standard in Java.  The library with the algorithm/filter in it is mortennobel's image scaling library and it takes a buffered image as an input and returns the resized image as desired.  However the trouble I’m having is that the ImageIO library in Java, a standard library, which converts images given to its read method to buffered images doesn't accept certain images created in Photoshop and so it throws an exception.  My library needs to be fully automated to process possible thousands of images at a time and so manually converting them by resaving them as JPEG's is really feasibly.  Is there some way I can convert these images from Adobes Exif format to standard JFIF format?  I've tried simple inserting the APP0 marker from a JFIF image in-between the SOI and APP1 marker but the ImageIO library still failed.
    The above image is a screenshot of the binary in hex of one of the images that cause an Invalid Format exception when passed to ImageIO.
    Any help you could offer me with this would be much appreciated.
    Kind regards and thank you,
    Alexei Blue
    Science Warehouse.
    NB: I previously posted this post in Developers but was told to post it in a Photoshop forum so apologies if this is the incorrect formum

    The image scaling library does have a BiCubicFilter in it so I'll experiment around with them and see what happens.  As for the imageIO library I think it accepts Exif image types, but still for some reason it just doesn't like Adobe Photoshop types.  Maybe its the colour map it doesn't like I just can't seem to work out what's wrong which is slightly frustrating but looking round to see if I can find an answer

  • Why does ppi matter for web images?

    Hello
    When placing an image in my (web/pixel) project the resolution is dependent from the set ppi.
    When I create a new document for web, then logically only the pixels matter. Nonetheless there's a ppi field, why? And depending what value it has, placed pictures (file > place or drag&drop from Windows' explorer) get resized instead of the wanted 1:1 resolution.
    1 pixel should remain 1 pixel when working with in pixels.
    Try it out:
    Create a new document with Full HD resolution (1920x1080 pixels), set ppi to 10.
    Import a Full HD picture (Blu-Ray screenshot whatever) and it's mini-sized.
    My screen resolution is 59 ppi (I use my 39" TV as monitor) and this is set in the Photoshop preferences (in case I do some print stuff that I get a 1:1 view if wanted). If there was any logic behind the pixel-ppi-placing thing, then this set standard monitor ppi should bring me a 100% sized picture... but it doesn't. Only when the ppi is set to the fantasy value of 72 I get a 100% sized placing.
    This can be disturbing and is very annoying when starting a new project by opening an image that does not come with 72 ppi by default (my Canon camera makes 180 ppi JPEG photos)  and placing new pictures in this project. They get opened in wrong sizes, in my case largely upscaled, with no way to correct it but guess-scaling it down.
    Bug?
    Pls pls fix it.
    Ppi has nothing lost in pixels-only projects.
    The only way that works is to open all single images in Photoshop as tabs, and then drag&drop from within Ps. -.-
    Regards
    Mopsi
    Example screenshot: http://www.m-i-u.de/images-i83580bxvogj.jpg
    The yellow framed layer is a image from my camera, opened in Photoshop CS6 extended. 3264x2448 pixels (180 ppi).
    The green framed layer is a screenshot from a movie, drag&drop from the explorer. 1920x1080 (normally) unwanted upscaled here.
    The red framed layer is a screensot as well, but drag&dropped from a tab within Photoshop. It remains in its original resolution of 1920x1080.

    I'm wrong and your right. I just did some testing and Photoshop does indeed interpolate the lower resolution 600x400 72DPI image is  up size to match the higher resolution document document size during the place process. I just assumed Photoshop would preserve image quality and not interpolate the image.    As you have shown it does interpolate the image which greatly lowers the image quality of re-sized low resolution image.
    This shows you should not use Photoshop to merge images into a composite if they have greatly different resolutions.  I don't have a problem there for I never use "save for web" to save images to be displayed on displays from the web or my machine.  I use Fit Image and save as, or a Image Processor script that uses Fit Image to re-size and uses save as.  The leave all my images files resolution setting unchanged.   For some reason Save for Web changes all jpeg files it saves resolution  setting to 72 DPI even if they are 8MP images for high resolution displays..
    During testing I also tried using Photoshop's script Load Files into Stack instead of using Place.  That script works the way I assumed Photoshop Place would work.  Images layer are not interpolated they remain the correct number of pixels and the image quality is not is not changed.. The image layer are normal layers but can be converted to smart object layers however the object would be normal layer not an image file.
    When you use Place you get
    It also possible to undo Photoshop's Place scaling with a simple calculation.  Divide the image layer's original dpi by the document's dpi here there are three layer that did not start at 300dpi. two started out as 74dpi image file the other a 500dpi image file.  72/300=.24 = 24% the other 500/300=1.66666 = 166.66%
    all you need do is change the associated layer's image transform width and height scale from 100% to the calculated percents
    The only time I set document to 72DPI resolution is in Photoshop Scripts so I can calculate a font size  for a charter sting so it will fit the canvas size.  Photoshop Text Tools seem to be tied to 72DPI resolution.  Once I add the text layer I restore the document DPI resolution back to its original setting.
    So when it comes to Photoshop all files use in a project should have identical DPI resolution for best result when making composites.    My image files are either RAW files which have no DPI for they are not RGB image files. Or RGB Image files that have a high DPI resolution. I process images for print. Image files DPI resolution is meaningless when if comes to Display Screens.  All that matters is the number of pixels a display can display and the number of pixels in the image. Even images I re-size for display screens DPI are high for I do not use "Save for Web". I see no good reason to strip metadata and change resolution to 72DPI.  I tend not to interpolate image except the ones I save to be displayed on a display.  I change Print size by changing the DPI setting without resample.  My Epson 4800 inkjet printer has no problem printing high resolution pixel I see no reason resample my camera 16MP image down in size just to print at 300dpi.  If I want to a single 6"x4" print I see nothing wrong printing it at 816DPI.  My eyes can not resolve down there the printer can.  However when Printing on Roll Paper many 6"x4"  the composite document I create via a script has a 300DPI resolution and the image layers are resized to be 6" x 4".

  • Lightroom 2.5 Image Size When Printing

    I have searched and tried several approaches, but cannot get LR to adjust an image size correctly when printing. 
    For example, I have a Lab Test Page tif image that has a document size of 23" W x 29" H and a resolution of 180 ppi.
    I can use CSR 4 Image/Image Size to change this to 8" W x 10.5" H and a resolution of 320 ppi using resampling. The reduced image prints correctly in CSR 4 on 8.5" x 11" paper and results in .25" margins top and bottom. The same thing happens in LR 2.5 with the size reduced image.
    However, if I try to print the original image using LR 2.5 to automatically resize the image it does not work correctly. I have tried all sorts of combinations of settings to get it to reduce the image (as is done in CSR 4) and print with .25" top/bottom margins without success. The image fails to resize correctly.
    Is this a bug, a feature??, or operator error? Can anyone tell how to make LR 2.5 automatically resize so it prints correctly? I have tested this on other computers with the same results.
    Thanks
     

    Go to print module.
    Select Print to jpg.
    Set the resolution at 180 ppi.
    Other output settings, sharpening, paper profile as required.
    Set the margin sizes as required.
    Set the cell size to the size of the image
    Set the Custom File Dimensions to the size of the paper...29" x 23" in this case.
    You can drag the Cell size and the various borders around until you get exactly the lay out on paper you require. Then when finished hit print to file, name the file and the job is done.
    If you want to print a a different size, with a different resolution, on different sized paper, with different borders all this can be done in the print module and it is WYSIWYG so no guess work (or calculations) involved. Using LR rather than PS for this also has the advantage of using much better algorithms for upsizing images than PS and applying output sharpening for the specific media type you intend to print to, all using the RAW data

  • Determine/Reset Scale of Linked Graphics - Maximize Image Quality

    Hi, we're currently using Illustrator CS4 for website comps to quickly mock-up pages for our clients to sign-off (we've explored using Fireworks, but there's just some major things missing that we need in regards to typography, global swatches, etc.).
    But we would like to generate some final images from these files as well for the sake of efficiency, as I believe Illustrator is 'supposed' to use the same Save for Web interface as Photoshop. It's just very efficient for us to have our slices designed, setup, optimized and named in this same master document.
    But I ran a test comparing the results when generating a final JPEG from Illustrator vs. Photoshop using the same exact settings, and on a file that was 100% of final size. But the Photoshop file was significantly sharper. So I investigated a bit more and found out that the image was scaled just a bit in Illustrator (maybe 110% or less). When I got the image to be as close to 100% as possible in Illustrator, the differences were negligible.
    - So what is the quickest/easiest method of resetting an imported image to 100% of the actual size in Illustrator?
       I look at the Transform palette (where I would see the scaling in InDesign), but it doesn't tell me anything. I had to look into the Link Information in the links palette to find the scale, but I can't change anything from there.
    - Any other tips for keeping linked files looking as good and sharp as possible all the way through the process to Saving for Web?
    - If the original image has been retouched and optimized (it's a high quality image) in Photoshop before importing into Illustrator, 'SHOULD' the results from Illustrator match Photoshop when using Save for Web and the same settings?
    THANKS! It is much more efficient for us to save our graphics from Illustrator, but we can't risk losing image quality in the process.

    jethrodesign wrote
    Yeah, I see that as long as the image has a resolution of 72dpi, it does come in at 100% of size. ..
    For what you want to achieve  you are right, sort of, but your statement is wrong.
    Images are always placed at 100% size as indicated in the info when you double click the links in the Links palette. However you have to understand what size means here. If the image has metadata containing dimensional information then that is the size in Illustrator. For example if the metadata says 5 x 5 inches it will be placed as 100% with that size according to the Illustrator's rulers regardless of what the pixel resolution of the linked image is - it can be 5 or 5000 pixels per inch. If the images don't have metadata describing the dimensions then Illustrator assumes that 72 pixels are 1 inch and will place the image with that size at 100% scale. For example if the image is with 720 x 720 pixels, Illustrator will show it as 10 x 10 inches at 100% scale.
    With work for the web you are most interested in the pixel size of the images and objects. Change the units in File > Document Setup to Pixels. But have in mind that these are 72 pixels occupying one inch on the ruler in Illustrator and not the pixel resolution of the linked images. So, the Transform palette showing the selected images or objects with pixel dimensions will matter if you save for the web or export to a raster image file format where you can specify the pixel dimensions of the image. The pixel dimensions in Illustrator will not matter at all if you print the illustrator file in which case the resolution of the linked images will be used - not the pixel space they occupy in Illustrator. But for the Web all that matters is the pixel dimensions in Illustrator. So if you want the ppi (pixels per inch) in Illustrator to match the actual ppi resolutions of the placed images (links), you have to save all images from Photoshop as 72 ppi or remove their metadata. This will ensure that no resampling occurs when you save images at 100% scale from illustrator for the web .
    In Photoshop you can use its automatd batch processing features to change quickly the ppi of multiple images.
    As for the resampling of the scaled images I believe Illustrator and Photoshop use the same algorithms
    Message was edited by: emil emil for clarity and fixing spelling

  • Relation between image size, resolution and pixels

    I would like to increase the size of image by using PSE9.
    For sample existing image had: width (W) 6.073", height (H) 7.683", resolution 300, pixels W 1822, H 2305.
    A situation) when I changed the image to W 8, H10 and click on RESAMPLE the resolution on changed but number of pixels increase to W 2400  and
       H 3036
    B situation) Image size W 8, H 10 and NO ACTIVATED RESAMPLE. Now resolution reduced to 227 and number of pixel NO CHANGED from original
       W 1822, H 2305
    In my understanding if image blow up the number of pixels will be same as original and only the distance between pixels will be increase. So, resolution should
    be dropped.
    Now the question: How in sample A increase number of pixels? From where they come?
    More realistic looks sample B.
    Now other way: I used crop - make original image smaller. So, the number of pixels should degrees and resolution NO CHANGED. But PSE 9 shown number of pixels same and resolution increased.
    Is it right?
    What is wrong or right in above explanation?
    Can visible find the difference between samples A & B on computers monitor? I tried blow up sample B by 10 times and still no differences on screen,It is because resolution of monitor to low?

    A. Resample means elements adds pixels to the existng pixels to increase image size
        and\or resolution and subtracts pixels to downsize. Usually resampling to make an image
        smaller is okay, but resampling to make an image bigger can result in loss of quality.
        Of course that doesn't mean you shouldn't do it, just something to keep in mind.
    B. Leaving the resample box unchecked, elements only changes resolution (print size)
        and doesn't change the actual number of pixels (harm the image) so the image will
        be and look the same on your monitor.
    Usually a resampled image will be of lower quality than a non resampled image because
    elements has to make pixels to upsize and subtract pixels to downsize.
    Elements uses the resampling method choosen in the image size dialog to determine how,
    with one of the bicubic choices being the best for photos.
    Elements, as far as i know, uses the standard bicubic mehod for the resampling with the crop tool.
    A more detailed explanation:
    http://kb2.adobe.com/cps/331/331327.html
    MTSTUNER

  • Wrong image size when placing

    When I try to place a picture in photoshop CS6 either from drag&drop in the application window or from the place command, my image gets automatically resized based on the resolution (pixels per inch) of my document.
    Example:
    I create a new blank document, 1000*1000px @ 300ppi.
    I have another image that I want to place in the document and this image measures 500*500px @ 100ppi.
    I then go to File->Place  and the image that appears is way too big.  In the Info panel, it says that the image is 1500x1500 and the transform settings at the top indicate that the image hasen't been scaled because both width and height are at 100%
    If I cahnge my document resolution (no resample) to 100ppi, the image has the right size when I place it.
    So my question is:  Is this normal?  Because it has never done that with past versions of Photoshop.  If it is normal, is there a way I can change this because placing an image based on it's physical (printed) size makes absolutely no sense.  1 pixel = 1 pixel.
    Thank you for your help

    Once you understand how Photoshop works you can batch some some things you create some actions for.  Size is difficult to deal with in actions and often you will have problems dealing with aspect ratios and image orientation.
    To automate a process well scripting is more powerful then actions for you can use logic to solve problem area involving sizing, orientation, aspect ratios and positioning.  You can size an image to cover an area then mask off any excess to virtually crop the image to the areas aspect ratio.  If you download my Photoshop Photo Collage Toolkit there are script that create composite that can deal with any size image.
    One script PasteImageRoll.jsx can past selected images into a document to be print on roll paper. Images will be tiled into the document some images may be rotated for a better fit for the tiles aspect ratio. Image will be resized to fill the tile area and masked to virtually make a center crop of the images.  Other scripts will place in images file into collage template as smart object layers. Smart object images layers will be scaled to fit the various templates images areas position over the area and masked to the area. Link Documentation and Examples for the toolkit and Link Paste Image Roll Script Information
    Scripting is very powerful you can even open image off the web using its URL even stack all the image on a web page using its url
    OpenImageFromWeb.jsx
    // OpenImageFromWeb.jsx
    // Copyright 2006-2009
    // Written by Jeffrey Tranberry
    // Photoshop for Geeks Version 3.0
    // modified by MLH
    // modified by JJMACK 2010
    <javascriptresource>
    <about>$$$/JavaScripts/OpenImageFromWeb/About=JJMack's OpenImageFromWeb.^r^rCopyright 2010 Mouseprints.^r^rJJMack's Script.^rOpen Image From Web as a Placed smart object layer!</about>
    <category>JJMack's Script</category>
    </javascriptresource>
    Description:
    This sample script shows how to download images from a web server using the
    Socket object.
    // Note: Socket.read() parameter & behavior
    // Socket.read() will read or time out. It may not read all data fromserver. <---------------
    // Socket.read(999999) will read 999999 bytes, or timeout, or socket will be
    // closed by the server.
    // enable double clicking from the
    // Macintosh Finder or the Windows Explorer
    #target photoshop
    // Make Photoshop the frontmost application
    app.bringToFront();
    // SETUP
    var html = "";
    var request = "";
    var url = "";
    var binary = "";
    var requesthtml = "";
    var socket = new Socket;
    var domain = "www.mouseprints.net" // the domain for the file we want
    var sImg = "/old/dpr/JJMack8btiSrgb.png"; // the rest of the url for the file we want
    var port = ":80"; // the port for the file we want
    // MAIN
    var url = prompt("Enter the image's full URL http://domain/full image path",url);   // prompt for domain name
    if (url != null && url != ""){
              if ( (url.indexOf("http://") != -1)  || (url.indexOf("HTTP://") != -1)  ) {
                        domainPathLength = url.length - "http://".length;
                        domainPath = url.substr(7, domainPathLength);
                        pathOffset = domainPath.indexOf("/");
                        domain = domainPath.substr(0, pathOffset);
                        sImg = domainPath.substr(pathOffset, domainPath.length - pathOffset );
                        // Isolate Image name
                        var Name =  sImg
                        var imagePath = "";
                        while (Name.indexOf("/") != -1 ) {                                        // Strip Path
                                  imagePath= imagePath + Name.substr(0, Name.indexOf("/") + 1);
                                  Name = Name.substr(Name.indexOf("/") + 1 ,);
                        //alert("domain = " +  domain + " , Image = " + sImg + " Image File Name = " + Name);
                        if ( domain != "" && sImg != "" && sImg != "/" && Name.indexOf(".") != -1 ) {
                                  var f = File("~/" + Name); // Image file name
                                  f.encoding = "binary"; // set binary mode
                                  f.open("w");
                                  if (socket.open(domain + port, "binary")){
                                            //alert("GET " + sImg +" HTTP/1.0\n\n");
                                            requesthtml ="\n\nDmain:" + domain + " Port" + port + " binary\n"
                                            request ="GET " + sImg +" HTTP/1.0\n\n"
                                            socket.write(request); // get the file
                                            var binary = socket.read(99999999);
                                            binary = removeHeaders(binary);
                                            f.write(binary);
                                            socket.close();
                                  else { alert("Connection to Domain:" + domain + " Port" + port + " Failed   ");}
                                  f.close();
                                  if (binary.length != 0) {
                                            //alert ("file length = " + binary.length );
                                            if(app.documents.length == 0) {
                                                      //app.documents.add([width] [, height] [, resolution] [, name] [, mode] [, initialFill] [,pixelAspectRatio] [, bitsPerChannel] [,colorProfileName])
                                                      app.documents.add(new UnitValue(1600,'px'), new UnitValue(1200,'px'), 72, null, NewDocumentMode.RGB, DocumentFill.WHITE, 1,BitsPerChannelType.EIGHT, "sRGB IEC61966-2.1" );
                                            placeSmartObject( f );
                                  f.remove(); // Remove temporary downloaded files
                        else { alert("Invalid Image URL: " + url ); }
              else { alert("Invalid URL: " + url ); }
    else { if ( url == "" ) alert("No URL Entered"); }
    // FUNCTIONS
    function placeSmartObject(fileRef){
              //create a new smart object  layer using a file
              try {
                        var desc = new ActionDescriptor();
                                  desc.putPath( charIDToTypeID( "null" ), new File( fileRef ) );
                                  desc.putEnumerated( charIDToTypeID( "FTcs" ), charIDToTypeID( "QCSt" ),charIDToTypeID( "Qcsa" ));
                                  desc.putUnitDouble( charIDToTypeID( "Wdth" ),charIDToTypeID( "#Prc" ), 100 );
                                  desc.putUnitDouble( charIDToTypeID( "Hght" ), charIDToTypeID( "#Prc" ), 100 );
                                  desc.putUnitDouble( charIDToTypeID( "Angl" ), charIDToTypeID( "#Ang" ), 0 );
                                  desc.putBoolean( charIDToTypeID( "Lnkd" ), true );
                        executeAction( charIDToTypeID( "Plc " ), desc, DialogModes.NO );
                        activeDocument.activeLayer.resize(100 ,100,AnchorPosition.MIDDLECENTER);
                        activeDocument.revealAll();
              } catch (e) { alert("Placeing file: '" + fileRef + "' failed"); }
    // Remove header lines from HTTP response
    function removeHeaders(binary){
              var bContinue = true ; // flag for finding end of header
              var line = "";
              var httpheader = "";
              var nFirst = 0;
              var count = 0;
              while (bContinue) {
                        line = getLine(binary) ; // each header line
                        httpheader = httpheader + line;
                        bContinue = line.length >= 2 ; // blank header == end of header
                        nFirst = line.length + 1 ;
                        binary = binary.substr(nFirst) ;
              if (httpheader.indexOf("Bad Request") != -1 || httpheader.indexOf("Not Found") != -1) {
                        alert (requesthtml + request + httpheader);
                        var binary = "";
              //alert (requesthtml + request + httpheader + "\nFile length = " + binary.length);
              return binary;
    // Get a response line from the HTML
    function getLine(html){
              var line = "" ;
              for (var i = 0; html.charCodeAt(i) != 10; i++){ // finding line end
                        line += html[i] ;
              return line ;
    StackWebPageImages.jsx
    // Copyright 2007.  Adobe Systems, Incorporated.  All rights reserved.
    // This script demonstrates how to download images from a web server using the Socket object.
    // Adobe's Socket.jsx Photoshop sample javascript
    // modified by JJMACK 2011
    <javascriptresource>
    <about>$$$/JavaScripts/StackWebPageImages/About=JJMack's StackWebPageImages.^r^rCopyright 2011 Mouseprints.^r^rJJMack's Script.^rPlaces Images used in a Web page as smart object layers in stack in a new document!^rOnly images embedded coded with path relative to the domains root will be Placed though.^rImages that fail to be placed may be Placed into the document using your browser right click to copy image URL.^rThen paste that URL into the OpenImageFromWeb script URL input field. </about>
    <category>JJMack's Script</category>
    </javascriptresource>
    // Note: Socket.read() parameter & behavior
    // Socket.read() will read or time out. It may not read all data from server.
    // Socket.read(999999) will read 999999 bytes, or timeout, or socket will be
    // closed by the server.
    // Settings
    #target photoshop
    app.bringToFront(); // bring top
    //if("en_US" == $.locale) { // display only US build
    //          alert("This sample script shows how to download images from a web server using the Socket object.");
    // Remove header lines from HTTP response
    function removeHeaders(binary)
              var bContinue = true ; // flag for finding end of header
              var line = "";
              var nFirst = 0;
              var count  = 0;
              while (bContinue) {
                        line = getLine(binary) ; // each header line
                        bContinue = line.length >= 2 ;  // blank header == end of header
                        nFirst = line.length + 1 ;
                        binary = binary.substr(nFirst) ;
              return binary;
    // Get a response line from the HTML
    function getLine(html)
              var line = "" ;
              for (var i = 0; html.charCodeAt(i) != 10; i++){ // finding line end
                        line += html[i] ;
              return line ;
    var socket = new Socket;
    var port = "80";
    var html = "";
    //if (socket.open("www.adobe.com:80")){
    //          socket.write("GET /index.html HTTP/1.0\n\n");
    //          html = socket.read(9999999);
    //          socket.close();
    var url = "";
    var url = prompt("Enter the Web page full URL the images are in like http://domain/index.html",url);   // prompt web page
    if (url != null && url != ""){
              if ( (url.indexOf("http://") != -1)  || (url.indexOf("HTTP://") != -1)  ) {
                        domainPathLength = url.length - "http://".length;
                        domainPath = url.substr(7, domainPathLength);
                        if ( domainPath.indexOf("/") != -1 ) {
                                  pathOffset = domainPath.indexOf("/");
                                  domain = domainPath.substr(0, pathOffset);
                                  wPage= domainPath.substr(pathOffset, domainPath.length - pathOffset );
                        else {
                                  domain = domainPath;
                                    wPage = "/";
                        // Isolate Page name
                        var pName=  wPage;
                        var pagePath = "";
                        while (pName.indexOf("/") != -1 ) {
                                  pagePath= pagePath + pName.substr(0, pName.indexOf("/") + 1);
                                  pName = pName.substr(pName.indexOf("/") + 1 ,);
                        //if (socket.open("www.adobe.com:80")){
                        if (socket.open(domain +":" + port)){
                                  //alert("GET page = " + wPage + " HTTP/1.0\n\n");
                                  socket.write("GET " + wPage + " HTTP/1.0\n\n");
                                  html = socket.read(9999999);
                                  socket.close();
                                  //var aImg = html.match(/src=\"\/images\/(.*?)\"/g);                    //  src="/images/~~~"
                                  //var aImg = html.match(/img src=\"(.*?)\"/g);                              // img src="~~~"
                                  //var aImg = html.match(/img src=\"(.*?)[\"?]/g);                    // img src=["|?]~~~" 
                                  //var aImg = html.match(/img (.*?)src=\"(.*?)[\"?]/g);                    // img ~~~src="~~~" 
                                  var aImg = html.match(/<img (.*?)src=\"(.*?)\"/g);                    // <img ~~~src="~~~"
                                  //var aImg = html.match(/<img (.*?)src=\"(.*?)[\"?]/g);                    // <img ~~~src=["|?]~~~"
                                  //alert("Image List\n" + aImg);
                                  if (null != aImg) { // parsed image tags
                                            //app.documents.add([width] [, height] [, resolution] [, name] [, mode] [, initialFill] [,pixelAspectRatio] [, bitsPerChannel] [,colorProfileName])
                                            app.documents.add(new UnitValue(1600,'px'), new UnitValue(1200,'px'), 72, null, NewDocumentMode.RGB, DocumentFill.WHITE, 1,BitsPerChannelType.EIGHT, "sRGB IEC61966-2.1" );
                                            for (var i=0; i < aImg.length; i++) {
                                                      var str = aImg[i];
                                                      imageNo=i+1;
                                                      //var sImg = str.substring(5, str.length-1); // remove "src=" & ["]
                                                      //var sImg = str.substring(9, str.length-1); // remove "img src=" & ["]
                                                      var sImg = str.substring(str.indexOf('src="')+5, str.length-1); // remove "<img ... src=" & ["]
                                                      try{
                                                                if (sImg.substring(0,7) == "http://" || sImg.substring(0,7) == "HTTP://")  { placeWebImage(imageNo, sImg); } // redirect image
                                                                else {
                                                                          if (sImg.substring(0,1) != "/" ) { sImg = pagePath + sImg ; }                               // image is relative to web page path
                                                                          //else { sImg = sImg.substr(1, sImg.length - 1) ; sImg = pagePath + sImg; }          // aways include web page path bad idea
                                                                          // Isolate Image name
                                                                          var Name =  sImg;
                                                                          var imagePath = "";
                                                                          while (Name.indexOf("/") != -1 ) {                                        // Strip Path
                                                                                    imagePath= imagePath + Name.substr(0, Name.indexOf("/") + 1);
                                                                                    Name= Name.substr(Name.indexOf("/") + 1 ,);
                                                                          Name= imageNo + " " + Name;
                                                                          //var f = File("~/socket_sample_" + i + sImg.substr(sImg.length-4)); // 4 = .gif or .jpg
                                                                          var f = File("~/" + Name ); // Temp File name
                                                                          f.encoding  = "binary";  // set binary mode
                                                                          f.open("w");
                                                                          //if (socket.open("www.adobe.com:80", "binary")){
                                                                          if (socket.open(domain +":" + port, "binary")){
                                                                                    socket.write("GET " + sImg +" HTTP/1.0\n\n"); // Adobe's site image link starts with "/"
                                                                                    var binary = socket.read(9999999);
                                                                                    binary = removeHeaders(binary);
                                                                                    f.write(binary);
                                                                                    socket.close();
                                                                          else { alert("Socket Open " + domain + ":" + port + ", binary Failed"); }
                                                                          f.close();
                                                                          //app.open(f); // Open files in Photoshop
                                                                          placeSmartObject( f );
                                                                          f.remove();  // Remove temporary downloaded files
                                                      catch(e){
                                            alert("Number of images found in page = " + imageNo );
                                  else { alert("No images found for " + url); }
                        else { alert("Connection to Domain:" + domain + " Port " + port + " Failed   ");}
              else { alert("Invalid URL: " + url ); }
    else { if (url == "") alert("No URL Entered"); }
    // FUNCTIONS
    function placeSmartObject(fileRef){
              //create a new smart object layer using a file
              try {
                        var desc = new ActionDescriptor();
                                  desc.putPath( charIDToTypeID( "null" ), new File( fileRef ) );
                                  desc.putEnumerated( charIDToTypeID( "FTcs" ), charIDToTypeID( "QCSt" ),charIDToTypeID( "Qcsa" ));
                                  desc.putUnitDouble( charIDToTypeID( "Wdth" ),charIDToTypeID( "#Prc" ), 100 );
                                  desc.putUnitDouble( charIDToTypeID( "Hght" ), charIDToTypeID( "#Prc" ), 100 );
                                  desc.putUnitDouble( charIDToTypeID( "Angl" ), charIDToTypeID( "#Ang" ), 0 );
                                  desc.putBoolean( charIDToTypeID( "Lnkd" ), true );
                        executeAction( charIDToTypeID( "Plc " ), desc, DialogModes.NO );
                        activeDocument.activeLayer.resize(100 ,100,AnchorPosition.MIDDLECENTER);
                        activeDocument.revealAll();
              } catch (e) { }
    function placeWebImage(num, url){
              var socket = new Socket;
              domainPathLength = url.length - "http://".length;
              domainPath = url.substr(7, domainPathLength);
              pathOffset = domainPath.indexOf("/");
              domain = domainPath.substr(0, pathOffset);
              sImg = domainPath.substr(pathOffset, domainPath.length - pathOffset );
              // Isolate Image name
              var Name =  sImg
              var imagePath = "";
              while (Name.indexOf("/") != -1 ) {                                        // Strip Path
                        imagePath= imagePath + Name.substr(0, Name.indexOf("/") + 1);
                        Name = Name.substr(Name.indexOf("/") + 1 ,);
              Name= num + "R " + Name;
              //alert("domain = " +  domain + " , Image = " + sImg + " Image File Name = " + Name);
              if ( domain != "" && sImg != "" && sImg != "/" && Name.indexOf(".") != -1 ) {
                        var f = File("~/" + Name); // Image file name
                        f.encoding = "binary"; // set binary mode
                        f.open("w");
                        if (socket.open(domain +":" + port, "binary")){
                                  //alert("socket.write GET " + sImg +" HTTP/1.0\n\n");
                                  //socket.write("GET " + sImg +" HTTP/1.0\n\n");           // did not work
                                  socket.write("GET " + url +" HTTP/1.0\n\n");                    // use url to this server works
                                  var binary = socket.read(9999999);
                                  binary = removeHeaders(binary);
                                  f.write(binary);
                                  socket.close();
                        //else { alert("Connection to Domain:" + domain + " Port" + port + " Failed   ");}
                        f.close();
                        placeSmartObject( f );
                        f.remove(); // Remove temporary downloaded files
              //else { alert("Invalid Image URL: " + url ); }

  • Change resolution without changing quality of image?

    i have photos at 72 resolution i need to change to 300 for a banner can i do this without changing the quality of photo
    thanks
    chuck

    Maybe. Maybe not.
    You can certainly change the PPI of an image to any number you want with no change at all the the image. Just go Image>Image Size and UNCHECK Resample Image. You can now type in any PPI, the only thing that will change will be the printed size of your image.
    Do this and see what size the image will print at 300 PPI. You may need to upsample to get it to a desired printed dimension of the banner. (To upsample will need to check Resample Image and type in desired PPI and print size). Resampling will change your image by adding or subtracting pixels.

  • Resampling: Upscaling, then downscaling

    While working on some images, I selected "Front Image" before doing some cropping.  At the time, I thought "Front Image" would only ensure that the aspect ratio would stay the same.  I know about holding down the shift key while cropping, but I thought this was another way to get the same result.  The workflow involves taking large .jpeg files (approx. 3500 pixels for the long edge), doing some very minor editing (adjusting brightness, contrast and color), saving the file as a .jpeg with the quality set to 8, and making sure the long edge is no larger than 3000 pixels.
    So, the image was being upscaled after cropping, then downscaled as it was being saved.
    The quality loss is barely (if at all) noticeable.  The upscaling and downscaling was very minor, but it still bothered me that I was upscaling the photo by accident.  I did some extreme scenario tests and had a very hard time telling the difference when upscaling even a small portion of the image.
    After realizing "Front Image" was upscaling the photo, I wondered: If the image is upscaled, then downscaled before it is saved, does Photoshop get rid of the added pixels first when downscaling?
    Does the .jpeg file compression set to 8 make the results of the resampling unnoticeable?
    I was shocked that I couldn't tell a difference after upscaling even a small portion of the photo.
    I was using Photoshop CS5.

    I admit to not being an expert here.  But you might want to read these two links and come to your own conclusion on resampling, cropping, and front image.
    http://www.photoshopessentials.com/essentials/resizing-vs-resampling/
    http://damiensymonds.blogspot.com/2011/11/front-image-crop-tool-dont-touch-it.html

  • AS CS3 - Image resizing issue

    Boy this problem is driving me nuts... If I use the following:
    tell application "Adobe Photoshop CS3"
    set myDoc to the current document
    resize image myDoc resolution 300 as pixels resample method none
    resize image myDoc width 100 as millimeters
    end tell
    The script will succesfully set the width of my opened photoshop file to 100 millimeters with a resolution of 300 DPI.
    BUT
    If I try to turn the script into an application and drag and drop my photoshop file on the following application:
    on open ThisFile
    tell application "Adobe Photoshop CS3"
    open ThisFile
    set myDoc to the current document
    resize image myDoc resolution 300 as pixels resample method none
    resize image myDoc width 100 as millimeters
    end tell
    end open
    The whole thing falls over and sets my DPI to only 1 pixel and the width to 25.4mm
    Does anybody no where I am going wrong, is this a strange bug?

    Dylan, another issue I see with your droplet example is ThisFile is an alias list, even if only one object is dropped. Photoshop can't open the list. Whenever you make a droplet, you always have to repeat through the individual items in the list. All my droplets essentially look like this:
    on open theItems
      repeat with thisFile in theItems
        tell application "Adobe Photoshop CS3"
           open ThisFile
          -- yadda yadda yadda
        end tell
      end repeat
    end open

  • Problem with existing script, can't get text of item

    I'm taking an earlier script and condensing it so that it will only work from one SELECTED folder. I thought it would be simple but i seam to be running into a few issues
    This is the error I get
    Result:
    error "Can’t get last text item of alias \"Images:2012-2013:WK21:Freedom:Freedom_WK21_PSD:\"." number -1728 from last text item of alias "Images:2012-2013:WK21:Freedom:Freedom_WK21_PSD:"
    property type_list : {"8BPS"}
    property extension_list : {"psd"}
    script o
              property theseNames : {}
    end script
    -- empty log file
    do shell script "echo  'Files not processed in Photoshop :'  > ~/Desktop/LogPhotoshopError.txt"
    set noError to true
    --at the beginning of the script, ask whether to replace or skip existing files? to apply to all?
    --use the result for the if file exists?
    display dialog "Should I replace or skip exisiting files?" buttons {"Replace", "Skip (Faster)"} default button 2 with icon 1
    set skipFiles to (button returned of the result) is "Skip (Faster)"
    --Below is what I removed
    --set dtF to paragraphs of (do shell script "ls -F ~/Desktop | grep '/' | cut -d'/' -f1")
    --set tc to (count dtF)
    --repeat with i from 1 to tc
    --          set folderName to item i of dtF --<:  is the folder name, no need to use text item delimiters -->":"
    --          if folderName does not start with "2_" and folderName does not start with "Hot" and folderName does not start with "Press" and folderName does --not start with "Design" and folderName does not start with "Keywords" and folderName does not start with "Season" and folderName does not
    --start with "Sue" and folderName does not start with "Design" then
    --Setup list of folders and process details of folders
    tell application "Finder" to set folderName to (choose folder with prompt "Select Folder")
    set {oldTID, my text item delimiters} to {my text item delimiters, "_WK"}
    set FolderEndName to last text item of folderName
    set brandName to first text item of folderName
    set my text item delimiters to "_PSD"
    set weekNumber to first text item of FolderEndName
    set my text item delimiters to oldTID
    set theFolder to ("Hal 9000:Users:matthew:Desktop:" & folderName)
    --set up names to destination folders and create locally based on brand name and week number
    set this_local_folder to "Images:2012-2013"
    set localWeekFolder to my getFolderPath("WK" & weekNumber, this_local_folder)
    set localBrandFolder to my getFolderPath(brandName, localWeekFolder)
    set localBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", localBrandFolder)
    set localBrandFolder_High_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_HR", localBrandFolder)
    set localBrandFolder_PSD to my getFolderPath(brandName & "_WK" & weekNumber & "_PSD", localBrandFolder)
    set this_Network_folder to "DCKGEN:Brands:Zoom:Brand - Zoom:Upload Photos:2013:"
    set networkWeekFolder to my getFolderPath("Week" & weekNumber, this_Network_folder)
    set networkBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", networkWeekFolder)
    set website_images to "DCKGEN:Website_Images:"
    --set up names to destination folders and create over Netwrok for FTP collection (based on a mounted drive)
    set this_ftp_folder to "Impulse:"
    set ftpWeekFolder to my getFolderPath("Week" & weekNumber, this_ftp_folder)
    set ftpBrandFolder to my getFolderPath(brandName, ftpWeekFolder)
    set ftpBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", ftpBrandFolder)
    set ftpBrandFolder_High_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_HR", ftpBrandFolder)
    --taking the folder identify which process it must follow.  F R E E D O M   W I T H  P N G
    if brandName is equal to "Freedom" then
              try
                        tell application "Finder" to set o's theseNames to (name of files of alias theFolder whose file type is in the type_list or name extension is in the extension_list)
              on error
                        set o's theseNames to {} -- no psd files or "8BPS"
              end try
              set numOfNames to (count o's theseNames)
              repeat with j from 1 to numOfNames
                        set thefile to theFolder & ":" & (item j of o's theseNames)
      --    F R E E D O M     Folder Photoshop Process W I T H  P N G
                        set thisName to (item j of o's theseNames)
                        tell application "Finder"
                                  set t_ext to name extension of file thefile
                                  if t_ext is not "" then set thisName to text 1 thru -((count t_ext) + 2) of thisName
                                  set b to exists file (localBrandFolder_PSD & thisName & ".psd")
                        end tell
                        if not b or (b and not skipFiles) then -- not exists file or file exists and "replace" (continue the rest of the script).
                                  tell application "Adobe Photoshop CS5.1"
      -- I remove the command activate, Photoshop stay in background
                                            set ruler units of settings to pixel units
                                            try
      open (alias thefile) showing dialogs never
                                                      set origName to name of current document
                                                      set myOptions to {class:JPEG save options, quality:12}
                                                      set myPNGOptions to {class:PNG save options, interlaced:false}
                                                      set myPSDOptions to {class:Photoshop save options, embed color profile:true, save layers:true}
                                                      tell current document
      --If the quick mask mode has been left on then delete the channel Quick Mask
                                                                if (quick mask mode) then delete channel ¬
                                                                          "Quick Mask"
      --If the Layer is incorrectly labeled with Original Layer it needs renaming to original Image
                                                                if (exists layer "Original Layer") then ¬
                                                                          tell layer "Original Layer" to set name to "Original Image"
      save in (localBrandFolder_PSD & origName) as Photoshop format with options myPSDOptions without copying
                                                                (delete layer "Original Image") flatten
      resize image resolution 300 resample method none
      --sharpen image
      filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
      save in (ftpBrandFolder_High_Res & name) as JPEG with options myOptions without copying
      --Prepare for Low RES by resetting image history
                                                                set current history state to history state 3
      delete current layer
      merge visible layers
                                                                resize image width 1020
      resize image resolution 300 resample method none
      filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
      --add save to lowResFolder with same options
      save in (networkBrandFolder_Low_Res & name) as PNG with options myPNGOptions without copying
      flatten
      save in (networkBrandFolder_Low_Res & name) as JPEG with options myOptions without copying
                                                                set newFile to file path
                                                                set newFile2 to newFile as string -- for testing end of name
                                                                if newFile2 ends with "_2.jpg" or newFile2 ends with "_3.jpg" or newFile2 ends with "_4.jpg" or newFile2 ends with "_5.jpg" or newFile2 ends with "_6.jpg" or newFile2 ends with "_7.jpg" or newFile2 ends with "_8.jpg" or newFile2 ends with "_9.jpg" or newFile2 ends with "_10.jpg" or newFile2 ends with "11.jpg" then -- exclude website_images
                                                                          my duplicateFile(newFile, {ftpBrandFolder_Low_Res})
                                                                else
                                                                          save in (website_images & name) as JPEG with options myOptions without copying
                                                                end if
      close saving no
                                                      end tell
                                            on error
                                                      set noError to false
                                                      my myLogs(thefile) -- write path to log file in Desktop
                                                      try
      close saving no --if exists, close current document
                                                      end try
                                            end try
                                  end tell
                        end if
              end repeat
      --End F R E E D O M  W I T H  P N G
    end if
    if not noError then do shell script "/usr/bin/open  ~/Desktop/LogPhotoshopError.txt'"
    on myLogs(t)
              try
                        do shell script "echo " & (quoted form of t) & ">> ~/Desktop/LogPhotoshopError.txt'"
              end try
    end myLogs
    on duplicateFile(tFile, foldersPath) -- tFile is an alias, foldersPath is a list of folder
              tell application "Finder" to repeat with folderPath in foldersPath
                        with timeout of 200 seconds -- adjust it,  error if the copy  is longer that 200 seconds
      duplicate tFile to folder folderPath with replacing
                        end timeout
              end repeat
    end duplicateFile
    on getFolderPath(tName, folderPath)
              tell application "Finder" to tell folder folderPath
                        if not (exists folder tName) then
                                  return (make new folder at it with properties {name:tName}) as string
                        else
                                  return (folder tName) as string
                        end if
              end tell
    end getFolderPath
    tell application "Finder"
              open "Hal 9000:Users:matthew:Desktop:LogPhotoshopError.txt"
    end tell

    I'm getting close or at least I hope this is how it looks now, but appears not pick up the files in the folder?
    The result
              exists folder "Freedom_WK20_HR" of folder "impulse:Week20:Freedom:"
              get folder "Freedom_WK20_HR" of folder "impulse:Week20:Freedom:"
              get name of every file of alias (alias "Images:2012-2013:WK20:Freedom:Freedom_WK20_PSD:") whose {"8BPS"} contains file type or {"psd"} contains name extension
              open "Hal 9000:Users:matthew:Desktop:LogPhotoshopError.txt"
    end tell
    --------------------MAIN SCRIPT BELOW__------------------
    property type_list : {"8BPS"}
    property extension_list : {"psd"}
    script o
              property theseNames : {}
    end script
    -- empty log file
    do shell script "echo  'Files not processed in Photoshop :'  > ~/Desktop/LogPhotoshopError.txt"
    set noError to true
    --at the beginning of the script, ask whether to replace or skip existing files? to apply to all?
    --use the result for the if file exists?
    display dialog "Should I replace or skip exisiting files?" buttons {"Replace", "Skip (Faster)"} default button 2 with icon 1
    set skipFiles to (button returned of the result) is "Skip (Faster)"
    --Setup list of folders and process details of folders
    tell application "Finder"
              set theFolder to (choose folder with prompt "Select Folder")
              set folderName to name of theFolder
              set {oldTID, my text item delimiters} to {my text item delimiters, "_WK"}
              set FolderEndName to last text item of folderName
              set brandName to first text item of folderName
              set my text item delimiters to "_PSD"
              set weekNumber to first text item of FolderEndName
              set my text item delimiters to oldTID
      --set up names to destination folders and create locally based on brand name and week number
              set this_local_folder to "Images:2012-2013"
              set localWeekFolder to my getFolderPath("WK" & weekNumber, this_local_folder)
              set localBrandFolder to my getFolderPath(brandName, localWeekFolder)
              set localBrandFolder_PSD to my getFolderPath(brandName & "_WK" & weekNumber & "_PSD", localBrandFolder)
              set this_Network_folder to "DCKGEN:Brands:Zoom:Brand - Zoom:Upload Photos:2013:"
              set networkWeekFolder to my getFolderPath("Week" & weekNumber, this_Network_folder)
              set networkBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", networkWeekFolder)
              set website_images to "DCKGEN:Website_Images:"
      --set up names to destination folders and create over Netwrok for FTP collection (based on a mounted drive)
              set this_ftp_folder to "Impulse:"
              set ftpWeekFolder to my getFolderPath("Week" & weekNumber, this_ftp_folder)
              set ftpBrandFolder to my getFolderPath(brandName, ftpWeekFolder)
              set ftpBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", ftpBrandFolder)
              set ftpBrandFolder_High_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_HR", ftpBrandFolder)
      --taking the folder identify which process it must follow.
              if brandName is equal to "BHS" then
                        try
                                  tell application "Finder" to set o's theseNames to (name of files of alias theFolder whose file type is in the type_list or name extension is in the extension_list)
                        on error
                                  set o's theseNames to {} -- no psd files or "8BPS"
                        end try
                        set numOfNames to (count o's theseNames)
                        repeat with j from 1 to numOfNames
                                  set thefile to theFolder & ":" & (item j of o's theseNames)
      --    B H S    Folder Photoshop Process
                                  set thisName to (item j of o's theseNames)
                                  tell application "Finder"
                                            set t_ext to name extension of file thefile
                                            if t_ext is not "" then set thisName to text 1 thru -((count t_ext) + 2) of thisName
                                            set b to exists file (localBrandFolder_PSD & thisName & ".psd")
                                  end tell
                                  if not b or (b and not skipFiles) then -- not exists file or file exists and "replace" (continue the rest of the script).
                                            tell application "Adobe Photoshop CS5.1"
      -- I remove the command activate, Photoshop stay in background
                                                      set ruler units of settings to pixel units
                                                      try
      open (alias thefile) showing dialogs never
                                                                set origName to name of current document
                                                                set myOptions to {class:JPEG save options, quality:12}
                                                                set myPSDOptions to {class:Photoshop save options, embed color profile:true, save layers:true}
                                                                tell current document
      --If the quick mask mode has been left on then delete the channel Quick Mask
                                                                          if (quick mask mode) then delete channel ¬
                                                                                    "Quick Mask"
      --If the Layer is incorrectly labeled with Original Layer it needs renaming to original Image
                                                                          if (exists layer "Original Layer") then ¬
                                                                                    tell layer "Original Layer" to set name to "Original Image"
      save in (localBrandFolder_PSD & origName) as Photoshop format with options myPSDOptions without copying
                                                                          (delete layer "Original Image") flatten
      resize image resolution 300 resample method none
      --sharpen image
      filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
      save in (ftpBrandFolder_High_Res & name) as JPEG with options myOptions without copying
      --Prepare for Low RES by resetting image history
                                                                          set current history state to history state 3
                                                                          flatten
                                                                          resize image width 1348
      resize image resolution 300 resample method none
      filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
      --add save to lowResFolder with same options
      save in (networkBrandFolder_Low_Res & name) as JPEG with options myOptions without copying
                                                                          set newFile to file path
                                                                          set newFile2 to newFile as string -- for testing end of name
                                                                          if newFile2 ends with "_2.jpg" or newFile2 ends with "_3.jpg" or newFile2 ends with "_4.jpg" or newFile2 ends with "_5.jpg" or newFile2 ends with "_6.jpg" or newFile2 ends with "_7.jpg" or newFile2 ends with "_8.jpg" or newFile2 ends with "_9.jpg" or newFile2 ends with "_10.jpg" or newFile2 ends with "11.jpg" then -- exclude website_images
                                                                                    my duplicateFile(newFile, {ftpBrandFolder_Low_Res})
                                                                          else
                                                                                    my duplicateFile(newFile, {ftpBrandFolder_Low_Res, website_images})
                                                                          end if
      close saving no
                                                                end tell
                                                      on error
                                                                set noError to false
                                                                my myLogs(thefile) -- write path to log file in Desktop
                                                                try
      close saving no --if exists, close current document
                                                                end try
                                                      end try
                                            end tell
                                  end if
                        end repeat
      --End BHS
      --taking the folder identify which process it must follow. B U R T O N
              else if brandName is equal to "Burton" then
                        try
                                  tell application "Finder" to set o's theseNames to (name of files of alias theFolder whose file type is in the type_list or name extension is in the extension_list)
                        on error
                                  set o's theseNames to {} -- no psd files or "8BPS"
                        end try
                        set numOfNames to (count o's theseNames)
                        repeat with j from 1 to numOfNames
                                  set thefile to theFolder & ":" & (item j of o's theseNames)
      --    B U R T O N    Folder Photoshop Process
                                  set thisName to (item j of o's theseNames)
                                  tell application "Finder"
                                            set t_ext to name extension of file thefile
                                            if t_ext is not "" then set thisName to text 1 thru -((count t_ext) + 2) of thisName
                                            set b to exists file (localBrandFolder_PSD & thisName & ".psd")
                                  end tell
                                  if not b or (b and not skipFiles) then -- not exists file or file exists and "replace" (continue the rest of the script).
                                            tell application "Adobe Photoshop CS5.1"
      -- I remove the command activate, Photoshop stay in background
                                                      set ruler units of settings to pixel units
                                                      try
      open (alias thefile) showing dialogs never
                                                                set origName to name of current document
                                                                set myOptions to {class:JPEG save options, quality:12}
                                                                set myPSDOptions to {class:Photoshop save options, embed color profile:true, save layers:true}
                                                                tell current document
      --If the quick mask mode has been left on then delete the channel Quick Mask
                                                                          if (quick mask mode) then delete channel ¬
                                                                                    "Quick Mask"
      --If the Layer is incorrectly labeled with Original Layer it needs renaming to original Image
                                                                          if (exists layer "Original Layer") then ¬
                                                                                    tell layer "Original Layer" to set name to "Original Image"
      save in (localBrandFolder_PSD & origName) as Photoshop format with options myPSDOptions without copying
                                                                          (delete layer "Original Image") flatten
      resize image resolution 300 resample method none
      --sharpen image
      filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
      save in (ftpBrandFolder_High_Res & name) as JPEG with options myOptions without copying
      --Prepare for Low RES by resetting image history
                                                                          set current history state to history state 3
                                                                          flatten
                                                                          resize image width 1020
      resize image resolution 300 resample method none
      filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
      --add save to lowResFolder with same options
      save in (networkBrandFolder_Low_Res & name) as JPEG with options myOptions without copying
                                                                          set newFile to file path
                                                                          set newFile2 to newFile as string -- for testing end of name
                                                                          if newFile2 ends with "_2.jpg" or newFile2 ends with "_3.jpg" or newFile2 ends with "_4.jpg" or newFile2 ends with "_5.jpg" or newFile2 ends with "_6.jpg" or newFile2 ends with "_7.jpg" or newFile2 ends with "_8.jpg" or newFile2 ends with "_9.jpg" or newFile2 ends with "_10.jpg" or newFile2 ends with "11.jpg" then -- exclude website_images
                                                                                    my duplicateFile(newFile, {ftpBrandFolder_Low_Res})
                                                                          else
                                                                                    my duplicateFile(newFile, {ftpBrandFolder_Low_Res, website_images})
                                                                          end if
      close saving no
                                                                end tell
                                                      on error
                                                                set noError to

  • Dialog prompt and check if file exists, and use the result of dialog

    I have this working script and I want to change the way it behaves.
    I want a dialog to come up, Do you want to skip or replace existing files.
    Then the result  of the dialog to be used in the reast of the script.
    I've added it in the script where I need to use it. in noce big letters, hopefully its not a big job.
    Many thanks
    property type_list : {"8BPS"}
    property extension_list : {"psd"}
    script o
              property theseNames : {}
    end script
    -- empty log file
    do shell script "echo  'Files not processed in Photoshop :'  > ~/Desktop/LogPhotoshopError.txt"
    set noError to true
    --Setup list of folders and process details of folders
    set dtF to paragraphs of (do shell script "ls -F ~/Desktop | grep '/' | cut -d'/' -f1")
    set tc to (count dtF)
    repeat with i from 1 to tc
              set folderName to item i of dtF --<:  is the folder name, no need to use text item delimiters -->":"
              if folderName does not start with "2_" and folderName does not start with "Hot" and folderName does not start with "Press" and folderName does not start with "Design" and folderName does not start with "Keywords" and folderName does not start with "Season" and folderName does not start with "Sue" and folderName does not start with "Design" then
                        set {oldTID, my text item delimiters} to {my text item delimiters, "_WK"}
                        set FolderEndName to last text item of folderName
                        set brandName to first text item of folderName
                        set my text item delimiters to "_PSD"
                        set weekNumber to first text item of FolderEndName
                        set my text item delimiters to oldTID
                        set theFolder to ("Hal 9000:Users:matthew:Desktop:" & folderName)
      --set up names to destination folders and create locally based on brand name and week number
                        set this_local_folder to "Images:2012-2013"
                        set localWeekFolder to my getFolderPath("WK" & weekNumber, this_local_folder)
                        set localBrandFolder to my getFolderPath(brandName, localWeekFolder)
                        set localBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", localBrandFolder)
                        set localBrandFolder_High_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_HR", localBrandFolder)
                        set localBrandFolder_PSD to my getFolderPath(brandName & "_WK" & weekNumber & "_PSD", localBrandFolder)
                        set this_Network_folder to "GEN:Brands:Zoom:Brand - Zoom:Upload Photos:2013:"
                        set networkWeekFolder to my getFolderPath("Week" & weekNumber, this_Network_folder)
                        set networkBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", networkWeekFolder)
                        set website_images to "GEN:Website_Images:"
      --set up names to destination folders and create over Netwrok for FTP collection (based on a mounted drive)
                        set this_ftp_folder to "pulse:"
                        set ftpWeekFolder to my getFolderPath("Week" & weekNumber, this_ftp_folder)
                        set ftpBrandFolder to my getFolderPath(brandName, ftpWeekFolder)
                        set ftpBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", ftpBrandFolder)
                        set ftpBrandFolder_High_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_HR", ftpBrandFolder)
      --at the beginning of the script, ask whether to replace or skip existing files? to apply to all?
      --use the result for the if file exists?
                        display dialog "Should I replace or skip exisiting files?" buttons {"Replace", "Skip (Faster)"} default button 2 with icon 1
      --taking the folder identify which process it must follow.
                        if brandName is equal to "BH" then
                                  try
                                            tell application "Finder" to set o's theseNames to (name of files of alias theFolder whose file type is in the type_list or name extension is in the extension_list)
                                  on error
                                            set o's theseNames to {} -- no psd files or "8BPS"
                                  end try
                                  set numOfNames to (count o's theseNames)
                                  repeat with j from 1 to numOfNames
                                            set thefile to theFolder & ":" & (item j of o's theseNames)
      --    B H   Folder Photoshop Process
      --if thefile exists in the folder localBrandFolder_PSD then do the result of dialog.
      --"Skip" the file and move on to next
      --If "replace" continue the rest of the script.
                                            tell application "Adobe Photoshop CS5.1"
      -- I remove the command activate, Photoshop stay in background
                                                      set ruler units of settings to pixel units
                                                      try
      open (alias thefile) showing dialogs never
                                                                set origName to name of current document
                                                                set myOptions to {class:JPEG save options, quality:12}
                                                                set myPSDOptions to {class:Photoshop save options, embed color profile:true, save layers:true}
                                                                tell current document
      --If the quick mask mode has been left on then delete the channel Quick Mask
                                                                          if (quick mask mode) then delete channel ¬
                                                                                    "Quick Mask"
      --If the Layer is incorrectly labeled with Original Layer it needs renaming to original Image
                                                                          if (exists layer "Original Layer") then ¬
                                                                                    tell layer "Original Layer" to set name to "Original Image"
      save in (localBrandFolder_PSD & origName) as Photoshop format with options myPSDOptions without copying
                                                                          (delete layer "Original Image") flatten
      resize image resolution 300 resample method none
      --sharpen image
      filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
      save in (localBrandFolder_High_Res & name) as JPEG with options myOptions without copying
      --get file path, return path of the JPEG file, work with (without copying)
      -- (with copying) : it return path of PSD file
                                                                          set newFile to file path --( return path of type alias )
      -- duplicate file using the Finder  -->on duplicateFile(..)
                                                                          my duplicateFile(newFile, {ftpBrandFolder_High_Res})
      --Prepare for Low RES by resetting image history
                                                                          set current history state to history state 3
                                                                          flatten
                                                                          resize image width 1348
      resize image resolution 300 resample method none
      filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
      --add save to lowResFolder with same options
      save in (localBrandFolder_Low_Res & name) as JPEG with options myOptions without copying
                                                                          set newFile to file path
                                                                          set newFile2 to newFile as string -- for testing end of name
                                                                          if newFile2 ends with "_2.jpg" or newFile2 ends with "_3.jpg" then -- exclude website_images
                                                                                    my duplicateFile(newFile, {networkBrandFolder_Low_Res, ftpBrandFolder_Low_Res})
                                                                          else
                                                                                    my duplicateFile(newFile, {networkBrandFolder_Low_Res, ftpBrandFolder_Low_Res, website_images})
                                                                          end if
      close saving no
                                                                end tell
                                                      on error
                                                                set noError to false
                                                                my myLogs(thefile) -- write path to log file in Desktop
                                                                try
      close saving no --if exists, close current document
                                                                end try
                                                      end try
                                            end tell
                                  end repeat
      --End BH
    -- else if and the rest of the script.....
    end repeat
    if not noError then do shell script "/usr/bin/open  ~/Desktop/LogPhotoshopError.txt'"
    on myLogs(t)
              try
                        do shell script "echo " & (quoted form of t) & ">> ~/Desktop/LogPhotoshopError.txt'"
              end try
    end myLogs
    on duplicateFile(tFile, foldersPath) -- tFile is an alias, foldersPath is a list of folder
              tell application "Finder" to repeat with folderPath in foldersPath
                        with timeout of 200 seconds -- adjust it,  error if the copy  is longer that 200 seconds
      duplicate tFile to folder folderPath with replacing
                        end timeout
              end repeat
    end duplicateFile
    on getFolderPath(tName, folderPath)
              tell application "Finder" to tell folder folderPath
                        if not (exists folder tName) then
                                  return (make new folder at it with properties {name:tName}) as string
                        else
                                  return (folder tName) as string
                        end if
              end tell
    end getFolderPath
    tell application "Finder"
              open "Hal 9000:Users:matthew:Desktop:LogPhotoshopError.txt"
    end tell

    Hi,
    I think that's what you want.
    I put the dialog in the beginning, so it does not appear to each folder, otherwise put it in the loop as it was originally.
    property type_list : {"8BPS"}
    property extension_list : {"psd"}
    script o
          property theseNames : {}
    end script
    -- empty log file
    do shell script "echo  'Files not processed in Photoshop :'  > ~/Desktop/LogPhotoshopError.txt"
    set noError to true
    --at the beginning of the script, ask whether to replace or skip existing files? to apply to all?
    --use the result for the if file exists?
    display dialog "Should I replace or skip exisiting files?" buttons {"Replace", "Skip (Faster)"} default button 2 with icon 1
    set skipFiles to (button returned of the result) is "Skip (Faster)"
    --Setup list of folders and process details of folders
    set dtF to paragraphs of (do shell script "ls -F ~/Desktop | grep '/' | cut -d'/' -f1")
    set tc to (count dtF)
    repeat with i from 1 to tc
          set folderName to item i of dtF --<:  is the folder name, no need to use text item delimiters -->":"
          if folderName does not start with "2_" and folderName does not start with "Hot" and folderName does not start with "Press" and folderName does not start with "Design" and folderName does not start with "Keywords" and folderName does not start with "Season" and folderName does not start with "Sue" and folderName does not start with "Design" then
                set {oldTID, my text item delimiters} to {my text item delimiters, "_WK"}
                set FolderEndName to last text item of folderName
                set brandName to first text item of folderName
                set my text item delimiters to "_PSD"
                set weekNumber to first text item of FolderEndName
                set my text item delimiters to oldTID
                set theFolder to ("Hal 9000:Users:matthew:Desktop:" & folderName)
                --set up names to destination folders and create locally based on brand name and week number
                set this_local_folder to "Images:2012-2013"
                set localWeekFolder to my getFolderPath("WK" & weekNumber, this_local_folder)
                set localBrandFolder to my getFolderPath(brandName, localWeekFolder)
                set localBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", localBrandFolder)
                set localBrandFolder_High_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_HR", localBrandFolder)
                set localBrandFolder_PSD to my getFolderPath(brandName & "_WK" & weekNumber & "_PSD", localBrandFolder)
                set this_Network_folder to "GEN:Brands:Zoom:Brand - Zoom:Upload Photos:2013:"
                set networkWeekFolder to my getFolderPath("Week" & weekNumber, this_Network_folder)
                set networkBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", networkWeekFolder)
                set website_images to "GEN:Website_Images:"
                --set up names to destination folders and create over Netwrok for FTP collection (based on a mounted drive)
                set this_ftp_folder to "pulse:"
                set ftpWeekFolder to my getFolderPath("Week" & weekNumber, this_ftp_folder)
                set ftpBrandFolder to my getFolderPath(brandName, ftpWeekFolder)
                set ftpBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", ftpBrandFolder)
                set ftpBrandFolder_High_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_HR", ftpBrandFolder)
                --taking the folder identify which process it must follow.
                if brandName is equal to "BH" then
                      try
                            tell application "Finder" to set o's theseNames to (name of files of alias theFolder whose file type is in the type_list or name extension is in the extension_list)
                      on error
                            set o's theseNames to {} -- no psd files or "8BPS"
                      end try
                      set numOfNames to (count o's theseNames)
                      repeat with j from 1 to numOfNames
                            set thefile to theFolder & ":" & (item j of o's theseNames)
                            --    B H   Folder Photoshop Process
                            tell application "Finder" to set b to exists file (localBrandFolder_PSD & item j of o's theseNames)
                            if b and not skipFiles then -- file exists and "replace" (continue the rest of the script).
                                  tell application "Adobe Photoshop CS5.1"
                                        -- I remove the command activate, Photoshop stay in background
                                        set ruler units of settings to pixel units
                                        try
                                              open (alias thefile) showing dialogs never
                                              set origName to name of current document
                                              set myOptions to {class:JPEG save options, quality:12}
                                              set myPSDOptions to {class:Photoshop save options, embed color profile:true, save layers:true}
                                              tell current document
                                                    --If the quick mask mode has been left on then delete the channel Quick Mask
                                                    if (quick mask mode) then delete channel ¬
                                                          "Quick Mask"
                                                    --If the Layer is incorrectly labeled with Original Layer it needs renaming to original Image
                                                    if (exists layer "Original Layer") then ¬
                                                          tell layer "Original Layer" to set name to "Original Image"
                                                    save in (localBrandFolder_PSD & origName) as Photoshop format with options myPSDOptions without copying
                                                    (delete layer "Original Image") flatten
                                                    resize image resolution 300 resample method none
                                                    --sharpen image
                                                    filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
                                                    save in (localBrandFolder_High_Res & name) as JPEG with options myOptions without copying
                                                    --get file path, return path of the JPEG file, work with (without copying)
                                                    -- (with copying) : it return path of PSD file
                                                    set newFile to file path --( return path of type alias )
                                                    -- duplicate file using the Finder  -->on duplicateFile(..)
                                                    my duplicateFile(newFile, {ftpBrandFolder_High_Res})
                                                    --Prepare for Low RES by resetting image history
                                                    set current history state to history state 3
                                                    flatten
                                                    resize image width 1348
                                                    resize image resolution 300 resample method none
                                                    filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
                                                    --add save to lowResFolder with same options
                                                    save in (localBrandFolder_Low_Res & name) as JPEG with options myOptions without copying
                                                    set newFile to file path
                                                    set newFile2 to newFile as string -- for testing end of name
                                                    if newFile2 ends with "_2.jpg" or newFile2 ends with "_3.jpg" then -- exclude website_images
                                                          my duplicateFile(newFile, {networkBrandFolder_Low_Res, ftpBrandFolder_Low_Res})
                                                    else
                                                          my duplicateFile(newFile, {networkBrandFolder_Low_Res, ftpBrandFolder_Low_Res, website_images})
                                                    end if
                                                    close saving no
                                              end tell
                                        on error
                                              set noError to false
                                              my myLogs(thefile) -- write path to log file in Desktop
                                              try
                                                    close saving no --if exists, close current document
                                              end try
                                        end try
                                  end tell
                            end if -- else "Skip" the file and move on to next
                      end repeat
                      --End BH
                end if
          end if
    end repeat
    if not noError then do shell script "/usr/bin/open  ~/Desktop/LogPhotoshopError.txt'"
    on myLogs(t)
          try
                do shell script "echo " & (quoted form of t) & ">> ~/Desktop/LogPhotoshopError.txt'"
          end try
    end myLogs
    on duplicateFile(tFile, foldersPath) -- tFile is an alias, foldersPath is a list of folder
          tell application "Finder" to repeat with folderPath in foldersPath
                with timeout of 200 seconds -- adjust it,  error if the copy  is longer that 200 seconds
                      duplicate tFile to folder folderPath with replacing
                end timeout
          end repeat
    end duplicateFile
    on getFolderPath(tName, folderPath)
          tell application "Finder" to tell folder folderPath
                if not (exists folder tName) then
                      return (make new folder at it with properties {name:tName}) as string
                else
                      return (folder tName) as string
                end if
          end tell
    end getFolderPath
    tell application "Finder"
          open "Hal 9000:Users:matthew:Desktop:LogPhotoshopError.txt"
    end tell

  • Get current file of Photoshop.

    All I want to do is from with in photoshop (the user applescript folder) is run this script but rather than select a file, use the open file on photoshop and process (there maybe others open so it would need to get the current document and file name)
    Many Thanks
    Matt
    property type_list : {"8BPS"}
    property extension_list : {"psd"}
    script o
              property theseNames : {}
    end script
    set thefile to (choose file) as text --> the file path
    tell application "Finder" to set TheName to (name of file thefile) --> the name
    set the1stLetter to the first character of TheName --> the first letter
    set the2ndLetter to the second character of TheName --> the first letter
    set brandInitial to {the1stLetter, the2ndLetter} as text
    if brandInitial is equal to "BH" then ¬
              set brandName to "BRAND"
    if brandInitial is equal to "AL" then ¬
              set brandName to "BRand"
    set weekNumber to ""
    display dialog "Please enter the week number:" default answer weekNumber
    set weekNumber to text returned of result
    try
              if weekNumber = "" then error
              set theWeekNumber to theWeekNumber as number
    on error
              set thePrefix to "INVALID ENTRY! "
    end try
    --Folder location Setup
    set this_local_folder to "Images:2012-2013"
    set localWeekFolder to my getFolderPath("WK" & weekNumber, this_local_folder)
    set localBrandFolder to my getFolderPath(brandName, localWeekFolder)
    set localBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", localBrandFolder)
    set localBrandFolder_High_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_HR", localBrandFolder)
    set localBrandFolder_PSD to my getFolderPath(brandName & "_WK" & weekNumber & "_PSD", localBrandFolder)
    set this_Network_folder to "DCKGEN:Brands:Zoom:Brand - Zoom:Upload Photos:2013:"
    set networkWeekFolder to my getFolderPath("Week" & weekNumber, this_Network_folder)
    set networkBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", networkWeekFolder)
    --all files for website
    set website_images to "DCKGEN:Website_Images:"
    --set up names to destination folders and create over Network for FTP collection (based on a mounted drive)
    set this_ftp_folder to "Impulse:"
    set ftpWeekFolder to my getFolderPath("Week" & weekNumber, this_ftp_folder)
    set ftpBrandFolder to my getFolderPath(brandName, ftpWeekFolder)
    set ftpBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", ftpBrandFolder)
    set ftpBrandFolder_High_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_HR", ftpBrandFolder)
    --set theFolder to eachItem as string -- I think this is the line that could be causing the problem.
    --taking the folder identify which process it must follow.
    if brandName is equal to "BRAND" then
              tell application "Adobe Photoshop CS5.1"
      -- I remove the command activate, Photoshop stay in background
                        set ruler units of settings to pixel units
                        try
      open (alias thefile) showing dialogs never
                                  set origName to name of current document
                                  set myOptions to {class:JPEG save options, quality:12}
                                  set myPSDOptions to {class:Photoshop save options, embed color profile:true, save layers:true}
                                  tell current document
      --If the quick mask mode has been left on then delete the channel Quick Mask
                                            if (quick mask mode) then delete channel ¬
                                                      "Quick Mask"
      --If the Layer is incorrectly labeled with Original Layer it needs renaming to original Image
                                            if (exists layer "Original Layer") then ¬
                                                      tell layer "Original Layer" to set name to "Original Image"
      save in (localBrandFolder_PSD & origName) as Photoshop format with options myPSDOptions without copying
                                            (delete layer "Original Image") flatten
      resize image resolution 300 resample method none
      --sharpen image
      filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
      save in (localBrandFolder_High_Res & name) as JPEG with options myOptions without copying
      --get file path, return path of the JPEG file, work with (without copying)
      -- (with copying) : it return path of PSD file
                                            set newFile to file path --( return path of type alias )
      -- duplicate file using the Finder  -->on duplicateFile(..)
                                            my duplicateFile(newFile, {ftpBrandFolder_High_Res})
      --Prepare for Low RES by resetting image history
                                            set current history state to history state 3
      flatten
      resize image width 1348
      resize image resolution 300 resample method none
      filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
      --add save to lowResFolder with same options
      save in (localBrandFolder_Low_Res & name) as JPEG with options myOptions without copying
                                            set newFile to file path
                                            set newFile2 to newFile as string -- for testing end of name
                                            if newFile2 ends with "_2.jpg" or newFile2 ends with "_3.jpg" then -- exclude website_images
                                                      my duplicateFile(newFile, {networkBrandFolder_Low_Res, ftpBrandFolder_Low_Res})
                                            else
                                                      my duplicateFile(newFile, {networkBrandFolder_Low_Res, ftpBrandFolder_Low_Res, website_images})
                                            end if
      close saving no
                                  end tell
                        end try
              end tell
      --End BH
    end if
    --then the next etc.
    on duplicateFile(tFile, foldersPath) -- tFile is an alias, foldersPath is a list of folder
              tell application "Finder" to repeat with folderPath in foldersPath
                        with timeout of 200 seconds -- adjust it,  error if the copy  is longer that 200 seconds
      duplicate tFile to folder folderPath with replacing
                        end timeout
              end repeat
    end duplicateFile
    on getFolderPath(tName, folderPath)
              tell application "Finder" to tell folder folderPath
                        if not (exists folder tName) then
                                  return (make new folder at it with properties {name:tName}) as string
                        else
                                  return (folder tName) as string
                        end if
              end tell
    end getFolderPath

    Ok,  there is improvement, the script gets the path without error.
    Test this script in the editor., don't use your script.
    tell application "Adobe Photoshop CS5.1"
          set thefile to (file path of current document) --> get the file path (an alias)
    end tell
    set thefile to thefile as string
    tell application "Finder" to set TheName to (name of file thefile) --> the name
    set the1stLetter to the first character of TheName --> the first letter
    set the2ndLetter to the second character of TheName --> the first letter
    set brandInitial to {the1stLetter, the2ndLetter} as text
    if brandInitial is equal to "BH" then ¬
          set brandName to "BRAND"
    if brandInitial is equal to "AL" then ¬
          set brandName to "BRand"
    set weekNumber to ""
    display dialog "Please enter the week number:" default answer weekNumber
    set weekNumber to text returned of result
    try
          if weekNumber = "" then error
          set theWeekNumber to theWeekNumber as number
    on error
          set thePrefix to "INVALID ENTRY! "
    end try
    --Folder location Setup
    set this_local_folder to "Images:2012-2013"
    set localWeekFolder to my getFolderPath("WK" & weekNumber, this_local_folder)
    set localBrandFolder to my getFolderPath(brandName, localWeekFolder)
    set localBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", localBrandFolder)
    set localBrandFolder_High_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_HR", localBrandFolder)
    set localBrandFolder_PSD to my getFolderPath(brandName & "_WK" & weekNumber & "_PSD", localBrandFolder)
    set this_Network_folder to "DCKGEN:Brands:Zoom:Brand - Zoom:Upload Photos:2013:"
    set networkWeekFolder to my getFolderPath("Week" & weekNumber, this_Network_folder)
    set networkBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", networkWeekFolder)
    --all files for website
    set website_images to "DCKGEN:Website_Images:"
    --set up names to destination folders and create over Network for FTP collection (based on a mounted drive)
    set this_ftp_folder to "Impulse:"
    set ftpWeekFolder to my getFolderPath("Week" & weekNumber, this_ftp_folder)
    set ftpBrandFolder to my getFolderPath(brandName, ftpWeekFolder)
    set ftpBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", ftpBrandFolder)
    set ftpBrandFolder_High_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_HR", ftpBrandFolder)
    --set theFolder to eachItem as string -- I think this is the line that could be causing the problem.
    --taking the folder identify which process it must follow.
    if brandName is equal to "BRAND" then
          tell application "Adobe Photoshop CS2" --5.1"
                -- I remove the command activate, Photoshop stay in background
                set ruler units of settings to pixel units
                try
                      set myOptions to {class:JPEG save options, quality:12}
                      set myPSDOptions to {class:Photoshop save options, embed color profile:true, save layers:true}
                      tell (my getDocByPath(thefile))
                            set origName to name
                            --If the quick mask mode has been left on then delete the channel Quick Mask
                            if (quick mask mode) then delete channel ¬
                                  "Quick Mask"
                            --If the Layer is incorrectly labeled with Original Layer it needs renaming to original Image
                            if (exists layer "Original Layer") then ¬
                                  tell layer "Original Layer" to set name to "Original Image"
                            save in (localBrandFolder_PSD & origName) as Photoshop format with options myPSDOptions without copying
                            (delete layer "Original Image") flatten
                            resize image resolution 300 resample method none
                            --sharpen image
                            filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
                            save in (localBrandFolder_High_Res & name) as JPEG with options myOptions without copying
                            --get file path, return path of the JPEG file, work with (without copying)
                            -- (with copying) : it return path of PSD file
                            set newFile to file path --( return path of type alias )
                            -- duplicate file using the Finder  -->on duplicateFile(..)
                            my duplicateFile(newFile, {ftpBrandFolder_High_Res})
                            --Prepare for Low RES by resetting image history
                            set current history state to history state 3
                            flatten
                            resize image width 1348
                            resize image resolution 300 resample method none
                            filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
                            --add save to lowResFolder with same options
                            save in (localBrandFolder_Low_Res & name) as JPEG with options myOptions without copying
                       set newFile to file path --( return path of type alias )
                                                              set newFile2 to newFile as string -- for testing end of name
                            if newFile2 ends with "_2.jpg" or newFile2 ends with "_3.jpg" then -- exclude website_images
                                  my duplicateFile(newFile, {networkBrandFolder_Low_Res, ftpBrandFolder_Low_Res})
                            else
                                  my duplicateFile(newFile, {networkBrandFolder_Low_Res, ftpBrandFolder_Low_Res, website_images})
                            end if
                            close saving no
                      end tell
                end try
          end tell
          --End BH
    end if
    --then the next etc.
    on duplicateFile(tFile, foldersPath) -- tFile is an alias, foldersPath is a list of folder
          tell application "Finder" to repeat with folderPath in foldersPath
                with timeout of 200 seconds -- adjust it,  error if the copy  is longer that 200 seconds
                      duplicate tFile to folder folderPath with replacing
                end timeout
          end repeat
    end duplicateFile
    on getFolderPath(tName, folderPath)
          tell application "Finder" to tell folder folderPath
                if not (exists folder tName) then
                      return (make new folder at it with properties {name:tName}) as string
                else
                      return (folder tName) as string
                end if
          end tell
    end getFolderPath
    on getDocByPath(tFile)
          set f to tFile as alias
          tell application "Adobe Photoshop CS5.1"
                repeat with i in (get documents)
                      if file path of i is f then return contents of i --return the doc
                end repeat
          end tell
    end getDocByPath
    If there is an error, give me the selected text in the editor and the error
    Message was edited by: Jacques Rioux

Maybe you are looking for

  • Firefox will not open after recent update of all computer lab servers, Windows server 2008 R2, Multipoint 2011

    All 3 computer lab servers were recently updated and rebooted. Java was updated as well to 7u21. Now all 3 do not respond when Firefox icon is clicked, from any thin-client or remote desktop session/user. There is no popup error, just an hour-glass f

  • Branch to different page based on the selection of select list

    Hi All, I have to create an application in which i have a form containing a field with static lov's ... now i want that whenever i click on a save button it branches to some page based on the selected value of lov of that field... like if i select ma

  • What is the problem with business catalyst?

    Once in every one hundred attempts the business catalyst website will actually let me upload my site, if the service is not going to work let me know so I can find someone to host my site.

  • Response count reset

    I deleted test response rows from the response sheet. The response number count continues to add newer response counts to the number of counts before the deletion. How does one get the total counts to always show the current number of responses only,

  • ICal adding alert for 35791394 minutes after events

    Since I've upgraded to Mountain Lion, I'm now getting random Alerts set for 35791394 minutes after the event (between one to three alerts with the same number of minutes for each event). I'm syncing with iCloud to an iPhone 4S and iPad (3), both with