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?

TOPICS
How to, Import and export

Views

54

Likes

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

Adobe Community Professional , 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,...

Likes

Translate

Translate
Adobe Community Professional ,
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

Likes

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

Copy link to clipboard

Copied

LATEST

@wilderthanyou 

 

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

Likes

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