package eu.friedcutlet.yokan.services.download /** * Re-encodes a downloaded manga page as a grayscale JPEG whose short side is at most [maxShortSide] * (see [eu.friedcutlet.yokan.database.einkScaledSize]). Null keeps the original bytes: undecodable or * animated images, or a result that would not be smaller. */ internal expect fun transcodeEinkPage(bytes: ByteArray, maxShortSide: Int): ByteArray? internal const val EinkJpegQuality = 85 /** GIFs may be animated; the decoders below would keep only the first frame. */ internal fun ByteArray.isGif(): Boolean = size >= 4 && this[0] == 'G'.code.toByte() && this[1] == 'I'.code.toByte() && this[2] == 'F'.code.toByte() && this[3] == '8'.code.toByte()