patawic Posted December 26, 2009 Share Posted December 26, 2009 <?php $gamertag = $_GET['gamertag']; $lines = file("http://www.xboxgamercard.net/testing/index.php?gamertag=$gamertag"); $image = imagecreatefrompng("base.png"); $img = imagecreatetruecolor(imagesx($image), imagesy($image)); $watermark = imagecreatefromjpeg("$lines[12]"); $base_width = imagesx($image); $base_height = imagesy($image); $watermark_width = imagesx($watermark); $watermark_height = imagesy($watermark); $dest_x = $base_width - $watermark_width - 0; $dest_y = $base_height - $watermark_height - 0; imagecopy($img, $image, 0, 0, 0, 0, $base_width, $base_height); imagecopy($img, $watermark, $dest_x, $dest_y, 10, 10, $watermark_width, $watermark_height); header ("Content-type: image/png"); Imagepng ($img); imagedestroy($img); ?> Im having an issue with my $lines[12] variable, the url works but there is an unwanted line break at the end of the file. causing this error http://xboxgamercard.net/testing/image.php?gamertag=immunise. how can i fix this. ive tried str_replace and strip_tags Link to comment https://forums.phpfreaks.com/topic/186392-unable-to-remove-line-break/ Share on other sites More sharing options...
rajivgonsalves Posted December 26, 2009 Share Posted December 26, 2009 change this $watermark = imagecreatefromjpeg("$lines[12]"); to $lines[12] = preg_replace("#[\r\n]+#", '', strip_tags($lines[12])); $watermark = imagecreatefromjpeg($lines[12]); Link to comment https://forums.phpfreaks.com/topic/186392-unable-to-remove-line-break/#findComment-984305 Share on other sites More sharing options...
salathe Posted December 26, 2009 Share Posted December 26, 2009 I think you should instead be using the FILE_IGNORE_NEW_LINES flag in your call to file. That will remove the newline from the end of each line in the $lines array. Link to comment https://forums.phpfreaks.com/topic/186392-unable-to-remove-line-break/#findComment-984316 Share on other sites More sharing options...
laffin Posted December 27, 2009 Share Posted December 27, 2009 Myself, I see line 12 empty on every gamertag that I've tried it on. You do know that the array begins with 0 not 1? so it shouldd be $line[11] that you are looking for. you can verify this by using var_dump($line) Link to comment https://forums.phpfreaks.com/topic/186392-unable-to-remove-line-break/#findComment-984329 Share on other sites More sharing options...
patawic Posted December 27, 2009 Author Share Posted December 27, 2009 the code works perfectly fine http://xboxgamercard.net/testing/i patawic i Link to comment https://forums.phpfreaks.com/topic/186392-unable-to-remove-line-break/#findComment-984596 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.