edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiBba458d2Tahinli2 months ago1975 commits
| 1 | """Write the TIFF alpha shapes ImageMagick will not emit. |
| 2 | |
| 3 | ImageMagick always tags a TIFF's alpha channel as associated (ExtraSamples 2, |
| 4 | premultiplied) and ignores ``-define tiff:alpha=unassociated``, so the ordinary |
| 5 | straight-alpha file -- the common one -- has to be written here. Both files |
| 6 | carry the same picture with the alpha flattened to 0 or 255, which makes the |
| 7 | premultiplication lossless and so lets the two decode to identical pixels. |
| 8 | """ |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | , , , = , , , |
| 14 | = |
| 15 | |
| 16 | # Flatten alpha to fully transparent or fully opaque: premultiplying by 0 or 1 |
| 17 | # loses nothing, so the associated file is recoverable exactly. |
| 18 | = |
| 19 | |
| 20 | , , , = |
| 21 | += |
| 22 | |
| 23 | |
| 24 | |
| 25 | """A little-endian, uncompressed, single-strip RGBA file.""" |
| 26 | = |
| 27 | |
| 28 | |
| 29 | |
| 30 | = b |
| 31 | |
| 32 | # The header is 8 bytes, then the strip, then the directory: writing the |
| 33 | # pixels first keeps every out-of-line value at a known offset behind it. |
| 34 | = 8 |
| 35 | = + |
| 36 | = |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | = + 2 + 12 * + 4 |
| 50 | |
| 51 | = |
| 52 | |
| 53 | |
| 54 | += |
| 55 | == 3: |
| 56 | += |
| 57 | |
| 58 | += |
| 59 | += |
| 60 | += |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 |