HEIC images aren't lossless

I'm trying to use Image I/O to create lossless HEIC images. As far as I can tell, it isn't possible. I've added a 1 pixel border around an TIFF image. When I save the TIFF image as HEIC, the border blurs to 3 pixels. If I save to PNG, changing only the "type" parameter in "CGImageDestinationCreateWithURL" the result is lossless.

I compared this behaviour with Pixelmator Pro and Apple's own Preview. When I move the quality knob all the way over to lossless, I still get that blurry 3 pixel border.

I have set the kCGImageDestinationLossyCompressionQuality option to 1.0. I can change the quality and see how it changes, but I can't get it to lossless mode.

Is there some other way to get HEIC into lossless mode that I don't know about?
Submitted a bug report and DTS ticket. I have a demo app that easily demonstrates the issue. At 1.0 quality, all other formats, including JPEG, are apparently lossless. HEIC is obviously lossy.
Perhaps HEIC is lossless after all. What is happening is that when an HEIC destination writes the image to disk, it resizes the image by one pixel. It actually crops one pixel on the bottom and left. You would only know it if you had added a noticeable, 1 pixel border, which I had done to debug. Obviously, a one-pixel resize is going to remove any losslessness.

One thing you can do is manually shrink the image by one pixel width, and two pixels high, shifting the image up by one pixel. Then it won't crop any of the image. Of course, now you've done two one-pixel resizes, but at the least the geometry will now be correct.

Apparently someone at Apple already knew that because Preview seems to do that double-resize too. But at least HEIC is still useable for reading and for low-resolution previews.
HEIC images aren't lossless
 
 
Q