Saving JPG to PNG using Save for the Web

Morning
I came across Paul Riggott's script for saving PSD to PNG which I changed to JPG to PSD.
The only problem with this is that the file size in most cases is larger than the original.
Is there a way to do a save as for the web as well?
Here is the  original code:
#target photoshop
var imageFolder = Folder.selectDialog("Select top folder to process");
var folderList=[];
if (imageFolder != null)  {
processFolder(imageFolder);
folderList.unshift(imageFolder);
createPNGfromJPG(folderList);
function createPNGfromJPG(folderList){
for(var a in folderList){
  var fileList = folderList[a].getFiles ("*.jpg");
   for (var z in fileList){
    var file = fileList[z];
    open(file);
    var Name = fileList[z].name.replace(/\.[^\.]+$/, '');
    var saveFile = File(decodeURI(fileList[z].path+"/"+Name+".png"));
    SavePNG(saveFile);
    app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
function processFolder(folder) {
    var fileList = folder.getFiles()
     for (var i = 0; i < fileList.length; i++) {
        var file = fileList[i];
if (file instanceof Folder) {
  folderList.push(file); 
       processFolder(file);
function SavePNG(saveFile){
    pngSaveOptions = new PNGSaveOptions();
    pngSaveOptions.embedColorProfile = true;
    pngSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
    pngSaveOptions.matte = MatteType.NONE;
    pngSaveOptions.quality = 1;
pngSaveOptions.PNG8 = false;
    pngSaveOptions.transparency = true;
activeDocument.saveAs(saveFile, pngSaveOptions, true, Extension.LOWERCASE);
Any help or support to head me in the right direction would be appreciated.
Iain

This uses "Fitimage"....
#target photoshop
var imageFolder = Folder.selectDialog("Select top folder to process");
var folderList=[];
if (imageFolder != null)  {
processFolder(imageFolder);
folderList.unshift(imageFolder);
createPNGfromJPG(folderList);
function createPNGfromJPG(folderList){
for(var a in folderList){
  var fileList = folderList[a].getFiles ("*.jpg");
   for (var z in fileList){
    var file = fileList[z];
    open(file);
    var Name = fileList[z].name.replace(/\.[^\.]+$/, '');
    var saveFile = File(decodeURI(fileList[z].path+"/"+Name+".png"));
    FitImage(640,640); //Resizes  to the longest size
    //FitImage(128,128);
    savePNG8SFW(saveFile);
    app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
function processFolder(folder) {
    var fileList = folder.getFiles()
     for (var i = 0; i < fileList.length; i++) {
        var file = fileList[i];
if (file instanceof Folder) {
  folderList.push(file); 
       processFolder(file);
function savePNG8SFW(saveFile) {
    var desc8 = new ActionDescriptor();
        var desc9 = new ActionDescriptor();
        desc9.putEnumerated( charIDToTypeID('Op  '), charIDToTypeID('SWOp'), charIDToTypeID('OpSa') );
        desc9.putEnumerated( charIDToTypeID('Fmt '), charIDToTypeID('IRFm'), charIDToTypeID('PNG8') );
        desc9.putBoolean( charIDToTypeID('Intr'), false );
        desc9.putEnumerated( charIDToTypeID('RedA'), charIDToTypeID('IRRd'), charIDToTypeID('Sltv') );
        desc9.putBoolean( charIDToTypeID('RChT'), false );
        desc9.putBoolean( charIDToTypeID('RChV'), false );
        desc9.putBoolean( charIDToTypeID('AuRd'), false );
        desc9.putInteger( charIDToTypeID('NCol'), 256 ); //Number of colours.
        desc9.putEnumerated( charIDToTypeID('Dthr'), charIDToTypeID('IRDt'), charIDToTypeID('Dfsn') );
        desc9.putInteger( charIDToTypeID('DthA'), 100 );
        desc9.putInteger( charIDToTypeID('DChS'), 0 );
        desc9.putInteger( charIDToTypeID('DCUI'), 0 );
        desc9.putBoolean( charIDToTypeID('DChT'), false );
        desc9.putBoolean( charIDToTypeID('DChV'), false );
        desc9.putInteger( charIDToTypeID('WebS'), 0 );
        desc9.putEnumerated( charIDToTypeID('TDth'), charIDToTypeID('IRDt'), charIDToTypeID('None') );
        desc9.putInteger( charIDToTypeID('TDtA'), 100 );
        desc9.putBoolean( charIDToTypeID('Trns'), true );
        desc9.putBoolean( charIDToTypeID('Mtt '), false );
        desc9.putInteger( charIDToTypeID('MttR'), 255 );
        desc9.putInteger( charIDToTypeID('MttG'), 255 );
        desc9.putInteger( charIDToTypeID('MttB'), 255 );
        desc9.putBoolean( charIDToTypeID('SHTM'), false );
        desc9.putBoolean( charIDToTypeID('SImg'), true );
        desc9.putBoolean( charIDToTypeID('SSSO'), false );
            var list3 = new ActionList();
        desc9.putList( charIDToTypeID('SSLt'), list3 );
        desc9.putBoolean( charIDToTypeID('DIDr'), false );
        desc9.putPath( charIDToTypeID('In  '),File( saveFile) );
    desc8.putObject( charIDToTypeID('Usng'), stringIDToTypeID('SaveForWeb'), desc9 );
    executeAction( charIDToTypeID('Expr'), desc8, DialogModes.NO );
function FitImage( inWidth, inHeight ) {
if ( inWidth == undefined || inHeight == undefined ) {
  alert( "FitImage requires both Width & Height!");
  return;
var desc = new ActionDescriptor();
var unitPixels = charIDToTypeID( '#Pxl' );
desc.putUnitDouble( charIDToTypeID( 'Wdth' ), unitPixels, inWidth );
desc.putUnitDouble( charIDToTypeID( 'Hght' ), unitPixels, inHeight );
var runtimeEventID = stringIDToTypeID( "3caa3434-cb67-11d1-bc43-0060b0a13dc4" );
executeAction( runtimeEventID, desc, DialogModes.NO );

Similar Messages

  • How stop PS6 from removing the DPI value from an image when using "save for the web"?

    How stop PS6 from removing the DPI-value from an image when using "save for the web"?
    Example:
    - Open a tif image, that contains a dpi value (resolution).
    - Use the splice tool in PS6.
    - Export the slices with "Save for web", as gif-files.
    Then the dpi value is removed, the gif files has no dpi value (it's empty).
    How can we stop PS6 from removing the dpi value when using "save for web"?
    OR:
    When using the slice tool, how can we save the sliced pieces without PS removing the dpi value?

    you can make your art go a little bit over the bounds. or you can make sure your artboart and art edges align to pixels

  • CS3 crashes when using Save For The Web

    I recently installed CS4, but because of the slow performance problems with it, I've gone back to using CS3. I'm finding that every time I use CS3's Save For The Web function, CS3 crashes. I tried re-installing CS3 but the problem persists. Save For The Web on CS4 is OK.
    Anyone got any suggestions?

    Try resetting the SFW preferences.
    LenHewitt, "How to delete/reset Photoshop preferences" #1, 23 Jun 2004 12:05 am

  • Save for the web colors

    I was having trouble with image colors when I used 'save for the web' and I found a couple of solutions in tech notes regarding embedded color profiles but there is some thing I just don't understand.
    It says:
    "To ensure that colors are consistent in Photoshop, ImageReady and the Save for the Web dialog box, use an embedded color profile for display in each, or preview the image in Photoshop using the monitors RGB color space. Note that if you use an embedded color profile for display, colors may appear incorrectly if you view the image in an application that cannot read color profiles."
    Can somebody give me the lowdown on what exactly a color profile is (what it does, when you should embed one etc) and some examples of the kind of application that can't read them i.e. if I send the photos via e-mail can the profile be read? put them on a web page?
    Thanks for any illumination!
    j.

    A profile is a file that decribes to applications that can read them the color and tonal characteristics of a particular device. A profile can also be a mathematical description of a particular RGB or CMYK Lab color space. You've probably seen RGB working spaces in Photoshop referred to in terms like sRGB, Adobe RGB, ProPhoto RGB, etc. Any application that is color managed and can read and use profiles needs a minimum of two profile to to the job - a source profile and a destination profile. When you're looking at images on your computer monitor, the source is your RGB working space and the destination is your specific monitor. Photoshop uses both the working space profile and the monitor profile to display your image correctly. Most other applications in Windows do not read profile and have to assume either "Monitor RGB" or sRGB as the source for the file. If your file is not one of those, then false asumptioins are made and the image does not appear correctly. Some web browsers like Firefox 3 and Apple Safari do read profiles but not necessarily by default. You have to turn the option in FF. Some email readers are color managed, others not.
    Profiles can be and usually are embedded in the document when you save it. Unless you have a good reason for not embedding a profile, it's almost always a good idea. It adds 4K to the file size and will let someone down the line who is using a color managed application see the file how you intended it. You have no control over the others, but that's life online. Currentlyl the best strategy is convert files destined for the web to sRGB and embed the profiles. That might change in the future, but it's a good place to be right now.

  • Save for the web jagged fonts nightmare

    Hi
    Can't export anti-aliased smooth fonts using save for the web. The fonts are jagged.
    How can save for the web the same smooth quality that I see on the screen?
    Using Illustrator CS6 on Mac OS X 10.8.3
    Thanks.

    What is the size of the art and are you enlargening it in the browser using CSS or manually adjusting the size?
    In both cases I am using save for web. In the first instance I am exporting at 100% size, 200% size in the next instance. If you are resizing in CSS/manually, export from Illy at the desired size.
    Mike

  • When I upload my images to the web they are not as vibrant. I am using the Save for the Web feature.

    When I upload my images to the wed they are not as vibrant. I am using the Save for the web feature and my sRGB is checked. I dont know what else to do. HELP!

    We really need to see what you're seeing.
    Can you post links to before and after?

  • Save for the web seq

    I need to save for the web an animation of about 100 frames. The problem is the only way to do that seems to be saving the file as a gif but I need to keep them frame by frame. I was wondering if there is a way to save for the web the entire sequence and keep it as a jpg or png.
    Tx

    Simply render the animation to whatever format you find suitable using File --> Render Video, then convert the result using batch processing.
    Mylenium

  • Save for the web - Colors and Shift key

    Hi Everyone,
    With CS3 and Save for the Web, while saving a transparent image using GIF, you could use the Eyedropper Tool (i) and hold Shift key to select multiple colors at a time ON the image itself.
    Trying this in CS4 and it doesn't look like it's working. Anything changed? No I have to select the colors one at a time and this is painfull when you're on 256 different colors.
    Thanks!

    It would appear this functionality is no longer available. Shift clicking on the swatches is, though that doesnt help much here.

  • Save for the web keyboard command no longer works

    I have Photoshop CC on Mac OS 10.9.2.
    For some reason I can't figure out, Shift-Option-Command-S no longer opens "save for the web" dialog.  It does nothing at all.
    I can open the dialog from the menu itself, no problem; it's just the shortcut that has failed.
    The shortcut is still visible in the menu as the appropriate command, but it does not work.
    Any thoughts?

    I've found that once you start using custom shortcuts it can get you into trouble with some of the standard shortcuts.  My experience was using the Arrange Documents shortcuts from the Michael Ninness Power Shortcuts workshop, which overwrote Free Transform step & repeat.  Even though I had my custom shortcuts saved in my dual monitor workspace, it was overwriting the Essentuals workspace.
    If I reset Preferences I'd be OK again, but as soon as I switched to my dual monitor workspace, it would overwrite Essentuals again.  The fix was to reset Preferences again, and save a new version of Essentuals I called 'Essentuals 2' with keyboard shortcuts and menus checked.  That lets me use the dual monitor workspace for the most part, and switch to the Essentuals 2 workspace if I need to use FT Step & Repeat.

  • What processes are included in 'save for the web'

    When I save a photo using the Photoshop CS3 'save for the web' command, I resize the photo to, for example, 800 pixels on the long side. It comes back the correct size but sometimes the colors look different (a little red usually). Is this because I was editing the original photo in RGB? Should I convert to profile, sRGB before I save for the Web? Or does Photoshop do this automatically? OR, should I convert to sRGB and then do color adjustments for the web?
    Sorry, I'm a little confused about this...
    Thanks,
    Jody

    Photoshop is color managed. However, the web is not, so when you save to web, you lose your color management. If you want to see what is going to happen after SFW, you should set the color to sRGB, as you guessed.
    However, that will only set the way the color looks on your monitor. It could vary wildly on anyone else's monitor.

  • Save for the web

    When I "save for the web" in Photoshop, why does Image Ready open? This adds time to my workflow.

    I had 2 computer crashes - laptop and desktop at once. I only had Phostoshop CS but due to problems with Windows 8 etc. Adobe gave me a link to CS2 so I could still use Photoshop. On the desktop, I made some kind of setting where "save for web" stays in Photoshop, but on the laptop I evidently didn't make the same choice and "save for the web" goes through Image Ready. Any thoughts on that?
    Thanks for any all replys.

  • The save for the web function has stopped working in my copy of photoshop elements 12.  I get this message, " The operation could not be completed.  The system cannot find the path specified" Resetting preferences did not fix.

    The save for the web function has stopped working in my copy of photoshop elements 12.  I get this message, “ The operation could not be completed.  The system cannot find the path specified” Resetting preferences did not fix.

    my os is windows 7.  elements 12 worked fine for many months then save for the web stopped working

  • How do I save for the web at 200%?

    I was asked to save a file for a client, her instructions were to save for the web at 200% from illustrator.  I have no idea what this means, and would love some help!

    Jacob Bugge wrote:
    She may have worked on it in 1:1, which is convenient, and then realized that it should be larger. But it is only a guess.
    Hi Jacob....
    Going by the OP's post:
    "I was asked to save a file for a client, her instructions were to save for the web at 200% from illustrator." Just doesn't make sense – to me... If it needs to be larger, just scale up the master and save... why the "save for the web at 200% from Illustrator", is what foxes me. <shrug>
    Cheers!
    S

  • Save for the web and devices

    Hi,
    Im trying to save for the web and devices my work, but the work is not displaying at the save window.
    Any ideas?
    Many thanks
    http://www.flickr.com/photos/92610801@N03/

    Emil,
    I'm not sure if I can trust my eyes, but isn't that emblem on a Template Layer which is not recognised by Save for Web?

  • Elements 12 save for the web not working

    The save for the web function has stopped working in my copy of photoshop elements 12.  I get this message, “ The operation could not be completed.  The system cannot find the path specified” Resetting preferences did not fix.  Windows 7 64 bit is the os

    my os is windows 7.  elements 12 worked fine for many months then save for the web stopped working

Maybe you are looking for

  • Why doesn't Firefox see that I have Flash loaded on my computer?

    I have Flash 10.1.102.64 loaded on my computer and I can watch youtube videos on Windows IE. I just loaded Firefox 3.0.5 and when I try to watch a youtube video, it tells me I need to install Flash. Why doesn't it see Flash? Do I need to do something

  • Help! Urgent !- Mapping error - XML file format ?

    Hello, I can't load this xml file (by http adapter): <?xml version="1.0" encoding="UTF-8"?> <ZVG_GetOrderList_requ> <Orders>     <Order MessageType="GETORDERLIST" DecimalSeparator="POINT" Currency="EUR">         <CustomerCode type="AG">0330029839</Cu

  • 1080i w 1920 on FCE not supported? it seems to be working for me.

    I guess this is a question aimed at Tom. I have a Sony HDR-SR12E which is set to record in its highest quality which records 1920x1080 with a 16Mbit/s AVCHD stream. Final Cut Express seems to import it through log and transfer and if you check the pr

  • Menu Bar Flashes On and Off

    The right side of my menu bar flashes on and off every few seconds. It's there for a second or two then disappears for a second or two. Is there a way I can get this to stop? It did this when I first got my MBP a few weeks ago and simply opening an a

  • Feature Request: Ability to detect which tab user has selected in tab view

    'Twould be nice if the tab the user has selected could be restored when a dialog box with a tab view is re-presented. Or is there a way and I'm just brain-dead at the moment? Thx, R