i want to convert images into any jpg from all other formats in php i am using this function
Edited by Vrythramax - Please the appropriate code tags when pasting code, and also please try to post in the correct forum
-moved- to PHP and MySQL Forum
| Code: |
| <?php
function LoadJpeg($imgname) { $im = @imagecreatefromjpeg($imgname); /* Attempt to open */ if (!$im) { /* See if it failed */ $im = imagecreatetruecolor(150, 30); /* Create a black image */ $bgc = imagecolorallocate($im, 255, 255, 255); $tc = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 150, 30, $bgc); /* Output an errmsg */ imagestring($im, 1, 5, 5, "Error loading $imgname", $tc); } return $im; } header("Content-Type: image/jpeg"); $img = LoadJpeg("bogus.image"); imagejpeg($img); ?> is this true and also tell me more function which convert into other formats following code is for image resizing <?php $new_width = 100; $new_height = 200; $tmp_image=imagecreatefromjpeg($_FILES['gfx']['tmp_name']); $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); //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); //Upload new image $conn_id = ftp_connect('ftp.example.tld'); ftp_login($conn_id,'user','pass'); ftp_fput($conn_id,'path/to/new/file.jpg', $fp, FTP_BINARY); fclose($fp); ?> |
Edited by Vrythramax - Please the appropriate code tags when pasting code, and also please try to post in the correct forum
-moved- to PHP and MySQL Forum
