• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Most efficient way to get the pixel dimensions of a JPG
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Most efficient way to get the pixel dimensions of a JPG


  • Subject: Re: Most efficient way to get the pixel dimensions of a JPG
  • From: "John C. Randolph" <email@hidden>
  • Date: Thu, 6 Jan 2005 15:59:26 -0800

John,

You can just read the dimensions in the header of the JPEG file. No need to decode the pixels. The format is available many places, like here:

http://netghost.narod.ru/gff/graphics/summary/jfif.htm


typedef struct _JFIFHeader { BYTE SOI[2]; /* 00h Start of Image Marker */ BYTE APP0[2]; /* 02h Application Use Marker */ BYTE Length[2]; /* 04h Length of APP0 Field */ BYTE Identifier[5]; /* 06h "JFIF" (zero terminated) Id String */ BYTE Version[2]; /* 07h JFIF Format Revision */ BYTE Units; /* 09h Units used for Resolution */ BYTE Xdensity[2]; /* 0Ah Horizontal Resolution */ BYTE Ydensity[2]; /* 0Ch Vertical Resolution */ BYTE XThumbnail; /* 0Eh Horizontal Pixel Count */ BYTE YThumbnail; /* 0Fh Vertical Pixel Count */ } JFIFHEAD;

So, read sizeof(JFIFHEAD) from the start of the file.

-jcr

On Jan 6, 2005, at 3:46 PM, John Fox wrote:


Hello:

I'm looking for a really fast and memory efficient way to determine the pixel height and width of a JPEG image. Can someone help me with this? Right now I'm creating an NSBitmapImageRep and getting its pixelsWide and pixelsHigh, but there's a lot of overhead for doing this.

Any help greatly appreciated.


John C. Randolph <email@hidden> (408) 974-8819
Sr. Cocoa Software Engineer,
Apple Worldwide Developer Relations
http://developer.apple.com/cocoa/index.html


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Most efficient way to get the pixel dimensions of a JPG (From: John Fox <email@hidden>)

  • Prev by Date: Scrolling a view containing two subviews (NSTextView weirdness)
  • Next by Date: Re: [Newbie] How to make application reappear after a close?
  • Previous by thread: Most efficient way to get the pixel dimensions of a JPG
  • Next by thread: Re: Most efficient way to get the pixel dimensions of a JPG
  • Index(es):
    • Date
    • Thread