Re: The bitmap image type from an NSBitmapImageRep?
Re: The bitmap image type from an NSBitmapImageRep?
- Subject: Re: The bitmap image type from an NSBitmapImageRep?
- From: p3consulting <email@hidden>
- Date: Sat, 17 Apr 2004 10:02:25 +0200
Have you check the
- (id)valueForProperty:(NSString *)property
?
The NSFileManger may give you HFSType, with
- (NSDictionary *)fileAttributesAtPath:(NSString *)path
traverseLink:(BOOL)flag
and the NSFileType property of the returned NSDictionary
If this is not sufficient for your needs you can still link to libmagic
to test for the file type before reading it.
(man file, at the end in the AVAILABILITY section you have the ftp
where to download the latest version).
magic_t magicCookie = magic_open( MAGIC_SYMLINK | MAGIC_PRESERVE_ATIME
);
magic_load(magicCookie,
"/usr/share/file/magic:/usr/local/share/file/magic:/opt/local/share/
file/magic");
const char *fileType = magic_file(magicCookie,
my_file_path_name_null_terminated_string);
/* examples
TIFF -> "TIFF image data, big-endian"
(or any variation about the endian of course)
JPEG -> "JPEG image data, JFIF standard 1.02, aspect ratio, 100 x 100"
PICT -> "data"
PSD -> "Adobe Photoshop Image"
of course results depend on the content of magic file on user system
that may be unconvenient for you (problem of consistency of returned
results)
but you can put a magic file of yours in your app bundle and pass the
path to this one
in magic_load instead of the traditional U*ix paths
(and add a better detection of PICT ;) )
*/
magic_close(magicCookie);
Pascal Pochet
email@hidden
Le avr. 16, 2004, ` 00:59, Ondra Cada a icrit :
>
Hi,
>
>
is there a way to obtain the current image type (JPEG, TIFF, GIF,...)
>
from an NSBitmapImageRep, which was created using imageRepWithData:?
>
>
TIA,
>
---
>
Ondra Hada
>
OCSoftware: email@hidden http://www.ocs.cz
>
private email@hidden http://www.ocs.cz/oc
>
>
[demime 0.98b removed an attachment of type
>
application/pkcs7-signature which had a name of smime.p7s]
>
_______________________________________________
>
cocoa-dev mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.