ex.
image.write( "tempfile" )
[Error: Unsupported MIME type: application/octet-stream]
How would you expect it to behave? Write .png, which is lossless, by default?
Without an extension it doesn't know which output image format to write to.
@arminrosu is right. You need to state what kind of image you write to write: PNG, JPEG, BMP.
Right now, the file extension is used to determine what kind you want to write. The method could be extended to allow an explicit MIME type, like this:
image.write( "tempfile", Jimp.MIME_PNG);
Would you want that?
My first thought was that without an extension, it would write using the source image's mime-type.
Either @arminrosu idea of extending the write method to image.write( "tempfile", Jimp.MIME_PNG); or adding an optional mime() method would work.
lenna.resize(256, 256)
.quality(60)
.greyscale()
.mime(Jimp.MIME_PNG) // set optional mime-type
.write("lenna-small");
Thinking about it a bit more, maybe the behaviors should be:
mime() hmm...
ya, maybe #3 is not needed, your call. The ability to optionally set the output mime solve for most cases.
By the way, thumbs up on Jimp and thanks for putting it out there.
Sorry for not getting back sooner. I'm planning on doing a release later in the week. I'll add this issue to the list of issues to be addressed in the release after that.
the work around is to just add ".png" to the file path.
It is a shame to have to add an extension so that the program understands the format that one wants to use.
When storing files on the server, we do not necessarily use extensions because we can do a processing before delivering the file to the client.
how to get the output var name from Jimp
Jimp.read(array).then(function (lenna) {
lenna.resize(256, 256) // resize
.quality(60) // set JPEG quality
.greyscale() // set greyscale
.write("lenna-small"); // save
})
Most helpful comment
@arminrosu is right. You need to state what kind of image you write to write: PNG, JPEG, BMP.
Right now, the file extension is used to determine what kind you want to write. The method could be extended to allow an explicit MIME type, like this:
Would you want that?