Page 1 of 1

jpeg types

Posted: 2013-06-22T01:58:29-07:00
by synoptik
Hi,
I found difficult parsing jpeg format, I need take only sizes of images.
I made an app what goes through first 200 bytes of jpeg, that found JFIF header and cant found width or height from double byte values.

Could someone say where I can found examples of different types JPEG's(i.e. many image created by foreign apps)?
Or how that could be when my app can't found width or height on the head of image? I've cheked it with imagemagick and not found similar values, for other jpeg's that works, but I found one or two jpeg images from where I got sizes of picture.

Re: jpeg types

Posted: 2013-06-22T10:25:54-07:00
by fmw42
I don't know of examples of different jpg images, but in IM you can get the size from

convert image.jpg -format "%wx%h" info:

returns:
70x46

Re: jpeg types

Posted: 2013-06-22T21:21:18-07:00
by synoptik
yes, therefor I asks in apropriat forum for that question.
fot jpeg I found sizes from bytes count
Height: 164,163
Width: 166,165
but that different for different types should be and not works for many.

Re: jpeg types

Posted: 2013-06-22T21:29:44-07:00
by fmw42
JPG is compressed. So I do not think you can use the byte count to compute the width and height.

Re: jpeg types

Posted: 2013-06-22T22:39:06-07:00
by synoptik
no, header is not compressed.
as here
Image
for me
Image
real size from IM 1200x718

Re: jpeg types

Posted: 2013-06-24T09:15:14-07:00
by snibgo
Many years ago, I wrote a C-language function to get the dimensions of a JPEG image. I cheated, by simply adapting rdjpcom.c by Thomas G. Lane. I have used this function in my own software for many years, and it has never failed.

My source code is here: https://www.dropbox.com/s/ztnf70oa4vu9m7e/rdjSize.cpp . You might want to read it to understand the process. Note that the dimensions are not guaranteed to be at any particular location in the file. Comments by "ARG" are my own.