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

Save for web legacy limitation workaround for instagram carousel

Community Beginner ,
Jul 14, 2021 Jul 14, 2021

Copy link to clipboard

Copied

Hi there, I posted earlier asking why "export for web - legacy" was not maintaining my proper canvas size and image size. (previous post: https://community.adobe.com/t5/photoshop/can-t-change-image-size-when-exporting-in-save-to-web/td-p/...)

I learned that this process has a limitation of 8192 pixels H or W - so people recommend using export > save as jpeg... The problem is, the purpose of what I'm doing is I am creating a multi-image instagram carousel. So I have spliced my canvas into 9 sections (1080 x 9 = 9720). It allows me to export for web lecagy but it decreases my image size thereby reducing the image quality. So when I tried export > save as jpeg, it didn't retain the splices. I need it to result in 9 different jpegs. Does anyone know a workaround for this?

Views

2.5K

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

correct answers 1 Correct answer

Community Expert , Jul 14, 2021 Jul 14, 2021

Something like this? The code below has been adjusted to default to 9 columns x 1 row.

 

Yes, it saves to PNG, however, it is easy enough to change the code to save to JPEG, but it would be good to know what JPEG settings. Perhaps show via screenshot what you would use in either save as copy or save for web legacy.

 

https://www.andrewnoske.com/wiki/Adobe_Photoshop_-_Scripts_Related_to_Montaging

 

 

// Takes the currently opened image, and allows the user to split it into
// a grid of PNG tiles,
...

Votes

Translate

Translate
Adobe
Community Expert ,
Jul 14, 2021 Jul 14, 2021

Copy link to clipboard

Copied

Something like this? The code below has been adjusted to default to 9 columns x 1 row.

 

Yes, it saves to PNG, however, it is easy enough to change the code to save to JPEG, but it would be good to know what JPEG settings. Perhaps show via screenshot what you would use in either save as copy or save for web legacy.

 

https://www.andrewnoske.com/wiki/Adobe_Photoshop_-_Scripts_Related_to_Montaging

 

 

// Takes the currently opened image, and allows the user to split it into
// a grid of PNG tiles, by specifying an number of columns and rows and a
// base file prefix.
//
// Tiles are created by duplicating the original image, cropping then saving.
// Tiles are saved in the form: 'C:/path/prefix0,0.png'

#target photoshop

if (documents.length != 1) {
  alert("Must open exactly one image in photoshop first");
} else {
  // Prompt user for number of columns and rows:
  var cols = parseInt(prompt("How many columns?", 9));
  var rows = parseInt(prompt("How many rows?", 1));
  var total = cols*rows;
  
  // Determine target tile size:
  var image = app.documents[0];
  var tileWidth = image.width / cols;
  var tileHeight = image.height / rows;
  
  // Draw guides along cuts:
  for(col = 0; col <= cols; col++) {
    image.guides.add(Direction.VERTICAL, col * tileWidth);
  }
  for(row = 0; row <= rows; row++) {
    image.guides.add(Direction.HORIZONTAL, row * tileHeight);
  }

  // Prompt user to confirm, and for file prefix to save out to:
  var savePath = File.saveDialog("Save Image File Prefix", "");
  if(!savePath) {alert("Cancelled"); exit;}
  if(!confirm("Create " + total + " tiles, each of " +
              tileWidth + " x " + tileHeight + "?\n\n\n" + 
              "Tiles will be saved as '" + savePath.fsName +
              "1,1.png' '...1,2.png' etc")) { exit; }

  // For each tile:
  for(row = 0; row < rows; row++) {
   for(col = 0; col < cols; col++) {
     // Determine crop coordinates (in pixels):
     var top = row * tileHeight;
     var bottom = top + tileHeight;
     var left = col * tileWidth;
     var right = left + tileWidth;

     // Duplicate image, crop, save as PNG and close:
     var tile = image.duplicate();  // Duplicate file.
     cropCurrentDocument(top, left, bottom, right);
     saveTileAsPng(tile, savePath.fsName, col, row);
     tile.close(SaveOptions.DONOTSAVECHANGES);
    }
  }
} 

function saveTileAsPng(img, origFilePath, col, row) {
  var newFilePath = origFilePath + "_" + col + "," + row + ".png";
  var newFile = new File(newFilePath);
  var pngSaveOptions = new PNGSaveOptions(); 
  activeDocument.saveAs(newFile, pngSaveOptions, true, Extension.LOWERCASE);
} 

// Crops active document by a rectangle with the given pixel coordinages.
function cropCurrentDocument(top, left, bottom, right){
  app.preferences.rulerUnits = Units.PIXELS;  
  activeDocument.selection.select(
      [[left, top], [right, top], [right, bottom], [left, bottom]],
      SelectionType.REPLACE, 0, false);
  executeAction(charIDToTypeID( "Crop" ), new ActionDescriptor(),
                DialogModes.NO );
}

 

 

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

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 ,
Jul 18, 2021 Jul 18, 2021

Copy link to clipboard

Copied

@mjbwale 

 

Is there a correct answer in either of your two topic threads?

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
Explorer ,
May 18, 2023 May 18, 2023

Copy link to clipboard

Copied

Is this seriously supposed to be a solution? I want to make one more pannel in my instagram carrousel and now I have to learn how to script in PS?...

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 18, 2023 May 18, 2023

Copy link to clipboard

Copied

quote

Is this seriously supposed to be a solution? I want to make one more pannel in my instagram carrousel and now I have to learn how to script in PS?...


By @Brittow

 

No, all you have to do is learn to run a custom script. There is a big difference.

 

You could simply manually crop the image into separate panels if you are not looking for automation.

 

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
Explorer ,
May 18, 2023 May 18, 2023

Copy link to clipboard

Copied

Well yes, manually slicing the image is not the issue though, just the exporting.

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 18, 2023 May 18, 2023

Copy link to clipboard

Copied

Slicing isn't the answer if you keep the canvas larger than 8192px, that's why I specifically used the term crop and not slice.

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
Explorer ,
May 18, 2023 May 18, 2023

Copy link to clipboard

Copied

It worked but it completed change the colors. 

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 18, 2023 May 18, 2023

Copy link to clipboard

Copied

quote

It worked but it completed change the colors. 


By @Brittow

 

There is nothing in the code to change colours, however, it doesn't explicitly include an ICC profile in the PNG save options.

 

Is your image sRGB?

 

What version of Photoshop are you running?

 

There are other options, the following script can create the slices as layers, then you can use Export As or the Export Layers to Files script that comes with Photoshop:

 

 
Another script can save slices to PSD without using Save for Web (no 8192px limit). The PSD would then need to be batch processed to PNG or JPEG. Or the script code would need to be updated for the required file format.

 

 

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
Explorer ,
May 18, 2023 May 18, 2023

Copy link to clipboard

Copied

The images are in ProPhoto RGB

The version is 22.4.3

I'll check this script. Thanks

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
Explorer ,
May 18, 2023 May 18, 2023

Copy link to clipboard

Copied

I converted the color space from PhoPhoto to sRGB and it seemed to solve the color shift issue when exporting with the script.

 

Is there a way to make it export as JPG and choose the export options such as quality and to include ICC profile?

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 18, 2023 May 18, 2023

Copy link to clipboard

Copied

quote

I converted the color space from PhoPhoto to sRGB and it seemed to solve the color shift issue when exporting with the script.

 

Yes, colour management 101.

 

quote

Is there a way to make it export as JPG and choose the export options such as quality and to include ICC profile?


By @Brittow

 

Yes, I'll change the code when I have time. If you are in a hurry, you can simply use Image Processor to convert the PSD to JPEG.

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 24, 2023 May 24, 2023

Copy link to clipboard

Copied

@Brittow – Here is a version of the script posted above to save to JPEG quality level 10 including ICC profile:

 

// Takes the currently opened image, and allows the user to split it into
// a grid of PNG tiles, by specifying an number of columns and rows and a
// base file prefix.
//
// Tiles are created by duplicating the original image, cropping then saving.
// Tiles are saved in the form: 'C:/path/prefix0,0.jpg'

/*
Modified to save JPEG versions:
https://community.adobe.com/t5/photoshop-ecosystem-discussions/save-for-web-legacy-limitation-workaround-for-instagram-carousel/m-p/13801386
v1.0 - 19th May 2023, initial changes made from PNG to JPEG
v1.1 - 28th June 2024, minor changes for extensions from .png to .jpg
*/

#target photoshop

if (documents.length != 1) {
  alert("Must open exactly one image in photoshop first");
} else {
  // Prompt user for number of columns and rows:
  var cols = parseInt(prompt("How many columns?", 9));
  var rows = parseInt(prompt("How many rows?", 1));
  var total = cols*rows;
  
  // Determine target tile size:
  var image = app.documents[0];
  var tileWidth = image.width / cols;
  var tileHeight = image.height / rows;
  
  // Draw guides along cuts:
  for(col = 0; col <= cols; col++) {
    image.guides.add(Direction.VERTICAL, col * tileWidth);
  }
  for(row = 0; row <= rows; row++) {
    image.guides.add(Direction.HORIZONTAL, row * tileHeight);
  }

  // Prompt user to confirm, and for file prefix to save out to:
  var savePath = File.saveDialog("Save Image File Prefix", "");
  if(!savePath) {alert("Cancelled"); exit;}
  if(!confirm("Create " + total + " tiles, each of " +
              tileWidth + " x " + tileHeight + "?\n\n\n" + 
              "Tiles will be saved as '" + savePath.fsName +
              "1,1.jpg' '...1,2.jpg' etc")) { exit; }

  // For each tile:
  for(row = 0; row < rows; row++) {
   for(col = 0; col < cols; col++) {
     // Determine crop coordinates (in pixels):
     var top = row * tileHeight;
     var bottom = top + tileHeight;
     var left = col * tileWidth;
     var right = left + tileWidth;

     // Duplicate image, crop, save as PNG and close:
     var tile = image.duplicate();  // Duplicate file.
     cropCurrentDocument(top, left, bottom, right);
     saveTileAsJPEG(tile, savePath.fsName, col, row);
     tile.close(SaveOptions.DONOTSAVECHANGES);
    }
  }
} 

function saveTileAsJPEG(img, origFilePath, col, row) {
  var newFilePath = origFilePath + "_" + col + "," + row + ".jpg";
  var newFile = new File(newFilePath);
  var jpgSaveOptions = new JPEGSaveOptions();
  jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
  jpgSaveOptions.embedColorProfile = true;
  jpgSaveOptions.matte = MatteType.NONE;
  jpgSaveOptions.quality = 10;  
  activeDocument.saveAs(newFile, jpgSaveOptions, true, Extension.LOWERCASE);
} 

// Crops active document by a rectangle with the given pixel coordinages.
function cropCurrentDocument(top, left, bottom, right){
  app.preferences.rulerUnits = Units.PIXELS;  
  activeDocument.selection.select(
      [[left, top], [right, top], [right, bottom], [left, bottom]],
      SelectionType.REPLACE, 0, false);
  executeAction(charIDToTypeID( "Crop" ), new ActionDescriptor(),
                DialogModes.NO );
}

 

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 ,
Jun 27, 2024 Jun 27, 2024

Copy link to clipboard

Copied

hello!
great script. I wondered if there was a way to have this same outcome, but instead of starting of of a already flatened and exporte PNG, I could run it directly from the original PSD file I'm working on (thinking about simplifying the workflow).

I actually did try to run it directly from the PSD but it resulted in HUGE jpgs, i don't understand why.
Running from the the flat PNG results in ~200kb slices, but running from PSD results in 40mb slices.
I tried to flat the PSD before running and the output is the same... 

thanks

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 ,
Jun 27, 2024 Jun 27, 2024

Copy link to clipboard

Copied

LATEST
quote

I actually did try to run it directly from the PSD but it resulted in HUGE jpgs, i don't understand why.
Running from the the flat PNG results in ~200kb slices, but running from PSD results in 40mb slices.
I tried to flat the PSD before running and the output is the same... 

thanks


By @kind_operator15C3

 

 

How did you save the JPEG or PNG files?

 

Did you use Save As/Save a Copy... Or did you use Export As or Save for Web (Legacy)?

 

file-info.png

 

In the PSD file, go to File > File Info, then the Raw Data tab. Do you see a message that there is too much metadata to display? More here:

 

https://prepression.blogspot.com/2017/06/metadata-bloat-photoshopdocumentancestors.html

 

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