Hi, I have read somewhere that with PHP you can actually create images from code, like Amazon does for example... is this really possible?

Is there any tutorial about this somewhere?

What I am thinking of doing (I don't know if it is possible) is acquire a picture from an url or from somebody's harddrive and then recreate it with the size I want, is this possible?

    If your system has the GD library installed, you can use PHP to directly create and manipulate images. You can also use PHP to call other image programs on your system like Xnview or ImageMagick.

    Read about GD here
    http://www.php.net/manual/en/ref.image.php

      So is this host dependent? How do I know if my server has this GD thing or these other softwares installed?

        Yes it is host dependent. Just like having PHP at all is host dependent.

        You can use phpinfo() to see if the GD libraries are installed.

          Hey WP, welcome back! Haven't seen you in a while ;-)

          I checked on PHP info and I found this:

          gd
          GD Support enabled
          GD Version 1.6.2 or higher
          FreeType Support enabled
          FreeType Linkage with freetype
          JPG Support enabled
          PNG Support enabled
          WBMP Support enabled

          is this a go ahead?

          I didn't find anything about Xnview or ImageMagick though.

          Also how much would you say is GD support popular among low costs php hosts? I am asking because I wouldn't want to create an application requiring GD support that would make a move to a different server hard in the future.

            yes, this is a go-ahead to create images using the GD libraries.

            However low-cost hosts might not offer this option because it tends to create a lot of load on the servers.

              I'd say you are go for GD on this server. Just note (if it might be an issue) that GD doesn't support GIF for legal reasons.

              The others won't be mentioned here, as they're run as separate applications that you would call from PHP's system functions. There's work on creating an ImageMagick extension to PHP in progress, but that's for the future.

              GD is reasonably well represented among PHP-supporting hosts in my experience, so you shouldn't have too much trouble. If GD Lib isn't installed, then a host who values its patrons may well be willing to install it if asked.

                Actually the manual says:

                The format of images you are able to manipulate depend on the version of GD you install, and any other libraries GD might need to access those image formats. Versions of GD older than gd-1.6 support gif format images, and do not support png, where versions greater than gd-1.6 support png, not gif.

                and then also adds:

                In order to read and write images in jpeg format, you will need to obtain and install jpeg-6b (available at » [url]ftp://ftp.uu.net/graphics/jpeg/[/url]), and then recompile GD to make use of jpeg-6b. You will also have to compile PHP with --with-jpeg-dir=/path/to/jpeg-6b.

                JPEG only is good enough for me.
                I am wondering now. Does anybody know of any script I can download, copy, modify that allows for taking a picture from an URL or from a local drive, reading it and then recreating it in PHP with a new size I specify?

                  Search around, there are plenty of scripts like that on here, and almost a new person asks every week.

                    I have looked on php.resourceindex.com and only found one that encodes images in php... do you know of other good Php script resources where to look?

                      17 days later

                      I am still looking for a script that will grab a picture and re-generate it with the new width and height I specify but I couldn't find any. Can anybody help me please?
                      Marc

                        Write a Reply...