• 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: Getting image info without loading entire image
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting image info without loading entire image


  • Subject: Re: Getting image info without loading entire image
  • From: Ken Tozier <email@hidden>
  • Date: Fri, 19 Jan 2007 19:34:40 -0500


On Jan 19, 2007, at 6:06 PM, Ryan Britton wrote:
Have you looked at CGImageSource?

http://developer.apple.com/documentation/GraphicsImaging/Reference/ CGImageSource/Reference/reference.html

Interesting...

Getting the info through CGImage functions like this

NSURL *url = [NSURL fileURLWithPath: inPath];
CGImageSourceRef srcRef = CGImageSourceCreateWithURL((CFURLRef) url, NULL);
CGImageRef imgRef = CGImageSourceCreateImageAtIndex(srcRef, 0, NULL);


NSDictionary *imgProps = (NSDictionary *) CGImageSourceCopyPropertiesAtIndex(srcRef, 0, NULL),
*srcProps = (NSDictionary *) CGImageSourceCopyProperties(srcRef, NULL);


width		= [imgProps objectForKey: @"PixelWidth"];
height		= [imgProps objectForKey: @"PixelHeight"];

CFRelease(srcRef);
CFRelease(imgRef);
							

is *MUCH* faster than getting the same info through NSImageRep like this.

NSImageRep		*img		= [NSImageRep imageRepWithContentsOfFile: inPath];

if (img != nil)
{
	width		= [NSNumber numberWithInt: [img pixelsWide]],
	height		= [NSNumber numberWithFloat: [img pixelsHigh]];
}


There must be some serious overhead in NSImage classes.

Thanks for the tip Ryan

Ken



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Getting image info without loading entire image
      • From: "Ken Ferry" <email@hidden>
    • Re: Getting image info without loading entire image
      • From: Andrew Farmer <email@hidden>
References: 
 >Getting image info without loading entire image (From: Ken Tozier <email@hidden>)
 >Re: Getting image info without loading entire image (From: Ryan Britton <email@hidden>)

  • Prev by Date: Re: Getting image info without loading entire image
  • Next by Date: Re: Getting image info without loading entire image
  • Previous by thread: Re: Getting image info without loading entire image
  • Next by thread: Re: Getting image info without loading entire image
  • Index(es):
    • Date
    • Thread