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.
jpeg types
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: jpeg types
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
convert image.jpg -format "%wx%h" info:
returns:
70x46
Re: jpeg types
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.
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.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: jpeg types
JPG is compressed. So I do not think you can use the byte count to compute the width and height.
Re: jpeg types
no, header is not compressed.
as here
for me
real size from IM 1200x718
as here
for me
real size from IM 1200x718
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: jpeg types
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.
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.
snibgo's IM pages: im.snibgo.com