Save As PNG script

Hello,
I'd like some help with this script if possible
I wanted to save my open file to PNG format in the same location with the same name. I managed to do that with the scripts below.
This is a script I found on the forum:
#target photoshop
main();
function main(){
if(!documents.length) return;
try{
    var Path = decodeURI(activeDocument.path.parent);
    }catch(e){return;}
if(!Folder(Path).exists){
    alert(Path + " Does not exist!");
    return;
var Name = decodeURI(app.activeDocument.name).replace(/\.[^\.]+$/, '');
var saveFile = File(Path + "/" + Name + "_bump.png");
sfwPNG24(saveFile);
//Uncomment the line below if you want to close the document.
//app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
function sfwPNG24(saveFile){
var pngOpts = new ExportOptionsSaveForWeb;
pngOpts.format = SaveDocumentType.PNG
pngOpts.PNG8 = false;
pngOpts.transparency = true;
pngOpts.interlaced = false;
pngOpts.quality = 100;
activeDocument.exportDocument(new File(saveFile),ExportType.SAVEFORWEB,pngOpts);
And this is how I modified it (so that it saves the file in the same folder and doesn't add any suffix to the name; also changed to save as PNG instead of using save for web):
#target photoshop
main();
function main(){
if(!documents.length) return;
try{
    var Path = decodeURI(activeDocument.path);
    }catch(e){return;}
if(!Folder(Path).exists){
    alert(Path + " Does not exist!");
    return;
var Name = decodeURI(app.activeDocument.name).replace(/\.[^\.]+$/, '');
var saveFile = File(Path + "/" + Name + ".png");
sfwPNG24(saveFile);
//Uncomment the line below if you want to close the document.
//app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
function sfwPNG24(saveFile){
var pngOpts = new PNGSaveOptions;
pngOpts.compression = 9;
pngOpts.interlaced = false;
activeDocument.saveAs(saveFile, pngOpts, true, Extension.LOWERCASE);
[b]My problem:[/b]
I don't know what's happening when I try to save a file just created (never saved yet). I thought I would get the Alert message but it doesn't seem to be the case (maybe the alert message in the code is related to a different condition?)
I would like to have a default folder/path in the code so that, if the file hasn't been saved yet, it would be saved in the specified location.
If anyone could do it I would really appreciate it!
Thanks

did not get that far.... Your catch ended the script without a notice to you. Try the changed line below in the catch.
#target photoshop
main();
function main(){
if(!documents.length) return;
try{
    var Path = decodeURI(activeDocument.path);
    }catch(e){alert(e); return;}   //Let the user know about the problem
if(!Folder(Path).exists){
    alert(Path + " Does not exist!");
    return;
var Name = decodeURI(app.activeDocument.name).replace(/\.[^\.]+$/, '');
var saveFile = File(Path + "/" + Name + ".png");
sfwPNG24(saveFile);
//Uncomment the line below if you want to close the document.
//app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
function sfwPNG24(saveFile){
var pngOpts = new PNGSaveOptions;
pngOpts.compression = 9;
pngOpts.interlaced = false;
activeDocument.saveAs(saveFile, pngOpts, true, Extension.LOWERCASE);

Similar Messages

  • Save as png in different size and file name suffix.

    Maybe someone can help me on this Photoshop script. I am working on a psd file with few layers in Photoshop CS6. I would like to save it to the png format.
    Below is my workflow.
    1) Drag and drop 01.psd into Photoshop from A folder.
    2) Save 01.psd to 01.png into the A folder with different sizes and suffixes as shown below:
        - name: 01-xhires.png, size: 180x180
        - name: 01-hires.png, size: 90x90
        - name: 01.png, size: 45x45
    3) With png options: (I have no idea of some options below, but at least you know what I am lookng for. )
        - Compression: Smallest/Slow
        - Interlace: None
        - Transparency: True
        - Blur: 0:0
        - includeProfile = false
        - optimized = true
        - quality = 100
        - PNG8 = false
    4) Use lower case extension.
    5) Other options should be in default setting.
    The script should be able to:
    1) Overwrite the png files whenever the psd file has been updated and saved multiple times without prompting.
    2) Save the png files into the same folder as the source file without creating any subfolder.
    3) Not close the psd file, but still keeping it opens in the Photoshop without any changes.
    Please help, thank you very much.

    Goto Russell Browns web site download the Image Processor Pro script install it and use it to do what you want. However  the script will not overwrite files.   Overwriting file in an automated process is dangerous you could easily wipe out all you image if you make a mistake.  If you want to replace files create the new files in a new temp location then when you see the files are what you want. Move(cut) the files to the location you want replacing any files with the same name.
    Menu File>Automate>Image Processor Pro...
    source folder you psd files or open document which should stay open.  If you want the script to overwrite the output files you need to edit the script and remove the code that generate new name when output files exists. You may also need to change some save options.  I  would think you would want the profile you convert the image into stored in the png file,  Most of the otions you want can be set like same location no subfolders, 16bit  not interlace etc.

  • [SOLVED] GIMP is unable to save an PNG

    Hello,
    when I try to save an PNG within GIMP I get the following message:
    Saving '/home/alex/test.png' failed:
    Error while saving '/home/alex/test.png'. Could not save image.
    This is my commandline output:
    libpng error: known incorrect sRGB profile
    (file-png:5692): GLib-WARNING **: (gerror.c:390):g_error_new_valist: runtime check failed: (domain != 0)
    I reinstalled gimp and deleted my profile, but it didn't work.
    Does anyone have the same problem?
    Greetings
    Alex
    Last edited by oelfe (2013-05-28 13:08:55)

    I've been having the same problem for a while now, since the libpng update a couple of weeks ago.
    The day before the update, I was able to open a png, apply changes to compression, interlacing, etc., and export it to the same filename, overwriting the original. (Not the best workflow, I know)
    After the update, the export would just simply blank out (0KB) the original file and give the same error message.
    libpng error: known incorrect sRGB profile
    Here's an example of a png file that does not work - https://dl.dropboxusercontent.com/u/937 … rabian.png (107 KiB)
    My workaround was to convert the colour profile to Adobe RGB, open it in Gimp and convert it back(?) to sRGB.
    It doesn't seem to happen with every png though, just mostly the ones that I needed for actual work on a website (they are all from the same graphics guy).
    Last edited by adrianx (2013-05-27 21:22:42)

  • Screenshots save as png not pdf

    Screenshots (using shift+apple+4) save as png files instead of pdf.
    Png blows; they're fuzzy, unreadable and generally makes the handiness of screenshot a waste of time
    Someone suggested using the new GRAB feature but it's no better.
    Anyone know how to get a fast, crisp screenshot that is actually usable.
    I'm using CS3 Mac OSX v10.5.2
    BRING BACK SCREENSHOTS AS PDF....PLEASE!

    Linda;
    There's a great maintenance app called Onyx: http://www.macupdate.com/info.php/id/11582
    Once you install the software, open Onyx and under the Parameters menubar option, you will see on the right hand side an option called "Screen Capture Format". There you can select almost a dozen formats, one of them being PDF. Save the setting, close the application and you should be able to save all your screen capture shots in PDF format. This app is free. Cheers.

  • How do I save a PNG file with an alpha channel in Photoshop CS5?

    I have a PNG file created in Photoshop and I need to save it with an alpha channel for web purposes. I tried 'Save for Web & Devices' and selecting the Transparent box. Then, after saving, when I select 'get info' for the file it says there is no alpha channel. I'm stumped I can't seem to create an alpha channel from within Photoshop while I'm editing. Help!

    If you save as a 24bit png with transparent checked photoshop will save the png with transparent background (ie alpha transparency).  The png will appear transparent in a web browser.

  • Save as png and not psd setting?

    hi all,
    i am a long time user but have not spent enough consistent time to avoid some very bad habits. i thought i would take some time to see if i can fix some of these. apologies for the multiple posts today.
    anyway, i am sometimes in a situation where i need to save images as png at a certain size or something for a website (or just because i like to save out as png) and in many cases i am not using any optimizations in psd files.
    is there a way to have photoshop default to Save As png?
    right now i think i have to do a pulldown every time i want a png and when i am trying to do some kind of "batch processing" i am getting a bit of carpal tunnel with all my clickthroughs.
    also, any tips on where to read up on optimizations or built in batch functionality in photoshop would be great. i have been using Preview for the mac and some of the functionality there (convert all to png, resize all to XX etc, etc) is really, really great.
    TIA

    Ifanview will let you batch convert to PNG.  I've not actually used it in that respect, so can't say what options you get, but it usually does a stand out job of everything, and it's free.  Windows only AFAICT
    http://www.irfanview.com/

  • How do I save a "bash" script? (in attempt to fix one of my other problems)

    Here is my original problem:
    http://discussions.apple.com/thread.jspa?threadID=2195627&tstart=0
    I came across this that sounds like it will help my issue:
    http://www.macosxhints.com/article.php?story=20090316190817357
    However, what am I supposed to do with that code? Put it in the Terminal? Save it as an Apple Script? I also got the "lingon" program set up, all I need to do is figure how how to save this "bash" script and all set!
    Any ideas?
    -Scott

    This link might help as it shows how to create the plist using lingon:
    http://mymacfixes.blogspot.com/2009/06/how-do-i-stop-clicking-noise-from-hard.ht ml

  • How do i save as png?

    i can't save as png in photoshop cs6?

    Hello!
    Usually, you will work in RGB color mode, it allows you to use all the tools in Photoshop. CMYK is made when you output on a printing press. It is recommended to still work in RGB, but preview using the correct CMYK profile with view>proof colors. LAB separates the luminosity from the colors, it might be useful for some editing tasks. There are also grayscale, and a black and white mode.
    You will use 16 bits usually, when editing a Photo that comes from a RAW file. It can store more color information, so might be useful when doing big color shifts, but not all tools are available, and it cannot be exported in many formats.
    You will have more info about color modes in the help: http://help.adobe.com/en_US/photoshop/cs/using/WSfd1234e1c4b69f30ea53e41001031ab64-73eea.h tml
    and the bit mode: http://help.adobe.com/en_US/photoshop/cs/using/WSfd1234e1c4b69f30ea53e41001031ab64-7949a.h tml#WSfd1234e1c4b69f30ea53e41001031ab64-73daa

  • Why can't Photoshop CS4 open/save as PNG?

    I recently had to downgrade to CS4 and I've been having A LOT of issues with it. The biggest one being the inability to cooperate with PNG files.
    Online I've seen a few sollutions and I tried them all. I have PNG.8BI in my plug-ins folder in my Program Files, I ran it through my antivirus and it came back clean, I'm working in RBG color mode. Still nothing.
    Any other ideas?

    System: Windows 7
    Third party plug-ins: Not to my knowledge?
    Quicktime: I believe so.
    Save Method: I save as two copies, one in the default Photoshop format (PSD) and then I hit "save as" to save as PNG.

  • How can i save the Visual script in other drive

    Hello
    I'm new in this Forum and i'm just started working on Oracle functional tool.
    In Oracle functional tool , i can't save the visual script in the different path ...
    For example:
    I have installed this suite in drive C: and all the scripts are saved with in it..But i want to save the script in other drive whereas E: drive ...........
    How can i do.....
    Regards
    Deepika

    hi
    you can store the scripts in one of the workspace available in OATS.
    you wont get a chance to create the work space in other drive then in which OATS is installed.
    but if you need to make a back up of scripts then simply copy and paste it wherever you want them,and whenever you need to run the script then copy it and paste to one of the workspace of OATS.
    hope will help you
    regards
    Umesh
    Edited by: USoni on May 15, 2009 3:41 AM

  • How to save a PNG with layers in Photoshop.

    i am tryin to save a PNG with layers. Is it poosible ?
    What i found on the net is ....PNG is not meant for multiple layers. But still want to know if photoshop have its own proprietory standard for PNG.
    Thanks in advance.

    No, it is not possible.
    PNG doesn't support layers.
    A few apps stuff their own private data into PNG to hide layer data, but well, it's private undocumented data.

  • I have a Macbook Air (july 2012) with OS X 10.8.3  installed.  I have dvds with .vob files and have Quicktime Version 10.2 (603.12).  I can't play the DVDs.  Thereare some features of QT that I like, e.g. precise frame selection and save as .png file-help

    I have a Macbook Air (july 2012) with OS X 10.8.3  installed.  I have dvds with .vob files and have Quicktime Version 10.2 (603.12).  I can't play the DVDs.  There are some features of QT that I like, e.g. precise frame selection and save as .png file-help.  Am I missing some Apple software?  I thought QT for Mountain Lion could convert the .vob files - is there some setting that I have missed?
    Any suggestions that preserves a simple workflow much appreciated.

    arthur wrote:
    Perian is here: Perian - The swiss-army knife of QuickTime® components
    Perian will be retired soon.

  • Applescript Save As PNG without dialogs

    Does anyone know how to force the dialogs that sometimes appear when applescripting a save as PNG to never ever appear? The Photoshop CS4 Applescript ref doc doesn't mention any options about this.
    Thanks in advance,
    - Alex Zavatone

    Well, this is an old post, but maybe someone else needs the answer. Here's what worked for me:
    set destinationfolder to "MyHardDrive:MyFolder:"
    set currentFilepath to destinationfolder & "MyFileName.png"
    set saveOptions to {class:PNG save options, interlaced:false}
    save current document in file currentFilepath as PNG with options saveOptions appending no extension with copying
    Applescript won't tell you if the destination folder doesn't exist. Instead, the save dialog box will pop up.

  • Can't Open/Save as PNG

    This has never happened before. When I chose Save/Save As, I can't save as .PNG. Save for Web & Devices is disabled too. And, when I go to open a PNG, it says "Photoshop cannot open this because it is not the right kind of document". Why are PNGs suddenly not working?!

    No plugins (to my knowledge) have been installed.  Here is my Plug-Ins directory:
    Directory of c:\Program Files\Adobe\Adobe Photoshop CS4 (64 Bit)\Plug-ins
    11/11/2010  09:04 AM   
    11/11/2010 09:04 AM
    11/11/2010 09:04 AM
    3D Engines
    11/11/2010 09:04 AM
    ADM
    11/11/2010 09:04 AM
    Automate
    11/11/2010 09:04 AM
    Effects
    11/11/2010 09:04 AM
    Extensions
    11/11/2010 09:04 AM
    File Formats
    11/11/2010 09:04 AM
    Filters
    11/11/2010 09:04 AM
    Image Stacks
    11/11/2010 09:04 AM
    Import-Export
    11/11/2010 09:04 AM
    Measurements
    11/11/2010 09:04 AM
    Panels
    0 File(s) 0 bytes
    13 Dir(s) 48,829,767,680 bytes free
    And the 'File Formats' directory contains this:
    Directory of c:\Program Files\Adobe\Adobe Photoshop CS4 (64 Bit)\Plug-ins
    11/11/2010 09:04 AM
    11/11/2010 09:04 AM
    11/11/2010 09:04 AM
    3D Engines
    11/11/2010 09:04 AM
    ADM
    11/11/2010 09:04 AM
    Automate
    11/11/2010 09:04 AM
    Effects
    11/11/2010 09:04 AM
    Extensions
    11/11/2010 09:04 AM
    File Formats
    11/11/2010 09:04 AM
    Filters
    11/11/2010 09:04 AM
    Image Stacks
    11/11/2010 09:04 AM
    Import-Export
    11/11/2010 09:04 AM
    Measurements
    11/11/2010 09:04 AM
              Panels
                   0 File(s)              0 bytes
                  13 Dir(s)  48,829,767,680 bytes free
    So, all of my plugins were created at exactly the same time and are only those that come from the install CD.
    Steve

  • Save As PNG Adds Hard Transition to Gradient

    I have an image that I have created which includes a gradient with a soft transition from the light tone to the dark tone. When I save as PNG, the resulting image displays a hard transition to the gradient. How do I create a PNG image which maintains the subtlety of the gradient?

    Well, I found a setting in the Save for Web dialog where the gradient doesn't show as a smooth transition:
    But that's only in the Save for Web preview window -- using the browser preview button or saving the file shows a smooth transition....
    Ken

Maybe you are looking for

  • Limiting the Infoview export. CS 2008

    Is there any way to limit the export options in infoview? Restricting viewers to only export to PDF, Excel and CSV? I realise that you can block exporting completely from the security settings, but is there any way to just limit the file types that c

  • TOP LIMIT FOR "OR" SEARCH IN METADATA FILTER

    Would anyone know the top limit for an "OR" search in the Metadata Filter.  Like if you are searching with keywords, how many keywords can you choose in the same column?  Could it be 20?  50?  I have an iMac with Mountain Lion 10.8.4 and Lightroom 5.

  • Issue with "Retrieving Metadata from a Custom Lookup Implementation"

    Hello, I have a use case where i need to find meta data files from a custom location instead of CLASSPATH. I followed the following article in creating my "Custom XML Context Implementation" http://download.oracle.com/docs/cd/A97336_01/buslog.102/bc4

  • View problems

    I just downloaded CS6 (trial version), I opened a file played around a bit, closed file (did not save changes) I then attempt to reopen the file (or other ones) and the view has changed, I no longer see the wave display and can't figure out how to ge

  • ITunes Error on Windows 7?

    I have just received a Acer laptop for my birthday, which runs Windows 7. One of the first things I went to set up was iTunes, and I have been receiving an error message upon trying to sign in. This is what it says: We could not complete your iTunes