Fast way to get Image Info (size, datatype info)
Fast way to get Image Info (size, datatype info)
Is there any way to get image dimensions and datatype data (located usually in image file header) fastly? "ping" function reads whole imagefile into memory and then return this data. This causes significan and not necessary delay...
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Fast way to get Image Info (size, datatype info)
identify <image>
or for more information
identify -verbose info: <image>
or for more information
identify -verbose info: <image>
Re: Fast way to get Image Info (size, datatype info)
Inspecting source I found that "identify" uses "PingImage" internally.
I mean function which read only image header... not a whole imagefile (do not confuse reading with decoding).
I mean function which read only image header... not a whole imagefile (do not confuse reading with decoding).
Re: Fast way to get Image Info (size, datatype info)
PingImage() reads the entire image but throws the pixels away so it is fast and memory efficient. ImageMagick does not have a method to just read an image header but not the pixels.
Re: Fast way to get Image Info (size, datatype info)
"PingImage" is much faster then decoding, but noticable slow then just read header. For example, if jpeg image is 16 megs, delay is significant. Maybe better to have api, which is invariant of image size. Just a suggestion.
For example, usually it is necessary to make some precalculations depending on image size, before really decoding it. The faster way to get image size before docoding, results in more interactive program.
Btw, it is possible to modify current IM code ("ReadImage" fucntion)?
For example, usually it is necessary to make some precalculations depending on image size, before really decoding it. The faster way to get image size before docoding, results in more interactive program.
Btw, it is possible to modify current IM code ("ReadImage" fucntion)?
Re: Fast way to get Image Info (size, datatype info)
JPEG is a special case. Set the image_info->size member to something small like 16x16 and PingImage() will return quickly.