Im using the following extension method to resize an image.When it comes to large resolution images the output size remains 1000x1000 pixels even when I set the output size to 5
The problem is that you are not taking into account the scale of the image you're creating.
You have a Retina screen. When you call lockFocus
and draw into the resulting graphics context, the graphics context has double-resolution. Thus, a size of 500x500 results in an underlying bitmap of 1000x1000. That doesn't matter for purposes of display; to the extent that it does matter, it's a good thing.
But when you proceed to save the image data to disk, you throw away the knowledge that this is a double-resolution image, and you simply save the bitmap — which is 1000x1000.
You should look at Apple's documentation on how to deal with high-resolution images, e.g. https://developer.apple.com/library/content/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/APIs/APIs.html