how to get width and height of image with url?

I use for that some library but it's slowly, I want a fast as possible approach to do that.

thanx.

Accepted Reply

thanx bro for help.

I doing that by FTImageSize ibrary

by function FTImageSize.getImageSizeFromImageURL(url, perferdWidth: widthImageInBuilderInterface).

Replies

Can you show what you do ?


When tyou say it is not fst, what is the impact for the end user ? Will he even notice ?


What about your older posts ? Are they solved ?

I need to adjust image dimensions depend height and width (originals) of image to imageView. when user click on a post, go to other controller show more details about this post, details include image of post that loaded from url. I used IGFastImage library but it's little slowly in fetch header of image and get dimensions.


my posts problems solved, but when navigate between tabbarItems and waitForConnectivity property of session, it's not solved yet. and I communicate with you soon about this proplems.

thanx bro, you always save my day.🙂

So, you need dimensions only when you go to present the detail of one view ?

Why don't you simply call the image size, like this

        print("Image size", theImage.size)


Can you show the code where you load the image ?


For the other threads, don't forget to close them if done.

I want the original dimensions of image with a specific url

like this url of image

let ImageUrl = "https://cdn.dribbble.com/users/230091/screenshots/5983130/img_0031_2x.png"

when I implement the approach I want tell me this:

imageWidth = 800

imageHeigth = 600


try download this image in above url and you will understand what I mean.

thanx.

try download this image in above url and you will understand what I mean.


Trying with code, I cannot understand what you mean.

let imageUrl = URL(string: "...your ImageUrl here...")!
here: do {
    let imageData = try Data(contentsOf: imageUrl) //You should not use this in app
    guard let image = UIImage(data: imageData) else {
        print("The content of the URL cannot be handled as an image")
        break here
    }
    print(image.size) //->(800.0, 600.0)
} catch {
    print(error)
}


If you eventually put the image into an imageView, downloading whole content would not be so bad. You have no need to use such slowly third party framework.

thanx bro for help.

I doing that by FTImageSize ibrary

by function FTImageSize.getImageSizeFromImageURL(url, perferdWidth: widthImageInBuilderInterface).