Add
- Add an opt-in
.preferHighDynamicRangeoption andpreferHighDynamicRange(_:)setter to decode images with a gain map (such as photos from recent iPhones and Ultra HDR JPEGs) as HDR on iOS 17, tvOS 17 and visionOS 1 or later. The HDR content is kept through downsampling, background decoding, the disk cache, and the drawing and Core Image processors. On macOS, the gain map of an HDR image is now kept when the image is stored to the disk cache. #2647 #2648 #2650 #2328 #2137 @onevcat @CloudlessMoon @jerrellmardis - Add the
.onDataReceivedoption and theonDataReceived(_:)setter to observe each chunk of image data thatImageDownloaderreceives. Handlers add up with the ones indefaultOptions, and a stale request is not called. #2640 #2635 #2118 @shubhransh-gupta - Add static async
ImagePrefetcher.prefetch(urls:),prefetch(resources:)andprefetch(sources:)methods that return anImagePrefetchResultand stop the prefetching when the task is cancelled. #2633 @shubhransh-gupta - Add
AsyncAnyModifierand an asyncrequestModifier(onDownloadTaskStarted:_:)setter, to modify the download request with an async closure. #2629 @shubhransh-gupta - Add
border(_:),border(color:lineWidth:radius:roundingCorners:)andcolorControls(brightness:contrast:saturation:inputEV:)toKFOptionSetter, soKF.Builder,KFImageandKFAnimatedImagecan chain these processors. #2642 #2631 @shubhransh-gupta - Add a
writeOptionsparameter toImageCache.storeToDisk, and apply.diskStoreWriteOptionsalso to the original image stored by.cacheOriginalImage. #2628 @shubhransh-gupta
Fix
- Return a cancellable
DownloadTaskwhen anAsyncImageDownloadRequestModifieris used. Before,retrieveImagereturnednil, socancelDownloadTask()andKFImagecould not stop the download. #2645 @onevcat - Use a full-precision and stable color identifier in
BorderImageProcessor,TintImageProcessor,OverlayImageProcessor,BlendImageProcessorandCompositingImageProcessor, so close colors no longer share a cache key and a pattern color no longer crashes on macOS. The cache keys of these processors change, so images cached with them are processed again once. #2639 #2632 @shubhransh-gupta - Apply the alpha of the border color only once in
addingBorder(_:)andBorderImageProcessor. #2626 @unaltolga - Draw the solid overlay color at fraction 0 in
overlaying(with:fraction:)andOverlayImageProcessoron macOS, the same as on iOS. #2625 @unaltolga - Fix
blurred(withRadius:)andBlurImageProcessordropping the second box blur pass for a small radius. #2636 @unaltolga - Fall back to an RGB context on macOS when a bitmap context cannot use the image's format, such as a 16-bit gray image with alpha, so decoding and the drawing processors no longer fail for it. #2641 @unaltolga
- Use the pixel size of the backing
CGImageto compute the memory cost of an image made withNSImage(cgImage:size:)on macOS. #2652 #2651 @xinnjie - Use the pixel size of the backing
CGImageforkf.sizeof an image made withNSImage(cgImage:size:)on macOS, so crop, blur and the drawing processors give correct results on Retina displays. #2654 @onevcat - Throw
.diskStorageIsNotReadyfrom the size, cleaning and removal methods ofDiskStoragewhen the storage is not ready, instead of reporting a size of 0 or a raw file system error. #2634 @shubhransh-gupta - Always call the completion handler of
calculateDiskStorageSizeand the disk cache retrieving when an unexpected error happens. #2630 @shubhransh-gupta