Search the Community
Showing results for tags 'image copy'.
-
Hi, I am getting an image URL from an xml feed. I am trying to copy the image from the URL in the XML Feed, then rename & resize it. Its only giving me a black resized block for each image resize... This is driving me nuts. Please look at my script and tell me where am I going wrong? set_time_limit(-1); $imgurl='http://path/to/img_main.jpg'; $pic=$imgurl; $img = $pic; //////// GET IMAGE NAME $url_arr = explode ('/', $pic); $ct = count($url_arr); $name = $url_arr[$ct-1]; $name_div = explode('.', $name); $ct_dot = count($name_div); $img_type = $name_div[$ct_dot -1]; /////// GET IMAGE NAME END $name= str_replace(' ', '_', $name); $im = imagecreatefromjpeg($img); $width = imagesx($im); $height = imagesy($im); $newwidth = '400'; $newheight = '240'; $thumb = imagecreatetruecolor($newwidth, $newheight); imagecopyresized($thumb, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); imagejpeg($thumb,'../ad_images/'.$name); //save image as jpg echo '<img src="../ad_images/'.$name.'"> '; $newwidth1 = '130'; $newheight1 = '98'; $thumb1 = imagecreatetruecolor($newwidth1, $newheight1); imagecopyresized($thumb1, $im, 0, 0, 0, 0, $newwidth1, $newheight1, $width, $height); imagejpeg($thumb1,'../ad_images/130/'.$name); //save image as jpg echo '<img src="../ad_images/130/'.$name.'"> '; $newwidth2 = '65'; $newheight2 = '49'; $thumb2 = imagecreatetruecolor($newwidth2, $newheight2); imagecopyresized($thumb2, $im, 0, 0, 0, 0, $newwidth2, $newheight2, $width, $height); imagejpeg($thumb2,'../ad_images/65/'.$name); //save image as jpg echo '<img src="../ad_images/65/'.$name.'"> <br>'; $dbname=$name; imagedestroy($thumb); imagedestroy($thumb1); imagedestroy($thumb2); imagedestroy($im);