0

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

rmaddy
  • 314,917
  • 42
  • 532
  • 579
BalaSREE
  • 3
  • 1

1 Answers1

1

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.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • in the abouve the person has mentioned l;ike, he had done something like that. So i thought there could be an answer for my question . – BalaSREE Nov 18 '14 at 05:57
  • That link is about getting the type of a file, not a UIImage. – rmaddy Nov 18 '14 at 06:01