BalaSREE
BalaSREE

Reputation: 3

find the extended file type of a specified file ( JPEG image, TIFF Image, ...) objective c

My question is a very simple one. How can i get the extension type of a UIImage? I can only get the image as UIImage and not as its name. The image can be static, or can be taken from the phone gallery or even from a file path. If someone could do a little help in that, it would be grateful.

-(returnType)functionName : (argument)UIImage

{
// code to get the extension//

return extension(as string)
}

this is how i wish to have it. I tried passing NSData. But either i need to do the JPEG representation or PNG representation. In both case i will either receive a jpeg extension or a png extension. Even if i pass a gif, it will be shown either jpeg or png. :( ... Please help

Upvotes: 0

Views: 392

Answers (1)

rmaddy
rmaddy

Reputation: 318774

Once you have a UIImage you no longer have any concept of an image type.

If you read encoded image data from a file (or other source) into an NSData object you can inspect the data to determine the image's type. But once you have a UIImage you have an abstract image bitmap that has no type.

Remember, a UIImage can be created in memory. It never started out as a file and it never had a specific type. It's just an image. Even if you load a UIImage from a file, any association with the original file is lost. It's not until you choose to convert the UIImage to a specific format do you get a type.

Upvotes: 1

Related Questions