PhaZZed Posted August 14, 2007 Share Posted August 14, 2007 Greetings, I am writing a small script to convert from .jpg to .gif $filename = $_GET['file']; // always .jpg $type = $_GET['type']; $im = @imagecreatefromjpeg($filename); if ($im === false) { die('Unable to open image'); } if ($type == "gif") { header ('Content-Type: image/gif'); imagegif($im); imagedestroy($im); } This script displays the image on the browser page, whereas I would like to actually have a variable pointing to the relative path, ie. $location = "http://www.xx.com/uploads/image.gif" Any suggestions? I read that imagegif($im,$destination); can be used, but it's giving me errors.. Quote Link to comment https://forums.phpfreaks.com/topic/64812-solved-convert-image-and-save-to-disk/ Share on other sites More sharing options...
PhaZZed Posted August 14, 2007 Author Share Posted August 14, 2007 Solution.. $filename = $_GET['file']; $type = $_GET['type']; $im = @imagecreatefromjpeg($filename); if ($im === false) { die('Unable to open image'); } srand((double)microtime()*1000000); $rand = rand(999999,99999999); $dest = "../temps/" . $rand; if ($type == "gif") { $dest .= ".gif"; imagegif($im,$dest); imagedestroy($im); $filename = $dest; } if ($type == "png") { $dest .= ".png"; imagepng($im,$dest); imagedestroy($im); $filename = $dest; } Quote Link to comment https://forums.phpfreaks.com/topic/64812-solved-convert-image-and-save-to-disk/#findComment-323349 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.