'inline:' can't read from standard input
Posted: 2014-05-27T22:00:48-07:00
Consider the following inline image data: data:,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAD0lEQVR4AQEEAPv/AAAAAAAEAAFlScNgAAAAAElFTkSuQmCC
This works fine:
This does not:
This gives the error messages:
convert: memory allocation failed `-' @ error/inline.c/ReadINLINEImage/160.
convert: no images defined `out.gif' @ error/convert.c/ConvertImageCommand/3106.
As far as I can tell, the issue is that ReadINLINEImage reads chunks of data of size the minimum of (GetBlobSize(image), MagickMaxBufferExtent). GetBlobSize seems to return 0 for some stream types (which makes sense, as the size of stdin isn't necessarily knowable). Given that it tries to allocate and then read chunks of size 0, ReadINLINEImage fails.
I have a patch with what I think is a reasonable solution, but I don't know how to attach it here.
This works fine:
Code: Select all
convert inline:data:,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAD0lEQVR4AQEEAPv/AAAAAAAEAAFlScNgAAAAAElFTkSuQmCC out.gif
Code: Select all
echo -n "data:,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAD0lEQVR4AQEEAPv/AAAAAAAEAAFlScNgAAAAAElFTkSuQmCC" | convert inline:- out.gif
convert: memory allocation failed `-' @ error/inline.c/ReadINLINEImage/160.
convert: no images defined `out.gif' @ error/convert.c/ConvertImageCommand/3106.
As far as I can tell, the issue is that ReadINLINEImage reads chunks of data of size the minimum of (GetBlobSize(image), MagickMaxBufferExtent). GetBlobSize seems to return 0 for some stream types (which makes sense, as the size of stdin isn't necessarily knowable). Given that it tries to allocate and then read chunks of size 0, ReadINLINEImage fails.
I have a patch with what I think is a reasonable solution, but I don't know how to attach it here.