Hi,

Is it possible to resize, crop, and upload an image? I know how to upload images using PHP, but I'm not sure how I would go about resizing and cropping an image that is being uploaded.

Could someone please point me in the right direction.

I appreciate any help. Thanks,
~Oni.

    Thanks mate. I keep getting an error though:

    Fatal error: Call to undefined function imagecreatefromjpeg() in c:\htdocs\bulldogs\resize.php on line 24

    Do you know what the problem is?

      Yup. GD wasn't compiled to accept JPEG images, or it doesn't support it.

      Do a phpinfo() and paste the section on the GD library in here.

        Sorry for being naive, but what section would that be?

          The table with the letters "gd" in big black letters above it. Below the Configuration section, each section is alphabetized, so scroll down a bit.

          EDIT: Here's mine:

          gd
          GD Support  enabled  
          GD Version bundled (2.0.23 compatible)
          FreeType Support enabled
          FreeType Linkage with freetype
          GIF Read Support enabled
          JPG Support enabled
          PNG Support enabled
          WBMP Support enabled
          XBM Support enabled

            I'm testing this on my local machine, so it's possible that it is already set up properly on my host... but on my local machine, I searched the phpinfo page for GD Support, JPG Support, etc. and nothing came up.

              Well, the point was for you to run it on your server so we know what environment we're dealing with, lol...

                Yeah, but I'm running the script on my local machine 🙂 I will be using it on both my local and host.

                  Well, if you want to use it on your local machine, then you'll need to install the GD library. What version of PHP are you using? It might be as simple as finding this:

                  extension=php_gd2.dll

                  in your PHP config file, and uncommenting it.

                    hmmm, I think I'm jsut going to stick with the server 🙂 When I run it on the server I get this error:

                    Warning: imagejpeg(): Unable to open 'thumb_pic/' for writing in...

                    I have changed the CHMOD on the folder to 777 and it still doesn't work.

                      thumb_pic/ ? Looks like you're trying to open a directory, not a file...

                        How right you are... that was very stupid of me. Thanks heaps for your help.
                        If you ever need help with something in Flash (thats if you aren't already an expert) I'd be happy to assist.

                        Cheers,
                        ~Oni.

                          At least it was an easy fix! 😉

                          Don't forget to mark this thread resolved, too.

                            Write a Reply...