• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Save For Web Image Size settings

New Here ,
May 12, 2016 May 12, 2016

Copy link to clipboard

Copied

Hi folks,

This is currently driving me mad.

Is there any way of accessing the Image options in Save For Web via script????

I need to be able to manipulate the following:

Image Size Percent:

Image Size Quality:

I've looked everywhere, trawled through the api and can't find any information.

My workaround is to use an action to resize the image and then run a script to ExportOptionsSaveForWeb() but this always results in a larger file size and, for some unknown reason, an image that is 1px up and to the left.

I do not get this issue when running this same process manually with exactly the same settings.

Any help?

TOPICS
Actions and scripting

Views

3.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
May 12, 2016 May 12, 2016

Copy link to clipboard

Copied

File size is not predictable. How well an image will compress depends on how much fine detail you have for an image   An image x pixels wide by y pixels high  saves as a high quality jpeg image can be as small as 200KB to as large as 7MB depends on image content.

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 12, 2016 May 12, 2016

Copy link to clipboard

Copied

Hi JJMack,

For the images I'm working on we have a master image created from a manual export.

I localise these images x 50. If I export each 1x version manually it is always around the same size in bytes.

Trying to script this exact process I always end up with an image that's a large files size and has a slight deviation in layout.

The only thing that changes from using scripts and using the manual process is changing the image size to 50% in the Save For Web window and that appears to be messing things up hence why I want to know if this can be accessed using javascript to run some tests and hopefully export images of the same quality, layout and file size.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 12, 2016 May 12, 2016

Copy link to clipboard

Copied

nickc97991501 wrote:

I localise these images x 50. If I export each 1x version manually it is always around the same size in bytes.???

Trying to script this exact process I always end up with an image that's a large files size and has a slight deviation in layout.

This sound like your interpolating images to different canvas sizes.  That your not trying to reduce files size using a lower quality setting and retain the image size.

Describe your exact manual process step by step and post your script.

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 12, 2016 May 12, 2016

Copy link to clipboard

Copied

Manual process.

  1. Open 2x image
  2. SaveForWeb
  3. Change Image Size to 50%
  4. Save.

Current Scripted process:

  1. Run 1x Script

var filePath = activeDocument.fullName.fsName

var saved = false;

var curDoc = activeDocument;

var heightOK = false;

var widthOK = false;

if (actionExists("50%", "Apple_PSD") && actionExists("Make_Edit", "Prep")) {

  if ( isEven(curDoc.height) ){

       heightOK = true;

  } else {

       heightOK = false;

  }

  if ( isEven(curDoc.width) ){

       widthOK = true;

  } else {

       widthOK = false;

  }

  if ( heightOK && widthOK ) {

  doAction("Make_Edit", "Prep");

  doAction("50%", "Apple_PSD"); 'This action is just, image Width and Height = 50%, Interpolation = Bicubic

  var newPath = filePath.split("_2x");

  newPath = newPath[0] + newPath[1];

  var fileType = filePath.split("_2x.");

  fileType = fileType[1];

  switch(fileType){

  case "jpg":

  saveFile = new File(newPath);

  saveOptions = new ExportOptionsSaveForWeb();

  saveOptions.format = SaveDocumentType.JPEG

  saveOptions.optimized = false;

  saveOptions.quality = 78;

  activeDocument.exportDocument(saveFile, ExportType.SAVEFORWEB, saveOptions);

  saved = true;

  break;

  case "gif":

  saveFile = new File(newPath);

  saveOptions = new GIFSaveOptions();

  saveOptions.colors = 256;

  saveOptions.dither = Dither.NONE;

  saveOptions.matte = MatteType.WHITE;

  saveOptions.preserveExactColors = 0;

  saveOptions.transparency = 1;

  saveOptions.interlaced = 0;

  break;

  case "png":

  saveFile = new File(newPath);

  saveOptions = new ExportOptionsSaveForWeb();

  saveOptions.format = SaveDocumentType.PNG;

  saveOptions.PNG8 = false;

  saveOptions.quality = 100;

  activeDocument.exportDocument(saveFile, ExportType.SAVEFORWEB, saveOptions);

  saved = true;

  break;

  }

  if (saved == false) { curDoc.saveAs(saveFile, saveOptions, true, Extension.LOWERCASE); }

  activeDocument.close(SaveOptions.DONOTSAVECHANGES);

  } else {

  if ( heightOK == false ){

  alert("Height of image is incorrect - must be an even number");

  }

  if ( widthOK == false  ){

  alert("Width of image is incorrect - must be an even number");

  }

  }

}

function actionExists( actionName, setName ){

   var res = false;

   try{

      var ref = new ActionReference();

      ref.putName( charIDToTypeID( 'Actn' ), actionName );

      ref.putName( charIDToTypeID( "ASet" ), setName );

      executeActionGet( ref );

      res = true;

   }catch(e){}

   return res;

}

function isEven(value) {

  if (value%2 == 0)

  return true;

  else

  return false;

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 12, 2016 May 12, 2016

Copy link to clipboard

Copied

nickc97991501 wrote:

Manual process.

  1. Open 2x image          Is 2x a process or is the image  2x the size you need
  2. SaveForWeb             If 2x is not a process why are you saving what you just opened?
  3. Change Image Size to 50%  Resampling or changing image's Resolution?
  4. Save.

Current Scripted process:

  1. Run 1x Script

The two actions save them as text files and post. IMO you are also asking for problems in the future using two outside actions which are in different action sets.

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 12, 2016 May 12, 2016

Copy link to clipboard

Copied

Hi JJMack,

That's the whole point. I do not want to be using actions for anything. They're legacy and they are causing the issues.

Hence why I asked if there was any way of utilising the options in the Save for web dialogue.

Specifically:

Image Size Percent:

Image Size Quality:

If it can't be done then that's incredibly frustrating and I have no idea why Adobe wouldn't enable that.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 12, 2016 May 12, 2016

Copy link to clipboard

Copied

nickc97991501 wrote:

Hi JJMack,

Save for web dialogue.

Image Size Percent:

Image Size Quality:

From my point of View (IMO)

"Save for Web" You use save for web to strip metadata and creating animated gif  (yes it can do other things that other features can also do so what.)

Image Resize can be done to ways  changing resolution and by interpolation.   Changing resolution is only valid for printing for web display devices do not use image files resolution setting. They display images at the resolution they are run at.  The number of pixels you have for images is what is important for the web.  You normally have to interpolate images for the web.

Anytime you interpolate an image you loose some image quality.   When you downsize you through away detail you have for your image. When you upsize you creating details for the image you do not have.  After the resize you have a totally new image not a single pixel you had for the original image exist.

How much quality you loose depends on many things.  The quality of the original pixels,  The size change percent, and the image content.  In a general case resize you need to use an interpolation method that works well on all images not a particular type of image.

Jpeg format uses  lossy compression which means when you decode a jpeg image you do not have the same image the you compressed.  Sill with my old eyes I can not see any difference between a quality 10 jpeg image and a quality 12 jpeg image and the quality 10 file size is much smaller the the quality 12 file size.

I do not understand why you require the large image  width and height to have a even number of pixels.    I would think you would be More interested in a particular size image for the web. Ones that would be fitted to some size pixel area.   Also if you use save as instead of Save for web you should convert image to the sRGB color space.

Resize is easy in scripting.

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 12, 2016 May 12, 2016

Copy link to clipboard

Copied

I appreciate the reply but I think it's veering off dramatically from what I'm asking. I know all about compression, JPEG etc.

This is for a very specific website that requires very specific standards and requires even numbers for the 2x version.

So I need to know one thing.

SaveForWeb:

Image Size Percent:

Image Size Quality:

Can these be accessed / manipulated via script?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 12, 2016 May 12, 2016

Copy link to clipboard

Copied

yes

I think you may want to download and install from the Web the Image Processor Pro Plug-in Script.  I believe it may be all you need to do what  you want to do...

http://www.adobe.com/content/dam/Adobe/en/devnet/photoshop/pdfs/photoshop-cc-javascript-ref.pdf

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 13, 2016 May 13, 2016

Copy link to clipboard

Copied

Actually no, Processor pro we've had for ages and it doesn't work with our process.

So that'd be a no for my question.

Thanks for the help.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 13, 2016 May 13, 2016

Copy link to clipboard

Copied

nickc97991501 wrote:

This is for a very specific website that requires very specific standards and requires even numbers for the 2x version.

You wrote the above an I believe every word.  However only you know the very specific standards.   That make it very hard for us to help you.  From seeing you script and reading what you wrote. I find it hard to believe with a few simple actions and the Image processor Pro Script that you can not do what you want.  If you have looked at Adobe documentation on Photoshop Java scripting you should have known all the script question you asked can be done.  I can understand you needing help but you seem not to want any.

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 13, 2016 May 13, 2016

Copy link to clipboard

Copied

No, I have looked through all the documentation for Photoshop scripting and the SaveForWeb function. It's not there.

It doesn't list the image size anywhere in that section. Now, maybe I thought I was missing something or maybe someone else had come across this same issue and worked it out. Maybe there is a hack or more probably this can't be done.

It's a simple question relating to two specific parts of the save for web function.

Can you script a 50% image reduction and set the Quality to bicubic as part of the ExportSettings SaveForWeb?

That is the help I need.

Cheers.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
May 13, 2016 May 13, 2016

Copy link to clipboard

Copied

Can you script a 50% image reduction and set the Quality to bicubic as part of the ExportSettings SaveForWeb

If you mean you want the image to be half the file size of the original, the only way to do this is by saving at different quality levels until you reach the desired file size. It's slow but it works and code for this has been posted on this forum a few times.

If you want to scale the dimensions of the document via SfW, this is possible using ScriptingListener code.

I don't know of anyway of specifying the interpolation for SfW.

You can write a script to do dimension scaling with the interpolation method that you want and then use SfW for saving.

Image Processor Pro can handle dimension scaling (percentage) and interpolation, then save via SfW. It still doesn't handle a targeted file size.

I don't know enough about your workflow to make any suggestions on how to get IPP integrated. Send me a message if you want to discuss this. I'm somewhat familiar with IPP.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 13, 2016 May 13, 2016

Copy link to clipboard

Copied

I can not help then I posted Adobe Java scripting manual clearly Save for Web is supported. IMO you can just as easy use save as but than I do not know your standards.

You can do the image resize the percentages you want and the interpolation you want and then use save for web why must the resize be done as part of Save for Web what are your standards anyway?

Capture.jpg

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
May 13, 2016 May 13, 2016

Copy link to clipboard

Copied

The question is, what is in the saveforweb method which could not be done with a script just using the "regular" save as JPEG method. As the components for such a script are fully documented, it should not really be such a big deal to create it.

Opinions?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 13, 2016 May 13, 2016

Copy link to clipboard

Copied

nickc97991501 wrote:

This is for a very specific website that requires very specific standards and requires even numbers for the 2x version.

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
May 13, 2016 May 13, 2016

Copy link to clipboard

Copied

OK, even number of pixels can be set when scaling.

It might be a good idea, if the OP could (if he is allowed to) give a bit more insight into those "very specific standards"…

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
May 12, 2016 May 12, 2016

Copy link to clipboard

Copied

You might carefully compare some of the save options with the Photoshop JavaScript documentation. At least, the quality properties are out of scope.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 12, 2016 May 12, 2016

Copy link to clipboard

Copied

Out of scope?

For Export for Web?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
May 12, 2016 May 12, 2016

Copy link to clipboard

Copied

I take it back… As I am working with the saveAsxxx saveOptions, I work with other numbers than in the export for web function.

Looks like a serious inconsistency to me…

BTW, I may delete my entry in a few hours, because of irrelevance.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Aug 09, 2016 Aug 09, 2016

Copy link to clipboard

Copied

LATEST

IMO Photoshops' image compression tools aren't very good, maybe you can achieve something externally. I would recommend exporting as a high quality jpg (or png if you need transparency or are working with flat colors) at the exact resolution you need them to appear, then using a tool like https://tinypng.com/ or WP- smush. You'll end up with smaller images that look better than what photoshop can achieve.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines