A script for 'Save for Web' as .jpg
I found a script that saves the current selected document in Photoshop as .png on the desktop and use it all the time.
main() {} function
declare local variables
var doc = app.activeDocument;
var Nomdoc = app.activeDocument.name.slice (0, -4);
saveFile var = new File ("~/Desktop/" + nomdoc + ".png");
pngSaveOptions = new PNGSaveOptions();
pngSaveOptions.interlaced = false;
doc.saveAs (saveFile, pngSaveOptions, true, Extension.LOWERCASE);
}
main();
Now I really want a similar script to 'Save for Web' as .jpg files, without a color profile, on the desktop. Preferably a version to save it as a quality of 100% and the other to register as quality of 60%.
Any help would be greatly appreciated.
Here you are...
function main(){ if(!documents.length) return; var Name = app.activeDocument.name.replace(/\.[^\.]+$/, ''); var saveFile = File(Folder.desktop + "/" + Name + ".jpg"); if(saveFile.exists){ if(!confirm("Overwrite existing document?")) return; saveFile.remove(); } SaveForWeb(saveFile,100); //change to 60 for 60% } main(); function SaveForWeb(saveFile,jpegQuality) { var sfwOptions = new ExportOptionsSaveForWeb(); sfwOptions.format = SaveDocumentType.JPEG; sfwOptions.includeProfile = false; sfwOptions.interlaced = 0; sfwOptions.optimized = true; sfwOptions.quality = jpegQuality; //0-100 activeDocument.exportDocument(saveFile, ExportType.SAVEFORWEB, sfwOptions); }
Tags: Photoshop
Similar Questions
-
help - problem with save for web when jpg image is placed in the file
I have a jpg image file that I placed in my Illustrator 5 file to use as background and then created several vector buttons on the top. When I try to create an arboard around a single button and then save it to the web, it ignores the size of the artboard and shows the dimensions of all jpg. If I create the same file without the background jpg image, I am able to use work plans to record only a single button. Every time I place a jpg image in my Illustrator file and try to use work plans, work plans are ignored and the entire area of the jpg is saved. I am able to use the tool cuts to the economy, but I prefer using work plans. Anyone have any suggestions on how to get the work plans of work when a jpg is placed in the file? Thank you.
In save for Web, the tab Image... is Crop to the artboard checked?
-
Save for Web. 240 DPI.
Hello!
I work with Photoshop CS5, and I recently discovered that when I "Save for Web" in JPG format, Photoshop records my images in 240 ppi even if my images are 72 dpi.
Do you know what it is?
Thank you!
Chris.
Watch "Metadata" to save for Web. It can be defined at all and is recovering the file master print resolution.
The value of copyright or None to 72.
-
Layer Comps in JPG format save for Web
Hi all
I use the script of "Composition of layers to files" a lot to send a few designs to clients. And sometimes I need to send a large number of jpg files at the same time, that are created with "Layers to files", but they are around 300 k or more, and when I use safe for the web it reduces the file size a lot! But I don't want todo it all manually again of course.
So I was wondering, is there any script which saves your JPGs Comps of layer in a JPG file which is compressed with the backup of the Web technology levels?
Thanks in advance.
Jeroen
Locate these lines in the script
case jpegIndex: docRef.bitsPerChannel = BitsPerChannelType.EIGHT; var saveFile = new File(exportInfo.destination + "/" + fileNameBody + ".jpg"); jpgSaveOptions = new JPEGSaveOptions(); jpgSaveOptions.embedColorProfile = exportInfo.icc; jpgSaveOptions.quality = exportInfo.jpegQuality; docRef.saveAs(saveFile, jpgSaveOptions, true, Extension.LOWERCASE); break;
Replace with this
case jpegIndex: docRef.bitsPerChannel = BitsPerChannelType.EIGHT; var saveFile = new File(exportInfo.destination + "/" + fileNameBody + ".jpg"); var exportOpts = new ExportOptionsSaveForWeb( ); exportOpts.format = SaveDocumentType.JPEG exportOpts.includeProfile = exportInfo.icc; exportOpts.quality = Math.round( exportInfo.jpegQuality / 12 * 100 ) ); // exportInfo.jpegQuality is 0 to 12, SFW uses 0 to 100. this converts if ( saveFile.exists ) saveFile.remove( );// avoid file exists overwrite dialog docRef.exportDocument( saveFile, ExportType.SAVEFORWEB, exportOpts ); break;
And who should do it. Or you can set so that it uses scriptlistner for the SFW as the script done for PNG. If you want to keep certain metadata the jpeg, you can use scriptlistner in any case, as the DOM version does not export metadata.
-
How to change folder name by default when you use save for Web in java script?
Hello everyone, hope you can help me.
Photoshop has a folder name by default of images When you export using slices Save for Web . I need to change this folder name.
How to change folder name by default when you use save for Web in java script?
Thanks in advance!
JJMack Chuck Uebele Nicolas Ribot SuperMerlin
You can try with scriptlistener to record the code. Change to the last line of the NO to ALL dialog boxes, so that the dialog - if you wish. There are two places in the code to save the files: one where is actually saved the file, and the other where the default value is file. I have seen it changed something with it. So, you can simply use the first listing of a path in the code below.
#target photoshop var idExpr = charIDToTypeID( "Expr" ); var desc19 = new ActionDescriptor(); var idUsng = charIDToTypeID( "Usng" ); var desc20 = new ActionDescriptor(); var idOp = charIDToTypeID( "Op " ); var idSWOp = charIDToTypeID( "SWOp" ); var idOpSa = charIDToTypeID( "OpSa" ); desc20.putEnumerated( idOp, idSWOp, idOpSa ); var idDIDr = charIDToTypeID( "DIDr" ); desc20.putBoolean( idDIDr, true ); var idIn = charIDToTypeID( "In " ); desc20.putPath( idIn, new File( "C:\\Users\\csuebele\\Pictures\\LR shortcuts" ) );//Here's where it actually saves var idFmt = charIDToTypeID( "Fmt " ); var idIRFm = charIDToTypeID( "IRFm" ); var idPNtwofour = charIDToTypeID( "PN24" ); desc20.putEnumerated( idFmt, idIRFm, idPNtwofour ); var idIntr = charIDToTypeID( "Intr" ); desc20.putBoolean( idIntr, false ); var idTrns = charIDToTypeID( "Trns" ); desc20.putBoolean( idTrns, true ); var idMtt = charIDToTypeID( "Mtt " ); desc20.putBoolean( idMtt, true ); var idEICC = charIDToTypeID( "EICC" ); desc20.putBoolean( idEICC, false ); var idMttR = charIDToTypeID( "MttR" ); desc20.putInteger( idMttR, 255 ); var idMttG = charIDToTypeID( "MttG" ); desc20.putInteger( idMttG, 255 ); var idMttB = charIDToTypeID( "MttB" ); desc20.putInteger( idMttB, 255 ); var idSHTM = charIDToTypeID( "SHTM" ); desc20.putBoolean( idSHTM, false ); var idSImg = charIDToTypeID( "SImg" ); desc20.putBoolean( idSImg, true ); var idSWsl = charIDToTypeID( "SWsl" ); var idSTsl = charIDToTypeID( "STsl" ); var idSLAl = charIDToTypeID( "SLAl" ); desc20.putEnumerated( idSWsl, idSTsl, idSLAl ); var idSWch = charIDToTypeID( "SWch" ); var idSTch = charIDToTypeID( "STch" ); var idCHsR = charIDToTypeID( "CHsR" ); desc20.putEnumerated( idSWch, idSTch, idCHsR ); var idSWmd = charIDToTypeID( "SWmd" ); var idSTmd = charIDToTypeID( "STmd" ); var idMDCC = charIDToTypeID( "MDCC" ); desc20.putEnumerated( idSWmd, idSTmd, idMDCC ); var idohXH = charIDToTypeID( "ohXH" ); desc20.putBoolean( idohXH, false ); var idohIC = charIDToTypeID( "ohIC" ); desc20.putBoolean( idohIC, true ); var idohAA = charIDToTypeID( "ohAA" ); desc20.putBoolean( idohAA, true ); var idohQA = charIDToTypeID( "ohQA" ); desc20.putBoolean( idohQA, true ); var idohCA = charIDToTypeID( "ohCA" ); desc20.putBoolean( idohCA, false ); var idohIZ = charIDToTypeID( "ohIZ" ); desc20.putBoolean( idohIZ, true ); var idohTC = charIDToTypeID( "ohTC" ); var idSToc = charIDToTypeID( "SToc" ); var idOCzerothree = charIDToTypeID( "OC03" ); desc20.putEnumerated( idohTC, idSToc, idOCzerothree ); var idohAC = charIDToTypeID( "ohAC" ); var idSToc = charIDToTypeID( "SToc" ); var idOCzerothree = charIDToTypeID( "OC03" ); desc20.putEnumerated( idohAC, idSToc, idOCzerothree ); var idohIn = charIDToTypeID( "ohIn" ); desc20.putInteger( idohIn, -1 ); var idohLE = charIDToTypeID( "ohLE" ); var idSTle = charIDToTypeID( "STle" ); var idLEzerothree = charIDToTypeID( "LE03" ); desc20.putEnumerated( idohLE, idSTle, idLEzerothree ); var idohEn = charIDToTypeID( "ohEn" ); var idSTen = charIDToTypeID( "STen" ); var idENzerozero = charIDToTypeID( "EN00" ); desc20.putEnumerated( idohEn, idSTen, idENzerozero ); var idolCS = charIDToTypeID( "olCS" ); desc20.putBoolean( idolCS, false ); var idolEC = charIDToTypeID( "olEC" ); var idSTst = charIDToTypeID( "STst" ); var idSTzerozero = charIDToTypeID( "ST00" ); desc20.putEnumerated( idolEC, idSTst, idSTzerozero ); var idolWH = charIDToTypeID( "olWH" ); var idSTwh = charIDToTypeID( "STwh" ); var idWHzeroone = charIDToTypeID( "WH01" ); desc20.putEnumerated( idolWH, idSTwh, idWHzeroone ); var idolSV = charIDToTypeID( "olSV" ); var idSTsp = charIDToTypeID( "STsp" ); var idSPzerofour = charIDToTypeID( "SP04" ); desc20.putEnumerated( idolSV, idSTsp, idSPzerofour ); var idolSH = charIDToTypeID( "olSH" ); var idSTsp = charIDToTypeID( "STsp" ); var idSPzerofour = charIDToTypeID( "SP04" ); desc20.putEnumerated( idolSH, idSTsp, idSPzerofour ); var idolNC = charIDToTypeID( "olNC" ); var list4 = new ActionList(); var desc21 = new ActionDescriptor(); var idncTp = charIDToTypeID( "ncTp" ); var idSTnc = charIDToTypeID( "STnc" ); var idNCzerozero = charIDToTypeID( "NC00" ); desc21.putEnumerated( idncTp, idSTnc, idNCzerozero ); var idSCnc = charIDToTypeID( "SCnc" ); list4.putObject( idSCnc, desc21 ); var desc22 = new ActionDescriptor(); var idncTp = charIDToTypeID( "ncTp" ); var idSTnc = charIDToTypeID( "STnc" ); var idNConenine = charIDToTypeID( "NC19" ); desc22.putEnumerated( idncTp, idSTnc, idNConenine ); var idSCnc = charIDToTypeID( "SCnc" ); list4.putObject( idSCnc, desc22 ); var desc23 = new ActionDescriptor(); var idncTp = charIDToTypeID( "ncTp" ); var idSTnc = charIDToTypeID( "STnc" ); var idNCtwoeight = charIDToTypeID( "NC28" ); desc23.putEnumerated( idncTp, idSTnc, idNCtwoeight ); var idSCnc = charIDToTypeID( "SCnc" ); list4.putObject( idSCnc, desc23 ); var desc24 = new ActionDescriptor(); var idncTp = charIDToTypeID( "ncTp" ); var idSTnc = charIDToTypeID( "STnc" ); var idNCtwofour = charIDToTypeID( "NC24" ); desc24.putEnumerated( idncTp, idSTnc, idNCtwofour ); var idSCnc = charIDToTypeID( "SCnc" ); list4.putObject( idSCnc, desc24 ); var desc25 = new ActionDescriptor(); var idncTp = charIDToTypeID( "ncTp" ); var idSTnc = charIDToTypeID( "STnc" ); var idNCtwofour = charIDToTypeID( "NC24" ); desc25.putEnumerated( idncTp, idSTnc, idNCtwofour ); var idSCnc = charIDToTypeID( "SCnc" ); list4.putObject( idSCnc, desc25 ); var desc26 = new ActionDescriptor(); var idncTp = charIDToTypeID( "ncTp" ); var idSTnc = charIDToTypeID( "STnc" ); var idNCtwofour = charIDToTypeID( "NC24" ); desc26.putEnumerated( idncTp, idSTnc, idNCtwofour ); var idSCnc = charIDToTypeID( "SCnc" ); list4.putObject( idSCnc, desc26 ); desc20.putList( idolNC, list4 ); var idobIA = charIDToTypeID( "obIA" ); desc20.putBoolean( idobIA, false ); var idobIP = charIDToTypeID( "obIP" ); desc20.putString( idobIP, """""" ); var idobCS = charIDToTypeID( "obCS" ); var idSTcs = charIDToTypeID( "STcs" ); var idCSzeroone = charIDToTypeID( "CS01" ); desc20.putEnumerated( idobCS, idSTcs, idCSzeroone ); var idovNC = charIDToTypeID( "ovNC" ); var list5 = new ActionList(); var desc27 = new ActionDescriptor(); var idncTp = charIDToTypeID( "ncTp" ); var idSTnc = charIDToTypeID( "STnc" ); var idNCzeroone = charIDToTypeID( "NC01" ); desc27.putEnumerated( idncTp, idSTnc, idNCzeroone ); var idSCnc = charIDToTypeID( "SCnc" ); list5.putObject( idSCnc, desc27 ); var desc28 = new ActionDescriptor(); var idncTp = charIDToTypeID( "ncTp" ); var idSTnc = charIDToTypeID( "STnc" ); var idNCtwozero = charIDToTypeID( "NC20" ); desc28.putEnumerated( idncTp, idSTnc, idNCtwozero ); var idSCnc = charIDToTypeID( "SCnc" ); list5.putObject( idSCnc, desc28 ); var desc29 = new ActionDescriptor(); var idncTp = charIDToTypeID( "ncTp" ); var idSTnc = charIDToTypeID( "STnc" ); var idNCzerotwo = charIDToTypeID( "NC02" ); desc29.putEnumerated( idncTp, idSTnc, idNCzerotwo ); var idSCnc = charIDToTypeID( "SCnc" ); list5.putObject( idSCnc, desc29 ); var desc30 = new ActionDescriptor(); var idncTp = charIDToTypeID( "ncTp" ); var idSTnc = charIDToTypeID( "STnc" ); var idNConenine = charIDToTypeID( "NC19" ); desc30.putEnumerated( idncTp, idSTnc, idNConenine ); var idSCnc = charIDToTypeID( "SCnc" ); list5.putObject( idSCnc, desc30 ); var desc31 = new ActionDescriptor(); var idncTp = charIDToTypeID( "ncTp" ); var idSTnc = charIDToTypeID( "STnc" ); var idNCzerosix = charIDToTypeID( "NC06" ); desc31.putEnumerated( idncTp, idSTnc, idNCzerosix ); var idSCnc = charIDToTypeID( "SCnc" ); list5.putObject( idSCnc, desc31 ); var desc32 = new ActionDescriptor(); var idncTp = charIDToTypeID( "ncTp" ); var idSTnc = charIDToTypeID( "STnc" ); var idNCtwofour = charIDToTypeID( "NC24" ); desc32.putEnumerated( idncTp, idSTnc, idNCtwofour ); var idSCnc = charIDToTypeID( "SCnc" ); list5.putObject( idSCnc, desc32 ); var desc33 = new ActionDescriptor(); var idncTp = charIDToTypeID( "ncTp" ); var idSTnc = charIDToTypeID( "STnc" ); var idNCtwofour = charIDToTypeID( "NC24" ); desc33.putEnumerated( idncTp, idSTnc, idNCtwofour ); var idSCnc = charIDToTypeID( "SCnc" ); list5.putObject( idSCnc, desc33 ); var desc34 = new ActionDescriptor(); var idncTp = charIDToTypeID( "ncTp" ); var idSTnc = charIDToTypeID( "STnc" ); var idNCtwofour = charIDToTypeID( "NC24" ); desc34.putEnumerated( idncTp, idSTnc, idNCtwofour ); var idSCnc = charIDToTypeID( "SCnc" ); list5.putObject( idSCnc, desc34 ); var desc35 = new ActionDescriptor(); var idncTp = charIDToTypeID( "ncTp" ); var idSTnc = charIDToTypeID( "STnc" ); var idNCtwotwo = charIDToTypeID( "NC22" ); desc35.putEnumerated( idncTp, idSTnc, idNCtwotwo ); var idSCnc = charIDToTypeID( "SCnc" ); list5.putObject( idSCnc, desc35 ); desc20.putList( idovNC, list5 ); var idovCM = charIDToTypeID( "ovCM" ); desc20.putBoolean( idovCM, false ); var idovCW = charIDToTypeID( "ovCW" ); desc20.putBoolean( idovCW, true ); var idovCU = charIDToTypeID( "ovCU" ); desc20.putBoolean( idovCU, true ); var idovSF = charIDToTypeID( "ovSF" ); desc20.putBoolean( idovSF, true ); var idovCB = charIDToTypeID( "ovCB" ); desc20.putBoolean( idovCB, true ); var idovSN = charIDToTypeID( "ovSN" ); desc20.putString( idovSN, """c:\photos""" );//Here's where the default folder is suppose to go. var idSaveForWeb = stringIDToTypeID( "SaveForWeb" ); desc19.putObject( idUsng, idSaveForWeb, desc20 ); executeAction( idExpr, desc19, DialogModes.ALL );
-
Need a script to generate sequential numbers for png save for web
Can someone please help save me in png save for web, names with sequential numbers as a prefix or suffix, while that in the process of automation batch
Is there a script?
Although it is probably overkill for what you need, Image Processor Pro manages this thing of the kind.
PS-scripts-browse/Image Processor Pro / Beta v3_2 on SourceForge.net
Take everything that is the last beta.
X
-
Problem with save for Web in Action
We do hundreds of images to our fine print main client. As part of the work, they want to the final image through save for Web registered as file a .jpg and .png to 1000 pixels wide.
The problem is, if you try to create an action for this, the size of the action records is a percentage and not a width in pixels. It is therefore impossible (so it seems) to record an action that sets the scale as a sizing with a fixed output of 1000 pixels wide. Since images vary in size and he insists on registration of the size as a percentage, you can not create an action that will work.
I tried to see if there is a way to change the action to change the output of a width in pixels, but didn't see how to do it. Is it still possible? We would save TONS of not having to manually open each image twice as much work and savings for each format.
Yes, there is a bug with this script.
The bug got into CS5 and was not attached to the CS6.
You can download the fixed script here...
-
Hi Forum
With the new update to export to save the web, I was wondering if anyone knows how to save the settings so that it is not automatically set to save as a GIF file, I like it to save in JPEG format all the time, any help would be greatly appreciated.
That's what I've provided to solve it,
I created a SCRIPT to save for Web command, set my settings to JPEG
and added a 'shortcut' to my Action for quick access
Hope this will help until it is fixed in future updates.
-
CS6 Question w/save for Web, do not use the Document DPI
I'm creating an Action where I take a document large PSD format (photography) and change the size of the image at 72 DPI and 1000 pixels on the long side of the photo. If the action flattens the image and then modified the image 72 DPI and 1000 pixels on the longest side. The Action then runs thru photo save for Web, while this does not reduce the file size and it creates the appropriate pixel dimensions, it does not recognize the change DPI and delivers the original document of 360 DPI.
I can take the same image, resize the image at 72 DPI and 1000 pixels on the longest side and then "save under" a jpg file. This always creates a 72 DPI jpg. What gives save for Web?
The PPI figure is stored as metadata. If the Metadata in SFW parameter is set to 'All' the 360 PPI is preserved.
So any setting less than 'All' will throw the Print metadata and set a default value of 72 DPI.
Gene
-
Hello world.
I've updated to the latest version, and now, whenever I press "Save for Web", it gives me GIF.
How to cancel it? I want to save my last option (as if it was in previous versions). This GIF drive me cleen!
I created a SCRIPT to save for Web command, set my settings to JPEG
and added a shortcut to my Action for quick access
It worked perfectly
Hope it will Help
-
Save for Web is now up to GIF on each record?
Up to the latest version, the save for Web dialog box remember the type of file that you saved last as. Now, every time I open it... interrupt my workflow, it is up to the pretty spectacular GIF format that I use save for Web several times a day to record versions of the wired models.
Anyone else seeing this?
I do not see any place to set a default file type save for web.
Am I missing something?
I don't understand the reasoning behind this change. People generally use the same type of file when they export and RARELY is it GIF more. But even if the GIF was still popular, I would say it is much more common that you export the same type of file most of the time that put permanently.
Gah
(edited for typo)
I created a SCRIPT to save for Web command, set my settings to JPEG
and added a shortcut to my Action for quick access
It worked perfectly
Hope it will Help
-
I can not save for web in photoshop that cc says 'cannot complete this operation.
Just bought CC Photoshop and Lightroom CC. Photoshop, I cannot save for web and Lightroom at opening, States that Lightroom doesn't have permissions to write to certain folders to standard user. etc. I followed other advice in other forums, but still problems with both. Help, please!
Hi Jennlu11,
This is the official page of Adobe about the permissions of LR. In particular, the #3 solution has a script that allows you to repair permissions automatically if nothing else works.
Solutions to the Lightroom error problems of user permissions
Mike
-
Animated GIF >; save for Web (legacy) ends too large
I created an animated GIF on a work plan which is 768 x 90, but the Dimensions of the Document indicate 1456 x 416 (a lot of the images fly in and "shrink").
When I export as a PNG or JPG image it only exports the work plan, so that it remains the size I want to (768 x 90); but when I export > save for Web (Legacy) which is the only way to create an animated GIF AFAIK, it is exported to 1456 x 416.
How can I get to the exit of the GIF animated image to the size of the artboard? Thank you.
New export > export as a workflow is not animated gifs, currently exporting. It's probably something that will be supported in the future, however.
To export a gif animated image in PS using Photoshop CC 2015, do not work plans. Please use export > save for Web (legacy) option without work plans. The backup of the Web feature levels is not support work plans and probably never will be. Instead, we will continue to improve and to the export as a workflow.
-
I save a series of images for use on the Web site using the background color #c54a90. This is achieved my having my background layer filled with color and other images then placing on the top (see screengrab below). However, when I export the image for the web or export in JPG the hexadecimal color replaces #c64a90. Does anyone know why this is? I have my RGB working space set to sRGB and the color profile is also sRGB. When I save it for the web, I tried embedding the profile and do not incorporate the profile and I get the same result. I also tried with and without conversion to sRGB in the Save Panel for web and has also no effect. Can anyone help? He drives me crazy!
Here is an example jpg resulting.
Here is the version stratified showing the original hex color:
Compression JPEG WILL change your image color values, because it is a lossy compression format.
Visually, the colors will be close, but the exact values are supposed to change.
-
Save for Web file of Preview size is not accurate (300%)
I have a jpg 106 k.
In save for Web the size of preview shows to 11.85 k (quality 15).
Save the file. The size is 49 k - 300% more that the survey estimate.
(why?)
Which version of photoshop and the operating system are you using?
Looks like you have some metadata save with the file.
Where it says set metadata from scratch and see if that makes a difference.
Maybe you are looking for
-
Firefox 4 will be not updated to firefox 5
Hello I have 2 PC, both very similar set up.1 PC: that I am on, is the version 4.0.12nd PC: version 5.0Both have gotten to these steps via update through the "Check for Updates". Problem is 1 PC says it is up-to-date. So I'm confused and I was wonder
-
Regular expression for middle of string
Little background. I get the data (only the numbers) and text (can contain numbers) series. Since I don't know which I get and when it starts / ends, I do the sender send 'textSTART ###textSTOP' where ' # ' is what I want to extract. # can contain te
-
Hello I create a socket to my servlet to send the mail from my application (I need more control of my server) but for that I need the host, the user name, the password and the port of the user's e-mail account. Is it possible to retrieve this informa
-
Highlitable/unavailable Windows Photo Gallery tools?
Some tools in 'Settings' not highlighted (crop, red eye, retouch, straighten, reduction, colour, exposure & effects of noise when you open a .bmp image?
-
Error: Name of the Member has invalid characters, is too long or is empty
Hello!I am trying to deploy the HFM application in 11.1.1.3 and receive the errors below.Error: Name of the Member has invalid characters, is too long or is emptyError: No child is specified for the parent/child pairRealAny idea?Thanks in advance!San