guessTargetColorspace returns the colorspace to which the image should be saved. If target format supports 16-bit colorspace, it will be preferred.
(img *vips.Image, supports16Bit bool)
| 35 | // guessTargetColorspace returns the colorspace to which the image should be saved. |
| 36 | // If target format supports 16-bit colorspace, it will be preferred. |
| 37 | func guessTargetColorspace(img *vips.Image, supports16Bit bool) vips.Interpretation { |
| 38 | interp := img.GuessInterpretation() |
| 39 | |
| 40 | switch interp { |
| 41 | case vips.InterpretationRGB, vips.InterpretationSRGB, vips.InterpretationBW: // 3 bytes |
| 42 | return interp // as is |
| 43 | |
| 44 | case vips.InterpretationRGB16: // 3 uint16 |
| 45 | if supports16Bit { |
| 46 | return interp // as is |
| 47 | } |
| 48 | return vips.InterpretationSRGB |
| 49 | |
| 50 | case vips.InterpretationGrey16: // 1 uint16 |
| 51 | if supports16Bit { |
| 52 | return interp // as is |
| 53 | } |
| 54 | return vips.InterpretationBW |
| 55 | |
| 56 | case vips.InterpretationCMYK: // 4 bytes |
| 57 | return vips.InterpretationSRGB |
| 58 | |
| 59 | default: |
| 60 | if supports16Bit { |
| 61 | return vips.InterpretationRGB16 // best effort |
| 62 | } |
| 63 | return vips.InterpretationSRGB // sRGB can be produced from any colorspace |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | // shouldImportICC returns true if we need to import ICC profile for the image. |
| 68 | func shouldImportICC(img *vips.Image) bool { |
no test coverage detected