0

Currently, I am using below to upload an image in Azure blob

  let im:UIImage = catImage[i]
            let imageData = im.pngData()
            blob.upload(from: imageData!, completionHandler:{(NSError) -> Void in
                print( i , "uploaded")

                print(blob.metadata)
                print(i , imageData)
            })

but I am losing image quality because of pngdata(). What else I can use without losing quality.

Soma Sharma
  • 73
  • 15
  • 1
    show the code where you use pngData – Scriptable Jan 09 '19 at 13:44
  • @Scriptable let imageData = im.pngData() // im is an UIImage – Soma Sharma Jan 09 '19 at 17:16
  • it would be much better if you could provide a sample image, or a link to sample image. convert it to data, compare that data size with the result of pngData() in the question. – Scriptable Jan 09 '19 at 17:38
  • @Scriptable have you ever faced above problem? – Soma Sharma Jan 09 '19 at 17:39
  • No, not really. It could be being compressed by the service on Azure that receives the file? (i'm not familiar with Azure blob?) .pngData should return the same quality image – Scriptable Jan 09 '19 at 17:54
  • Not sure what your specific issue is, but Azure has nothing to do with compressed data; blobs are just... objects. It knows nothing of your contents, and doesn't alter *any* contents. Your issue is going to be related to the image library / tools you're working with. – David Makogon Jan 10 '19 at 04:21
  • @Scriptable - Azure Storage does no such thing. Blobs in Azure Storage are just objects. They are never altered from what is sent to / retrieved from them. – David Makogon Jan 10 '19 at 04:22
  • @DavidMakogon I will check once again in my code about the specific issue and will update here – Soma Sharma Jan 10 '19 at 04:53
  • @DavidMakogon please check my edited code. – Soma Sharma Jan 10 '19 at 06:04

2 Answers2

0

Similar question here: UIImage to raw NSData / avoid compression

Trying to save a UIImage without compression.

Dave C
  • 457
  • 3
  • 10
0

It was a problem with my image picker, solved it by picking phasset instead of images directly

Soma Sharma
  • 73
  • 15