@nico_swd: aha, if we use imagecopyresized, we must read image, but my site have a upload module for image, I want to resize those images as soon as visitors upload.
No problem, just read the image like this: $image = imagecreatefromjpeg($_FILES['tmp_name']); PHP: And save it like this: imagejpeg($image, 'path/to/new/location/image.jpg'); PHP: If you need help, you will have to post your code.
You can't create it more directly. The image becomes available after it has been copied to the temp directory. You can't access it anywhere before that.
it's true, I just said that, after it had been copied to tmp directory, I want to resize that tmp image to new location. Your method: 1. Create an image (in memory) from tmp image. 2. Using imagecopyresized to resize image which has been create
That's what my method does. imagejpeg() will save the newly created image in the wanted directory. And the temp file will be deleted after the script finishes its execution. You HAVE to read it in the memory, because you need it in an external library (GD or Imagick) to resize it.
I'll got a few really useful functions which I use all the time on my projects. They will resize images to a certain maximum height (or) width while keeping the ratio. Can also set the quality etc. Also have a function to create square thumbnails. What's your email address and I'll send you them?
use photoshop.. open image then go to Image --> Image size, then resize it and save it as any extension you want
What kind of answer is that. He needs it doing as part of a script not just once. Im sure he knows how to resize an image !!!!!!!
You have ONLY three options: * Use imagecopyresized to resize the image (either after upload or during). * Use on-fly resize which will resize the image but won't actually store it (just bandwidth waste), search google for such functions. * Javascript/PHP resize using width/height attributed. Peace,