On Tue, 29 Mar 2011 03:21:48 +0300, Andre Polykanine wrote:

>My questions are:
>1.  what  are the restrictions of ImageCopyResampled()? Can I make a jpg
>image  from  a jpg one, and a png image from a png one? And what about

Yes, or even a JPEG from a GIF, or a PNG from a JPEG, etc. 

But: imagecopyresampled works on image *resources*, which you create
either as "blank canvases" or by reading from files. In your case, you
want to create a resource from a file (JPEG, PNG, GIF etc.) and another
as a blank canvas into which you will copy the original image, resampled
(or resized). See the examples here:


After the comment "// Resample" it:
* creates a new blank image resource to copy into, i.e. $dst_image
* creates an image by reading a file, i.e. $src_image
* copies with resampling, i.e. from $src_image to $dst_image

>2.  I  don't  need to output the image as the script output, I need to
>upload it as a file (replacing the uploaded larger file). Could I make
>it with fwrite and then copy it to the server? All of the examples give 

You can write the new image to a file using one of these:


NB: see the following comments by tim (at) leethost (dot) com, regarding
performance of imagecopyresampled vs imagecopyresized:


Also check out ImageMagick, if your host provides it (or you can install

Ross McKay, Toronto, NSW Australia
"Let the laddie play wi the knife - he'll learn"
- The Wee Book of Calvin

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to