Page 1 of 1

Detecting Image type from raw bytes

Posted: 2014-04-11T10:30:46-07:00
by roflson
In order to speed up my image processing, I use the jpeg:size hint to give the JPEG decoder more efficiency.

However, I don't want to do this blindly. How can I detect an image type from the raw bytes before calling BlobToImage?

I could write code to inspect the header, but I think Imagemagick should be able to do this too?

Re: Detecting Image type from raw bytes

Posted: 2014-04-11T10:59:43-07:00
by fmw42
see string format at http://www.imagemagick.org/script/escape.php

%m image file format (file magic)

Code: Select all

identify -format "%m" yourimage

Re: Detecting Image type from raw bytes

Posted: 2014-04-11T12:19:17-07:00
by roflson
I am doing this in-memory with the MagickCore interface. I need to determine an image type from the raw bytes before calling BlobToImage