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

Export as .. File Quality based on MB/KB size - Photoshop JavaScript script.

Explorer ,
Nov 13, 2019 Nov 13, 2019

Hello, i need to create a Photoshop JavaScript script that will reduce the quality based on a given file size.

Lets say i have a 800x800 resolution PNG image that is 700kb. 

How can i script it as to tell Photoshop to Export the file a 800x800 JPG file around 200kb. 

The file size doesnt have to be 100% exact.  It can be plus or minus 7kb -> 207kb or mb -> 193mb.

Important thing is i have to tell Photoshop via JavaScript ExtendScript to reduce the quality based on the size i give it. 

 

Any help would be appreciated.

TOPICS
Actions and scripting
2.3K
Translate
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 ,
Nov 13, 2019 Nov 13, 2019

There have been scripts posted the do what you want.  The problem is the post may no longer be available post over three years old are not longer available on this changed site. And this site search has its problems.  A script most likely can not predict how well a particular image will compress at some  jpeg image quality setting.  A script would most likely need to use "save as" jpeg at a high image quality then examine the size of the saved file. If to large save over the file lowering the jpeg quality till the output file falls within you criteria.

 

Photoshop Save for Web feature seems to be able to estimate what output file size  will be produces at an image quality setting.  However, I do not know if a script can set and retrieve fields in Photoshop Save to web dialog.  Look at the sizes shown in the 4up save for web tab the the different quality settings..

 

image.png

JJMack
Translate
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 ,
Nov 13, 2019 Nov 13, 2019
LATEST

Try here to start:

 

Save Small JPEG

savesmalljpeg.jsx

Translate
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