Forum Moderators: coopster

Message Too Old, No Replies

Saving(writing) image to disk

         

artie2004

3:29 pm on Apr 20, 2005 (gmt 0)

10+ Year Member



Hi. I have an image that i want to rotate. After rotating it, i want to save(write) it back to my disk. Could someone please show me how to do this? Below are my source code. Thanks.

<?php
// File and rotation
$filename = '/usr/home/prescrip/www/mdsapp/pharmagroup/labels/888515678.png';
// Content type
//header('Content-type: image/png');
// Load
$source = imagecreatefrompng($filename);
// Rotate

$ro = imagerotate($source, 90,0);

imagedestroy($source);

//echo "HERE". $rotate;

// Output

imagepng($ro);

?>

ironik

10:01 pm on Apr 20, 2005 (gmt 0)

10+ Year Member



imagepng() has an extra parameter you can pass that allows you to save to disk:


imagepng($ro, 'path/to/filename.png');

This overrides the output to screen and saves it as the specified file name.

artie2004

4:33 am on Apr 21, 2005 (gmt 0)

10+ Year Member



Thanks ironik!