1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Resize image from url

Discussion in 'PHP' started by Fracisc, Dec 11, 2017.

  1. #1
    I have a site where I list many images from an external URL. The problem is that those images are huge and take up a lot of loading time. I would like to resize them from the URL, without downloading them to my server.

    Could you please help me out with a PHP script for this?

    Thanks!
     
    Fracisc, Dec 11, 2017 IP
  2. Root Case

    Root Case Greenhorn

    Messages:
    5
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    5
    #2
    Without downloading them, it is impossible to modify them. If you meant saving instead of downloading, that's a different thing and there are multiple options you can choose from (for example PHP built-in functions or ImageMagick).
     
    Root Case, Dec 11, 2017 IP
  3. Fracisc

    Fracisc Well-Known Member

    Messages:
    3,670
    Likes Received:
    10
    Best Answers:
    1
    Trophy Points:
    195
    #3
    Yup, I meant without saving them. They are different extensions so it is harder to display them in a smaller size. At least I don't know how to do that..
     
    Fracisc, Dec 11, 2017 IP
  4. phpmillion

    phpmillion Member

    Messages:
    145
    Likes Received:
    11
    Best Answers:
    4
    Trophy Points:
    45
    #4
    phpmillion, Dec 12, 2017 IP
  5. Softprodigy

    Softprodigy Greenhorn

    Messages:
    5
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    11
    #5
    Other option which I think which you can experiment with resizing the images in the web pages. You can mention the size of the image in the HTML part which will squeeze the images to limited sizes.
     
    Softprodigy, Dec 12, 2017 IP
  6. phpmillion

    phpmillion Member

    Messages:
    145
    Likes Received:
    11
    Best Answers:
    4
    Trophy Points:
    45
    #6
    While it may sound like a possible solution, I would strongly recommend not doing so. First of all, it's the worst possible way to resize image. Second, there will be many situations when this method won't work properly.
     
    phpmillion, Dec 12, 2017 IP
  7. qwikad.com

    qwikad.com Illustrious Member Affiliate Manager

    Messages:
    7,151
    Likes Received:
    1,656
    Best Answers:
    29
    Trophy Points:
    475
    #7
    I used timthumb in the past, now they came up with a secure alternative: https://github.com/mindsharelabs/mthumb

    What it does is it crops images out and significantly reduces their kb sizes. You can adjust the height and width and depending on the images you won't even know they were cropped out. It can be used for both internal and external image links.

    To understand how it works, check out this page: https://www.binarymoon.co.uk/2010/08/timthumb/
     
    qwikad.com, Dec 12, 2017 IP