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

PSD Format - how to read compressed data from Image Data Section?

Community Beginner ,
Mar 26, 2007 Mar 26, 2007

Copy link to clipboard

Copied

Has anybody tried to read ZIP-compressed data from the Image Data section in PSD file format? I tried to read data compressed with predication as well as without prediction, but had no success - the inflating function returns no error, but the image is corrupt. I used different versions of ZLib to decompress the data - none of them worked. If you have any experience in this area and are ready to help, it will be much appreciated!
Thank you in advance,
Anatoly
TOPICS
SDK

Views

6.2K

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
Participant ,
Apr 07, 2007 Apr 07, 2007

Copy link to clipboard

Copied

I see now how the confusion has arisen. There is in fact no mention of ZIP anywhere in Photoshop 6.0 File Formats Specification Release 1 (September 2000). However, I just today stumbled across a copy of Release 2 - and you're right, it's right where you say it is. (I also stumbled across a copy of the Photoshop CS File Formats document, which also mentions ZIP.)

But I cannot find an option to produce ZIP compressed PSDs in CS2 (I did say this above). Maybe it's intended for PSB.

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 ,
Apr 08, 2007 Apr 08, 2007

Copy link to clipboard

Copied

You're right about Photoshop not having a ZIP compression option in its save dialog box (I use PS 7 and it too does not include such an option), however this is not to say that ZIP compression may not be employed behind the scenes. Search the help for ZIP and you will find the following bit of info:

"Photoshop PDF format supports all of the color modes and features that are supported in standard Photoshop format. Photoshop PDF also supports JPEG and ZIP compression, except for Bitmap-mode images, which use CCITT Group 4 compression."

If you take another look at the 6.0 specs you will see that the ZIP compression option dates back to days of PS 3.0!

My guess is that PS somehow decides on a suitable compression option i.e. RAW (0), RLE(1), ZIP - prediction(2), ZIP + prediction(3). (Anatoly, have you tried both kinds of ZIP compression? Its not something you should have to guess. The ImageData::compression field should tell you the compression option that's been used.)

One last thing though, users are allowed to decide the image/layer compression type when saving multilayered TIFFs in PS. And as everyone knows 😉 , TIFFs saved in PS have a lot in common with PSDs. (Speaking of TIFFs, LibTIFF has some support for ZIP compression, and as everyone knows 😉 TIFF was originally developed by Adobe.)

PS:
Erm ... I thought the Photoshop CS File Formats document was not public domain!

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
Participant ,
Apr 09, 2007 Apr 09, 2007

Copy link to clipboard

Copied

It is very well known that TIFF, PDF, and PostScript since Level 2 support ZIP, etc. This has no relevance to PSD, of course. TIFF was NOT originally developed by Adobe (some of us can remember life before Adobe), but through acquisitions they are now its nominal "owner".

> you will see that the ZIP compression option dates back to days of PS 3.0!

I have no idea what you mean by that. It was not even mentioned until Release 2 of the V6 document, and even then, nobody is even sure if CS2 can generate ZIP compressed PSD. There is one very important reason why it would not arbitrarily choose compression types in the way you suggest: Doing so would unpredictably make files incompatible with older Photoshop versions (you may believe PS3.0 decompresses ZIP, but I don't for a moment).

As I said above, however, it is quite possible that PSB uses ZIP, even adaptively as you suggest. However the document does not even discuss whether this is true; discussion of ZIP is limited to about five words.

This is by no means "documentation"; it's merely "mentioning". The File Formats document is one of the most incomplete and poorly expressed specs I've ever seen, as is soon discovered by anyone, like the original poster, or myself, who tries to use it to write working code. Some of the typos were fixed in the CS version, but none of the serious flaws and omissions.

Public domain? It's not my site. Anyone can find those links on Google.

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 ,
Apr 09, 2007 Apr 09, 2007

Copy link to clipboard

Copied

Yes I did find the doc when I did Google search, and I was quite surprised that it was online because I thought version 6 was the last publicly available specification.

As for ZIP compression in version 3.0 of Photoshop, refer to pages 19-25 of the version 6 (rel. 2) specification. You will see that this specification mentions ZIP compression on pages 21 and 24.

I agree with you though that the specification appears far from complete. For example, I had to go search other sites for information on Adobe's implementation of a packbits (which really is a version of RLE).

Arguments aside, I wonder if Anatoly has tried to decompress the imagedata using ZLib with and without prediction.

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
Participant ,
Apr 09, 2007 Apr 09, 2007

Copy link to clipboard

Copied

> As for ZIP compression in version 3.0 of Photoshop

There is no such thing. Any inference otherwise from the 6.0 Release 2 documentation is incorrect.

If you can find a PSD with ZIP - if such a thing can be created at all - I'm more than happy to try to open it with 3.0 to prove this.

Once again, I suspect that ZIP is only relevant to PSB - although of course they omitted to explain.

Re: PackBits - Apple invented that particular RLE flavour. It was in the Mac Toolbox ROM circa 1984 and may have been used by the Lisa too. It's one of the TIFF standard compressors.

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 ,
Apr 20, 2007 Apr 20, 2007

Copy link to clipboard

Copied

I've solved this problem, to uncompress the zip data. I'm the author of libpsd, you can download full source code from http://libpsd.graphest.com, and you can find it on sourceforge.net.

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 ,
Apr 20, 2007 Apr 20, 2007

Copy link to clipboard

Copied

Cool! ... I only wish you'd posted this before I wrote my TIFF library.

Just a couple of questions though:

1. Is libpsd documented?
2. How exactly did you solve the ZIP uncompression issue?

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
Participant ,
Apr 20, 2007 Apr 20, 2007

Copy link to clipboard

Copied

Does anyone know how to create a ZIP compressed PSD/PSB in Photoshop?

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 ,
Apr 22, 2007 Apr 22, 2007

Copy link to clipboard

Copied

After Photoshop CS, Adobe uses the zip format for data saving as default. If it couldn't work, set the color depth to 16 bit.

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
Participant ,
Apr 23, 2007 Apr 23, 2007

Copy link to clipboard

Copied

LATEST
> After Photoshop CS, Adobe uses the zip format for data saving as default.

CS2 has only ever made PackBits PSDs for me, no matter what bit depth. Can you elucidate?

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