https://pharo.manuscript.com/f/cases/21611With the new File/Stream changes in Pharo 7, ImageReadWriter and subclasses broke because these classes are not yet capable of working with simple binary streams.
I created a new test case (attached) to catch the functional degradation. For each image type (class) there are 2 tests, IO in memory and IO to file.
For example:
testJpegWriteReadInMemory
| form bytes result |
form := self pharoLogoFormNonTransparent.
bytes := ByteArray streamContents: [ :out | PluginBasedJPEGReadWriter putForm: form onStream: out ].
"Without format detection"
result := (JPEGReadWriter on: bytes readStream) nextImage.
self assert: form bits size equals: result bits size.
"With format detection"
result := ImageReadWriter formFromStream: bytes readStream.
self assert: form bits size equals: result bits size
testJpegWriteReadUsingFiles
| form file result |
form := self pharoLogoFormNonTransparent.
file := (self class name asString , '-pharo-logo.jpeg') asFileReference.
file ensureDelete.
(PluginBasedJPEGReadWriter on: file binaryWriteStream) nextPutImage: form. "gets closed ?!"
"Without format detection"
result := file binaryReadStreamDo: [ :in | (JPEGReadWriter on: in) nextImage ].
self assert: form bits size equals: result bits size.
"With format detection"
result := file binaryReadStreamDo: [ :in | ImageReadWriter formFromStream: in ].
self assert: form bits size equals: result bits size.
file delete
I have a bunch of changes that make all tests pass. They clean up some strange coding as well.
I will make a proper PR later.
Sven