jpeg types

Discuss digital image processing techniques and algorithms. We encourage its application to ImageMagick but you can discuss any software solutions here.
Post Reply
synoptik
Posts: 3
Joined: 2013-06-22T01:22:05-07:00
Authentication code: 6789

jpeg types

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: jpeg types

Post 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
synoptik
Posts: 3
Joined: 2013-06-22T01:22:05-07:00
Authentication code: 6789

Re: jpeg types

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: jpeg types

Post by fmw42 »

JPG is compressed. So I do not think you can use the byte count to compute the width and height.
synoptik
Posts: 3
Joined: 2013-06-22T01:22:05-07:00
Authentication code: 6789

Re: jpeg types

Post by synoptik »

no, header is not compressed.
as here
Image
for me
Image
real size from IM 1200x718
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: jpeg types

Post 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.
snibgo's IM pages: im.snibgo.com
Post Reply