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

Apply Layer Mask does not seem to shrink document size

New Here ,
May 09, 2024 May 09, 2024

Copy link to clipboard

Copied

I have a document with only one layer that is 250MB.  If I duplicate that layer, then the document becomes 500MB.  (Using round numbers here).  If I then take that new layer, create a layer mask, invert it to hide everything in the layer, and then select "Apply Layer Mask", the resulting layer appears empty/transparent, which is what you would expect.  However, the document is still showing in PS as 500MB.  What's wrong here?  If I create an empty layer, it does not increast the document size.  So what is the difference between a new empty layer, and an empty layer that was created as stated above by applying an inverted layer mask?

 

For those interested, the reason I need to do this is complicated but I will try to explain.  I have a sharpening plugin that I use.  I always run that plugin on a new layer and then I create an inverted layer mask and selectively paint in the sharpening only where needed.  I could leave things that way, but having the document grow so large is not helpful, expecially when I am only painting in the sharpening to a small area of the total image.  I was hoping that the "Apply Layer Mask" would shrink the document since it makes all the non masked pixels transparent.  

 

I am running PS 2024 25.7.0 release on Sonoma 14.4.1.

 

Am I missing something?  Other than free disk space?  😀

TOPICS
macOS

Views

149

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 09, 2024 May 09, 2024

Copy link to clipboard

Copied

I'm not getting that.

 

A new empty layer roughly doubles the size.

A duplicate layer emptied by "apply layer mask" produces exactly the same size, down to the last byte.

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 09, 2024 May 09, 2024

Copy link to clipboard

Copied

@jalessi 

 

There appears to be an update/refresh memory issue with the info panel or status bar with the open size after applying the layer mask.

 

I don't know if this is just a display issue or if Photoshop is holding onto the extra data in RAM. Purge doesn't affect the reported size.

 

If you save, close and open the image again, it is no longer double size in memory and matches the size of a new empty layer as you would expect.

 

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 09, 2024 May 09, 2024

Copy link to clipboard

Copied

I was wondering if there might be more to it than a possible reporting bug, because there can be more factors that affect layers with masks. I did a quick test which anyone might verify with their own files. The spreadsheet image below shows what I found. It raises a few questions that I address after the image. The point of me doing this is just to say, make sure you’ve accounted for these things, because lots of things happen between starting with a single layer and adding layers and masks, and some of them are not obvious.

 

The short version is, if the file size doesn’t go down as far as you think after applying the mask, it might be at least partly because all you got rid of was a mask, and a mask actually contributes the least to the file size, and contributes much less than the other things that got added along the way.

 

For the details, keep reading…

One reason I wanted to test was that I was wondering if it made any difference whether the document starts out as a single Background layer (no transparency possible) or a single normal layer (transparency possible), because simply making it not a Background layer increases the file size to accommodate an alpha channel (but not just that, which I’ll cover at the end).

 

The other question is what difference the Maximum Compatibility option makes. It adds the composite compatibility layer, which increases file size significantly. The compatibility layer option isn’t offered or needed for a document that has one Background layer.

 

OK, so let’s go through the table pictured below, with the questions.

Important: The sizes are saved file sizes reported by macOS Finder, not any of the numbers inside Photoshop.

 

Photoshop-file-size-and-layer-attributes.jpg

 

Q: Why does file B start out double the size of all the others?

A: B is a layer (not Background), so it must provide for transparency, and on top of that the Maximum Compatibility option is enabled, so it really has two layers. So, double the size. All other files are either a Background (flattened), or do not use the Maximum Compatibility option so there really are no other layers in the document.

 

Q: After duplicating the first layer, why are A and B about 1/3 larger than C and D?

A: For A and B, Maximum Compatibility is on. If it was not, all files would be around 43MB because the original 22-ish MB layer was duplicated.

 

Q: Why do all four files only gain 1MB or less when the pixel mask is added?

A: A mask is just a grayscale image, one channel instead of three. Also it’s 8 bits/channel even if the image is higher. And, because a mask is often large areas of white or black, it compresses very well, much better than a color layer. So, a mask can be much less data than a full color image layer with all kinds of color value variations in it. The bulk of the file size is still the two layers plus (for A and B) the composite compatibility layer.

Q: Why do all four files lose almost nothing after the mask is applied?

A: Probably because of the previous answer, file size didn’t go up much when the mask was added.

Q: OK, but…why does it not go down as far as it went up when the mask was added?

A: Maybe because the changes to the RGB layer made by the applied mask are color, not grayscale, so they might not compress as well as they did before. I’m less sure about this one.

 

In the end, what I found out is:

  • Whether it started out as a Background or a layer doesn’t make much difference if you’re adding at least one more layer. 
  • Masks increase file size less than I thought…a lot less. 
  • The file size increase has a lot more to do with the Maximum Compatibility composite layer. 

 

I have to keep Maximum Compatibility enabled, because I want to be able to preview and use the Photoshop file in other applications such as Lightroom Classic. But maybe you have a choice.

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 10, 2024 May 10, 2024

Copy link to clipboard

Copied

I just assumed finished file size on disk - and a little too late realized that compression and layer compression will influence the result. I always save uncompressed.

 

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 10, 2024 May 10, 2024

Copy link to clipboard

Copied

@Conrad C & @D Fosse 

 

This isn’t about size on disk, it's about size reported on the open doc in memory (at least in my findings).

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 10, 2024 May 10, 2024

Copy link to clipboard

Copied

Understood.

 

My philosophy has always been that file size is what it is. If I started worrying about that, I wouldn't get any work done 😉

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 10, 2024 May 10, 2024

Copy link to clipboard

Copied


@D Fosse wrote:

Understood.

 

My philosophy has always been that file size is what it is. If I started worrying about that, I wouldn't get any work done 😉


 

I hear you!  :]

 

This looks like a bug to me.

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 10, 2024 May 10, 2024

Copy link to clipboard

Copied

Is there off-canvas content on the Layer? 

Was the Mask actually fully black? 

 

Can you provide the file? 

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 10, 2024 May 10, 2024

Copy link to clipboard

Copied

LATEST

@c.pfaffenbichler 

 

This is easy to test for yourself...

 

1) Open any image:

01.png

 

2) Add a new blank layer, there is no reported file size change:

02.png

 

3) Delete the blank layer, dupe the single layer and add a hide-all layer mask. The file size in open memory is doubled, as expected:

03.png

 

4) Apply the layer mask. The reported size doesn't change. You can test that there are no pixels in the layer, it's empty.

04.png

 

5) Save, close and reopen the image, it will no longer be reported as double the size, it will be the same as step 2.

05.png

 

I have created a bug report here:

https://community.adobe.com/t5/photoshop-ecosystem-bugs/incorrect-file-size-reported-after-apply-hid...

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