#FEATURE by exept
authorClaus Gittinger <cg@exept.de>
Fri, 18 Oct 2019 20:57:51 +0200
changeset 8845 6e7cbf194cd9
parent 8844 71867baa556e
child 8846 c77242ddd1fa
#FEATURE by exept class: Image class added: #fromBase64Stream:using: comment/format in: #fromStream: #fromStream:using:
Image.st
--- a/Image.st	Fri Oct 18 01:46:33 2019 +0200
+++ b/Image.st	Fri Oct 18 20:57:51 2019 +0200
@@ -1871,6 +1871,28 @@
 
 !Image class methodsFor:'file reading'!
 
+fromBase64Stream:aStream using:aReaderClass
+    "read an image from a base64 encoded stream, given an imageReaderClass.
+     Use this, if you know the file's format, but it has an invalid
+     extension (or non-definite header), so #fromStream: could not
+     find out the images format.
+     Return nil (or whatever a handler returned),
+     if the stream does not contain an appropriate image."
+
+    |image|
+
+    image := aReaderClass fromBase64Stream:aStream.
+    image notNil ifTrue:[^ image].
+
+    "/ nope - unknown format
+    ^ ImageNotFoundQuerySignal
+                raiseRequestWith:aStream
+                errorString:('Image: unknown image file format in stream').
+
+    "Created: 1.2.1997 / 14:46:20 / cg"
+    "Modified: 1.2.1997 / 14:48:53 / cg"
+!
+
 fromFile:aFileName
     "read an image from a file - this methods tries to find
      out the file format itself (by the extension and by contents)
@@ -2138,11 +2160,7 @@
         ]
     ].
 
-    "
-     nope - unknown format
-    "
-"/    'Image [info]: unknown image file format in stream: ' infoPrintCR.
-
+    "/ nope - unknown format
     ^ ImageNotFoundQuerySignal
                 raiseRequestWith:aStream
                 errorString:('Image [warning]: unknown image file format in stream').
@@ -2180,11 +2198,7 @@
     image := aReaderClass fromStream:aStream.
     image notNil ifTrue:[^ image].
 
-    "
-     nope - unknown format
-    "
-"/    'Image [info]: unknown image file format in stream: ' infoPrintCR.
-
+    "/ nope - unknown format
     ^ ImageNotFoundQuerySignal
                 raiseRequestWith:aStream
                 errorString:('Image: unknown image file format in stream').