6 Replies
      Latest reply on Feb 9, 2019 3:25 AM by BurierA
      BurierA Level 1 Level 1 (0 points)

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

        thanx.

        • Re: how to get width and height of image with url?
          Claude31 Level 8 Level 8 (6,365 points)

          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 ?

            • Re: how to get width and height of image with url?
              BurierA Level 1 Level 1 (0 points)

              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.

                • Re: how to get width and height of image with url?
                  Claude31 Level 8 Level 8 (6,365 points)

                  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.

                    • Re: how to get width and height of image with url?
                      BurierA Level 1 Level 1 (0 points)

                      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.

                        • Re: how to get width and height of image with url?
                          OOPer Level 8 Level 8 (5,225 points)

                          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.