Re: Copy of image -> smaller

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




----- Original Message ----- From: "Rabin Vincent" <rabin@xxxxxx>
To: "Gustav Wiberg" <gustav@xxxxxxxxxxxxxx>
Cc: "PHP General" <php-general@xxxxxxxxxxxxx>
Sent: Monday, May 15, 2006 1:35 PM
Subject: Re:  Copy of image -> smaller


On 5/15/06, Gustav Wiberg <gustav@xxxxxxxxxxxxxx> wrote:
[snip]
//What should/could I do here?
//

            //Set new width and height
            //
           $new_width = 100;
           $new_height = 200;
           $tmp_image=imagecreatefromjpeg($toPath . $mfileAdd);
           $width = imagesx($tmp_image);
           $height = imagesy($tmp_image);
           $new_image = imagecreatetruecolor($new_width,$new_height);
            ImageCopyResized($new_image, $tmp_image,0,0,0,0, $new_width,
$new_height, $width, $height);

I can't see anything wrong with this resizing.

            //Grab new image
            ob_start();
            ImageJPEG($new_image);
            $image_buffer = ob_get_contents();
            ob_end_clean();
            ImageDestroy($new_image);
            //Create temporary file and write to it
            $fp = tmpfile();
            fwrite($fp, $image_buffer);
            rewind($fp);

Instead of doing this, you may want to use the filename
argument of ImageJPEG to save the image directly to a file.

            //Upload new image
            $copyTo = 'http://www.ledins.se/test.jpg';
            $conn_id = ftp_connect('<domain>');
            ftp_login($conn_id,'<username for domain>','<password>');
            ftp_fput($conn_id, $copyTo, $fp, FTP_BINARY);

Destination file ($copyTo) is supposed to be a path (eg.
public_html/test.jpg) and not a URL.

Ok! Thanx, that might be the problem! :-)

Best regards
/Gustav Wiberg

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux