PHP - Black Watermark
hi guys
i need some help i am trying to create a resized image with a watermark, from an uploaded image.. the image is getting uploaded and resized but the watermark doesnt appear correct. instead of a transparent watermark, there's a black square in it's place. this is my code Code: [Select] $tempfile = $_FILES['filename']['tmp_name']; $src = imagecreatefromjpeg($tempfile); list($origWidth, $origHeight) = getimagesize($tempfile); // creating png image of watermark $watermark = imagecreatefrompng('../imgs/watermark.png'); // getting dimensions of watermark image $watermark_width = imagesx($watermark); $watermark_height = imagesy($watermark); // placing the watermark $dest_x = $origWidth / 2 - $watermark_width / 2; $dest_y = $origHeight / 2 - $watermark_height / 2; imagecopyresampled($src, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, $origWidth, $origHeight); imagealphablending($src, true); imagealphablending($watermark, true); imagejpeg($src,$galleryPhotoLocation,100); // $galleryPhotoLocation is correct. the image gets uploaded successfully.. Similar Tutorialsnot sure what i am doing wrong but when i try to call this watermark function i get "query failed" "included failed" errors which doesnt happen unless i call the function. maybe someone can sort out my code so that it uploads the watermark correctly http://www.plus2net.com/php_tutorial/gd-water.php upoad.php <?php include("include/session.php"); $caption = $_POST['caption']; $target_path = "gallery/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); $file_path = basename( $_FILES['uploadedfile']['name']); $file_size = basename( $_FILES['uploadedfile']['size']); $username = $session->username; $time = $session->time; if ($file_size > '4194304'){ //echo 'error '. $file_size; header('Location: gallery.php?id=error'); } else { if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { $location_height=300; // Location of water mark $location_width=300; // Location of water mark $add="gallery/$file_path"; // Source directory location $add2="destination/$file_name"; // Destination directory location $water_img="wtt7.gif"; // Water Image file //echo "The file ". basename( $_FILES['uploadedfile']['name']). //" has been uploaded<br><br>Link: <a href=\"http://www.thetastingroomokc.com/gallery/". basename( $_FILES['uploadedfile']['name']) ."\">http://www.thetastingroomokc.com/gallery/". basename( $_FILES['uploadedfile']['name']) ."</a>"; mysql_query("INSERT INTO gallery VALUES ('', '$username', '$time', '$caption' , '$file_path' )"); //echo $file_size.' is how big your file is. It was transferred.'; header('Location: gallery.php'); } else{ // echo "There was an error uploading the file, please try again!"; } } ?> what am i doing wrong? my watermark function won't work but i am calling the function right i think. if (move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { watermark($file_path,$watermark,'png'); mysql_query("INSERT INTO gallery VALUES ('', '$username', '$time', '$caption' , '$file_path' )"); //echo $file_size.' is how big your file is. It was transferred.'; header('Location: gallery.php'); } Hi I am using this script for water marking images from here http://911-need-code-help.blogspot.com/2008/11/watermark-your-images-with-another.html which works great. I also tried using this resizer here http://911-need-code-help.blogspot.com/2008/10/resize-images-using-phpgd-library.html because it works great too but trying to get both of them to work together wasn't working for me. The 2 codes are very similar and the farthest I got was being able to produce 2 images at the same time "one watermarked and one resized" I could never actually get it to resize and then watermark. I ended up using another piece of code that i found and and it seems to work great for resizing after the image is watermarked but not before. I keep trying to resize it before the watermark and nothing works for me. Anyone know what i can do to achieve this? or get the 2 scripts in the links above to flow together? Here is my working code for watermarking then resizing. //-------------------------------- // CREATE WATERMARK FUNCTION //-------------------------------- define( 'WATERMARK_OVERLAY_IMAGE', 'http://localhost/d.png' ); define( 'WATERMARK_OVERLAY_OPACITY', 70 ); define( 'WATERMARK_OUTPUT_QUALITY', 90 ); function create_watermark( $source_file_path, $output_file_path ) { list( $source_width, $source_height, $source_type ) = getimagesize( $source_file_path ); if ( $source_type === NULL ) { return false; } switch ( $source_type ) { case IMAGETYPE_GIF: $source_gd_image = imagecreatefromgif( $source_file_path ); break; case IMAGETYPE_JPEG: $source_gd_image = imagecreatefromjpeg( $source_file_path ); break; case IMAGETYPE_PNG: $source_gd_image = imagecreatefrompng( $source_file_path ); break; default: return false; } $overlay_gd_image = imagecreatefrompng( WATERMARK_OVERLAY_IMAGE ); $overlay_width = imagesx( $overlay_gd_image ); $overlay_height = imagesy( $overlay_gd_image ); imagecopymerge( $source_gd_image, $overlay_gd_image, floor(($source_width - $overlay_width) / 2), floor(($source_height - $overlay_height) / 2), 0, 0, $overlay_width, $overlay_height, WATERMARK_OVERLAY_OPACITY ); /* Right corner imagecopymerge( $source_gd_image, $overlay_gd_image, $source_width - $overlay_width, $source_height - $overlay_height, 0, 0, $overlay_width, $overlay_height, WATERMARK_OVERLAY_OPACITY ); */ imagejpeg( $source_gd_image, $output_file_path, WATERMARK_OUTPUT_QUALITY ); imagedestroy( $source_gd_image ); imagedestroy( $overlay_gd_image ); } //-------------------------------- // FILE PROCESSING FUNCTION //-------------------------------- define( 'UPLOADED_IMAGE_DESTINATION', '/xampp/htdocs/admin/original/' ); define( 'PROCESSED_IMAGE_DESTINATION', '/xampp/htdocs/images/' ); define( 'THUMBNAIL_IMAGE_DESTINATION', '/xampp/htdocs/images/' ); function process_image_upload( $Field ) { $temp_file_path = $_FILES[ $Field ][ 'tmp_name' ]; $temp_file_name = $_FILES[ $Field ][ 'name' ]; list( , , $temp_type ) = getimagesize( $temp_file_path ); if ( $temp_type === NULL ) { return false; } switch ( $temp_type ) { case IMAGETYPE_GIF: break; case IMAGETYPE_JPEG: break; case IMAGETYPE_PNG: break; default: return false; } $rand=time(); $dash = "-"; $uploaded_file_path = UPLOADED_IMAGE_DESTINATION . $rand . $dash . $temp_file_name; $processed_file_path = PROCESSED_IMAGE_DESTINATION . $rand . $dash . preg_replace( '/\\.[^\\.]+$/', '.jpg', $temp_file_name ); // $uploaded_image_path = UPLOADED_IMAGE_DESTINATION . $temp_image_name; move_uploaded_file( $temp_file_path, $uploaded_file_path ); $result = create_watermark( $uploaded_file_path, $processed_file_path ); //This is where its does the resize.. include 'test.php'; $image = new Resize_Image; $image->new_width = 350; $image->new_height = 350; $image->image_to_resize = "$processed_file_path"; // Full Path to the file $image->ratio = true; // Keep Aspect Ratio? // Name of the new image (optional) - If it's not set a new will be added automatically $image->new_image_name = 'sunset_wallpaper_thumbnail'; //Path where the new image should be saved. If it's not set the script will output the image without saving it $image->save_folder = '/xampp/htdocs/images/'; $process = $image->resize(); if($process['result'] && $image->save_folder) { echo 'The new image ('.$process['new_file_path'].') has been saved.'; } //End of resize if ( $result === false ) { return false; } else { return array( $uploaded_file_path, $processed_file_path ); } } //-------------------------------- // END OF FUNCTIONS //-------------------------------- $result = process_image_upload( 'photo' ); if ( $result === false ) { echo '<br>An error occurred during file processing.'; } else { echo "<h1>Submission Successful</h1>"; echo "You will now be redirected back to the last page you visited. Thanks!"; //echo "<meta http-equiv='refresh' content='2;URL=/admin/'>"; } I want to watermark a simple TEXT line on some images (ie: "SAMPLE") I have successfully created a working code and using imagettftext and the PHP manual, I have summized that the coordinates 0,0 will essentially place the beginning of the text at the top left corner of my image. This would remain the same regardless of the image size or shape. Are there coordinates that will consistently designate the lower-right corner? Do the coordinates change for horizontals and verticals; large files and small?
I want my watermark password field to say password and not be written in all asterisks. I know that this is because I am using type=password on my input field. I'm not sure how to make the type be text while displaying the password in asterisks. You can see the problem on my site at http://network.jasonbiondo.com Here is the code: Code: [Select] <div id="username"> <input id="username-field" class="loginFields" type="text" name="username" title="Username" value="Username" /> <script type="text/javascript"> //<![CDATA[ document.getElementById('username-field').onfocus = function() { if (this.value == 'Username') this.value=''; }; document.getElementById('username-field').onblur = function() { if (this.value == '') this.value = 'Username'; }; //]]> </script> </div> <div id="password"> <input id="password-field" class="loginFields" type="password" name="password" title="Password" value="Password" /> <script type="text/javascript"> //<![CDATA[ document.getElementById('password-field').onfocus = function() { if (this.value == 'Password') this.value=''; }; document.getElementById('password-field').onblur = function() { if (this.value == '') this.value = 'Password'; }; //]]> </script> </div> The web video script that I'm using, and trying to modify, works successfully integrating a watermark in the upper left corner of the video file, (so that when it's downloaded, the watermark stays on the video). In the ffmpeg php file code below, the watermarking starts with this line $watermark_image_full_path = "watermark.png"; at line 275 (out of 504 - about halfway). I am wondering if there might be a way to make the watermark also display briefly in another location on the video again, maybe halfway through, when playing it.
<?php if (IS_LOGGED == false || $pt->config->upload_system != 'on') { $data = array( 'status' => 400, 'error' => 'Not logged in' ); echo json_encode($data); exit(); } else if ($pt->config->ffmpeg_system != 'on') { $data = array( 'status' => 402 ); echo json_encode($data); exit(); } else { $getID3 = new getID3; $featured = ($user->is_pro == 1) ? 1 : 0; $filesize = 0; $error = false; if (PT_IsAdmin() && !empty($_POST['is_movie']) && $_POST['is_movie'] == 1) { if (empty($_POST['movie_title']) || empty($_POST['movie_description']) || empty($_FILES["movie_thumbnail"]) || empty($_POST['stars']) || empty($_POST['producer']) || empty($_POST['country']) || empty($_POST['quality']) || empty($_POST['rating']) || !is_numeric($_POST['rating']) || $_POST['rating'] < 1 || $_POST['rating'] > 10 || empty($_POST['release']) || empty($_POST['category']) || !in_array($_POST['category'], array_keys($pt->movies_categories))) { $error = $lang->please_check_details; } // $cover = getimagesize($_FILES["movie_thumbnail"]["tmp_name"]); // if ($cover[0] > 400 || $cover[1] > 570) { // $error = $lang->cover_size; // } } else{ $request = array(); $request[] = (empty($_POST['title']) || empty($_POST['description'])); $request[] = (empty($_POST['tags']) || empty($_POST['video-thumnail'])); if (in_array(true, $request)) { $error = $lang->please_check_details; } else if (empty($_POST['video-location'])) { $error = $lang->video_not_found_please_try_again; } else if (($pt->config->sell_videos_system == 'on' && $pt->config->who_sell == 'pro_users' && $pt->user->is_pro) || ($pt->config->sell_videos_system == 'on' && $pt->config->who_sell == 'users') || ($pt->config->sell_videos_system == 'on' && $pt->user->admin)) { if (!empty($_POST['set_p_v']) || $_POST['set_p_v'] < 0) { if (!is_numeric($_POST['set_p_v']) || $_POST['set_p_v'] < 0 || (($pt->config->com_type == 0 && $_POST['set_p_v'] <= $pt->config->admin_com_sell_videos)) ) { $error = $lang->video_price_error." ".($pt->config->com_type == 0 ? $pt->config->admin_com_sell_videos : 0); } } } else { $request = array(); $request[] = (!in_array($_POST['video-location'], $_SESSION['uploads']['videos'])); $request[] = (!in_array($_POST['video-thumnail'], $_SESSION['ffempg_uploads'])); $request[] = (!file_exists($_POST['video-location'])); if (in_array(true, $request)) { $error = $lang->error_msg; } } } if (empty($error)) { $file = $duration_file = $getID3->analyze($_POST['video-location']); $duration = '00:00'; if (!empty($file['playtime_string'])) { $duration = PT_Secure($file['playtime_string']); } if (!empty($file['filesize'])) { $filesize = $file['filesize']; } $video_res = (!empty($file['video']['resolution_x'])) ? $file['video']['resolution_x'] : 0; $video_id = PT_GenerateKey(15, 15); $check_for_video = $db->where('video_id', $video_id)->getValue(T_VIDEOS, 'count(*)'); if ($check_for_video > 0) { $video_id = PT_GenerateKey(15, 15); } if (PT_IsAdmin() && !empty($_POST['is_movie']) && $_POST['is_movie'] == 1) { $thumbnail = 'upload/photos/thumbnail.jpg'; if (!empty($_FILES['movie_thumbnail']['tmp_name'])) { $file_info = array( 'file' => $_FILES['movie_thumbnail']['tmp_name'], 'size' => $_FILES['movie_thumbnail']['size'], 'name' => $_FILES['movie_thumbnail']['name'], 'type' => $_FILES['movie_thumbnail']['type'] ); $file_upload = PT_ShareFile($file_info); $thumbnail = PT_Secure($file_upload['filename'], 0); // if (!empty($file_upload['filename'])) { // $thumbnail = PT_Secure($file_upload['filename'], 0); // $upload = PT_UploadToS3($thumbnail); // } } } else{ $thumbnail = PT_Secure($_POST['video-thumnail'], 0); if (file_exists($thumbnail)) { $upload = PT_UploadToS3($thumbnail); } } $category_id = 0; $convert = true; $thumbnail = substr($thumbnail, strpos($thumbnail, "upload"), 120); // ****************************** if (PT_IsAdmin() && !empty($_POST['is_movie']) && $_POST['is_movie'] == 1) { $link_regex = '/(http\:\/\/|https\:\/\/|www\.)([^\ ]+)/i'; $i = 0; preg_match_all($link_regex, PT_Secure($_POST['movie_description']), $matches); foreach ($matches[0] as $match) { $match_url = strip_tags($match); $syntax = '[a]' . urlencode($match_url) . '[/a]'; $_POST['movie_description'] = str_replace($match, $syntax, $_POST['movie_description']); } $data_insert = array( 'title' => PT_Secure($_POST['movie_title']), 'category_id' => PT_Secure($_POST['category']), 'stars' => PT_Secure($_POST['stars']), 'producer' => PT_Secure($_POST['producer']), 'country' => PT_Secure($_POST['country']), 'movie_release' => PT_Secure($_POST['release']), 'quality' => PT_Secure($_POST['quality']), 'duration' => $duration, 'description' => PT_Secure($_POST['movie_description']), 'rating' => PT_Secure($_POST['rating']), 'is_movie' => 1, 'video_id' => $video_id, 'converted' => '2', 'size' => $filesize, 'thumbnail' => $thumbnail, 'user_id' => $user->id, 'time' => time(), 'registered' => date('Y') . '/' . intval(date('m')) ); if (!empty($_POST['buy_price']) && is_numeric($_POST['buy_price']) && $_POST['buy_price'] > 0) { $data_insert['sell_video'] = PT_Secure($_POST['buy_price']); } } else{ $link_regex = '/(http\:\/\/|https\:\/\/|www\.)([^\ ]+)/i'; $i = 0; preg_match_all($link_regex, PT_Secure($_POST['description']), $matches); foreach ($matches[0] as $match) { $match_url = strip_tags($match); $syntax = '[a]' . urlencode($match_url) . '[/a]'; $_POST['description'] = str_replace($match, $syntax, $_POST['description']); } if (!empty($_POST['category_id'])) { if (in_array($_POST['category_id'], array_keys(get_object_vars($pt->categories)))) { $category_id = PT_Secure($_POST['category_id']); } } $video_privacy = 0; if (!empty($_POST['privacy'])) { if (in_array($_POST['privacy'], array(0, 1, 2))) { $video_privacy = PT_Secure($_POST['privacy']); } } $age_restriction = 1; if (!empty($_POST['age_restriction'])) { if (in_array($_POST['age_restriction'], array(1, 2))) { $age_restriction = PT_Secure($_POST['age_restriction']); } } $sub_category = 0; if (!empty($_POST['sub_category_id'])) { $is_found = $db->where('type',PT_Secure($_POST['category_id']))->where('lang_key',PT_Secure($_POST['sub_category_id']))->getValue(T_LANGS,'COUNT(*)'); if ($is_found > 0) { $sub_category = PT_Secure($_POST['sub_category_id']); } } $continents_list = array(); if (!empty($_POST['continents-list'])) { foreach ($_POST['continents-list'] as $key => $value) { if (in_array($value, $pt->continents)) { $continents_list[] = $value; } } } $data_insert = array( 'video_id' => $video_id, 'user_id' => $user->id, 'title' => PT_Secure($_POST['title']), 'description' => PT_Secure($_POST['description']), 'tags' => PT_Secure($_POST['tags']), 'duration' => $duration, 'video_location' => '', 'category_id' => $category_id, 'thumbnail' => $thumbnail, 'time' => time(), 'registered' => date('Y') . '/' . intval(date('m')), 'featured' => $featured, 'converted' => '2', 'size' => $filesize, 'privacy' => $video_privacy, 'age_restriction' => $age_restriction, 'sub_category' => $sub_category, 'geo_blocking' => (!empty($continents_list) ? json_encode($continents_list) : '') ); if (!empty($_POST['set_p_v']) && is_numeric($_POST['set_p_v']) && $_POST['set_p_v'] > 0) { $data_insert['sell_video'] = PT_Secure($_POST['set_p_v']); } if ( ($pt->config->approve_videos == 'on' && !PT_IsAdmin()) || ($pt->config->auto_approve_ == 'no' && $pt->config->sell_videos_system == 'on' && !PT_IsAdmin() && !empty($data_insert['sell_video'])) ) { $data_insert['approved'] = 0; } } // ****************************** $insert = $db->insert(T_VIDEOS, $data_insert); if ($insert) { $delete_files = array(); if (!empty($_SESSION['ffempg_uploads'])) { if (is_array($_SESSION['ffempg_uploads'])) { foreach ($_SESSION['ffempg_uploads'] as $key => $file) { if ($thumbnail != $file) { $delete_files[] = $file; unset($_SESSION['ffempg_uploads'][$key]); } } } } if (!empty($delete_files)) { foreach ($delete_files as $key => $file2) { unlink($file2); } } if (isset($_SESSION['ffempg_uploads'])) { unset($_SESSION['ffempg_uploads']); } $data = array( 'status' => 200, 'video_id' => $video_id, 'link' => PT_Link("watch/$video_id") ); ob_end_clean(); header("Content-Encoding: none"); header("Connection: close"); ignore_user_abort(); ob_start(); header('Content-Type: application/json'); echo json_encode($data); $size = ob_get_length(); header("Content-Length: $size"); ob_end_flush(); flush(); session_write_close(); if (is_callable('fastcgi_finish_request')) { fastcgi_finish_request(); } if ($pt->config->queue_count > 0) { $process_queue = $db->getValue(T_QUEUE,'video_id',$pt->config->queue_count); } if ( (count($process_queue) < $pt->config->queue_count && !in_array($video_id, $process_queue)) || $pt->config->queue_count == 0) { if ($pt->config->queue_count > 0) { $db->insert(T_QUEUE, array('video_id' => $insert, 'video_res' => $video_res, 'processing' => 2)); } $ffmpeg_b = $pt->config->ffmpeg_binary_file; $filepath = explode('.', $_POST['video-location'])[0]; $time = time(); $full_dir = str_replace('ajax', '/', __DIR__); $video_output_full_path_240 = $full_dir . $filepath . "_240p_converted.mp4"; $video_output_full_path_360 = $full_dir . $filepath . "_360p_converted.mp4"; $video_output_full_path_480 = $full_dir . $filepath . "_480p_converted.mp4"; $video_output_full_path_720 = $full_dir . $filepath . "_720p_converted.mp4"; $video_output_full_path_1080 = $full_dir . $filepath . "_1080p_converted.mp4"; $video_output_full_path_2048 = $full_dir . $filepath . "_2048p_converted.mp4"; $video_output_full_path_4096 = $full_dir . $filepath . "_4096p_converted.mp4"; $video_file_full_path = $full_dir . $_POST['video-location']; $watermark_image_full_path = "watermark.png"; // demo Video $video_time = ''; $demo_video = ''; if ($pt->config->demo_video == 'on' && !empty($data_insert['sell_video'])) { $have_demo = false; if (!empty($duration_file['playtime_seconds']) && $duration_file['playtime_seconds'] > 0) { $video_time = round((10 * round($duration_file['playtime_seconds'],0)) / 100,0); $video_time = '-t '.$video_time.' -async 1'; $have_demo = true; } } // demo Video //$shell = shell_exec("$ffmpeg_b -y -i $video_file_full_path -vcodec libx264 -preset {$pt->config->convert_speed} -filter:v scale=426:-2 -crf 26 $video_output_full_path_240 2>&1"); $ffmpegCommand =''.$ffmpeg_b.' -y -i '.$video_file_full_path.' -i '.$watermark_image_full_path.' -filter_complex "overlay=10:10,scale=640:-2" -vcodec libx264 -preset '.$pt->config->convert_speed.' -crf 26 '.$video_output_full_path_240.' 2>&1'; $shell = shell_exec($ffmpegCommand); $upload_s3 = PT_UploadToS3($filepath . "_240p_converted.mp4"); $db->where('id', $insert); $db->update(T_VIDEOS, array( 'converted' => 1, '240p' => 1, 'video_location' => $filepath . "_240p_converted.mp4" )); if ($pt->config->queue_count > 0) { $db->where('video_id',$insert)->delete(T_QUEUE); } if ($video_res >= 3840) { //$shell = shell_exec("$ffmpeg_b -y -i $video_file_full_path -vcodec libx264 -preset {$pt->config->convert_speed} -filter:v scale=3840:-2 -crf 26 $video_output_full_path_4096 2>&1"); $ffmpegCommand =''.$ffmpeg_b.' -y -i '.$video_file_full_path.' -i '.$watermark_image_full_path.' -filter_complex "overlay=10:10,scale=640:-2" -vcodec libx264 -preset '.$pt->config->convert_speed.' -crf 26 '.$video_output_full_path_4096.' 2>&1'; $shell = shell_exec($ffmpegCommand); $upload_s3 = PT_UploadToS3($filepath . "_4096p_converted.mp4"); $db->where('id', $insert); $db->update(T_VIDEOS, array( '4096p' => 1 )); // demo Video if ($pt->config->demo_video == 'on' && empty($demo_video) && $have_demo == true) { $demo_video = substr($filepath, 0,strpos($filepath, '_video') - 10).sha1(time()). "_video_4096p_demo.mp4"; $shell = shell_exec("$ffmpeg_b $video_time -y -i $video_file_full_path -vcodec libx264 -preset {$pt->config->convert_speed} -filter:v scale=3840:-2 -crf 26 ".$full_dir . $demo_video." 2>&1"); $upload_s3 = PT_UploadToS3($demo_video); $db->where('id', $insert); $db->update(T_VIDEOS, array( 'demo' => $demo_video )); } // demo Video } if ($video_res >= 2048) { //$shell = shell_exec("$ffmpeg_b -y -i $video_file_full_path -vcodec libx264 -preset {$pt->config->convert_speed} -filter:v scale=2048:-2 -crf 26 $video_output_full_path_2048 2>&1"); $ffmpegCommand =''.$ffmpeg_b.' -y -i '.$video_file_full_path.' -i '.$watermark_image_full_path.' -filter_complex "overlay=10:10,scale=640:-2" -vcodec libx264 -preset '.$pt->config->convert_speed.' -crf 26 '.$video_output_full_path_2048.' 2>&1'; $shell = shell_exec($ffmpegCommand); $upload_s3 = PT_UploadToS3($filepath . "_2048p_converted.mp4"); $db->where('id', $insert); $db->update(T_VIDEOS, array( '2048p' => 1 )); // demo Video if ($pt->config->demo_video == 'on' && empty($demo_video) && $have_demo == true) { $demo_video = substr($filepath, 0,strpos($filepath, '_video') - 10).sha1(time()) . "_video_2048p_demo.mp4"; $shell = shell_exec("$ffmpeg_b $video_time -y -i $video_file_full_path -vcodec libx264 -preset {$pt->config->convert_speed} -filter:v scale=2048:-2 -crf 26 ".$full_dir . $demo_video." 2>&1"); $upload_s3 = PT_UploadToS3($demo_video); $db->where('id', $insert); $db->update(T_VIDEOS, array( 'demo' => $demo_video )); } // demo Video } if ($video_res >= 1920 || $video_res == 0) { //$shell = shell_exec("$ffmpeg_b -y -i $video_file_full_path -vcodec libx264 -preset {$pt->config->convert_speed} -filter:v scale=1920:-2 -crf 26 $video_output_full_path_1080 2>&1"); $ffmpegCommand =''.$ffmpeg_b.' -y -i '.$video_file_full_path.' -i '.$watermark_image_full_path.' -filter_complex "overlay=10:10,scale=640:-2" -vcodec libx264 -preset '.$pt->config->convert_speed.' -crf 26 '.$video_output_full_path_1080.' 2>&1'; $shell = shell_exec($ffmpegCommand); $upload_s3 = PT_UploadToS3($filepath . "_1080p_converted.mp4"); $db->where('id', $insert); $db->update(T_VIDEOS, array( '1080p' => 1 )); // demo Video if ($pt->config->demo_video == 'on' && empty($demo_video) && $have_demo == true) { $demo_video = substr($filepath, 0,strpos($filepath, '_video') - 10).sha1(time()) . "_video_1080p_demo.mp4"; $shell = shell_exec("$ffmpeg_b $video_time -y -i $video_file_full_path -vcodec libx264 -preset {$pt->config->convert_speed} -filter:v scale=1920:-2 -crf 26 ".$full_dir . $demo_video." 2>&1"); $upload_s3 = PT_UploadToS3($demo_video); $db->where('id', $insert); $db->update(T_VIDEOS, array( 'demo' => $demo_video )); } // demo Video } if ($video_res >= 1280 || $video_res == 0) { //$shell = shell_exec("$ffmpeg_b -y -i $video_file_full_path -vcodec libx264 -preset {$pt->config->convert_speed} -filter:v scale=1280:-2 -crf 26 $video_output_full_path_720 2>&1"); $ffmpegCommand =''.$ffmpeg_b.' -y -i '.$video_file_full_path.' -i '.$watermark_image_full_path.' -filter_complex "overlay=10:10,scale=640:-2" -vcodec libx264 -preset '.$pt->config->convert_speed.' -crf 26 '.$video_output_full_path_720.' 2>&1'; $shell = shell_exec($ffmpegCommand); $upload_s3 = PT_UploadToS3($filepath . "_720p_converted.mp4"); $db->where('id', $insert); $db->update(T_VIDEOS, array( '720p' => 1 )); // demo Video if ($pt->config->demo_video == 'on' && empty($demo_video) && $have_demo == true) { $demo_video = substr($filepath, 0,strpos($filepath, '_video') - 10).sha1(time()) . "_video_720p_demo.mp4"; $shell = shell_exec("$ffmpeg_b $video_time -y -i $video_file_full_path -vcodec libx264 -preset {$pt->config->convert_speed} -filter:v scale=1280:-2 -crf 26 ".$full_dir . $demo_video." 2>&1"); $upload_s3 = PT_UploadToS3($demo_video); $db->where('id', $insert); $db->update(T_VIDEOS, array( 'demo' => $demo_video )); } // demo Video } if ($video_res >= 854 || $video_res == 0) { //$shell = shell_exec("$ffmpeg_b -y -i $video_file_full_path -vcodec libx264 -preset {$pt->config->convert_speed} -filter:v scale=854:-2 -crf 26 $video_output_full_path_480 2>&1"); $ffmpegCommand =''.$ffmpeg_b.' -y -i '.$video_file_full_path.' -i '.$watermark_image_full_path.' -filter_complex "overlay=10:10,scale=640:-2" -vcodec libx264 -preset '.$pt->config->convert_speed.' -crf 26 '.$video_output_full_path_480.' 2>&1'; $shell = shell_exec($ffmpegCommand); $upload_s3 = PT_UploadToS3($filepath . "_480p_converted.mp4"); $db->where('id', $insert); $db->update(T_VIDEOS, array( '480p' => 1 )); // demo Video if ($pt->config->demo_video == 'on' && empty($demo_video) && $have_demo == true) { $demo_video = substr($filepath, 0,strpos($filepath, '_video') - 10).sha1(time()) . "_video_480p_demo.mp4"; $shell = shell_exec("$ffmpeg_b $video_time -y -i $video_file_full_path -vcodec libx264 -preset {$pt->config->convert_speed} -filter:v scale=854:-2 -crf 26 ".$full_dir . $demo_video." 2>&1"); $upload_s3 = PT_UploadToS3($demo_video); $db->where('id', $insert); $db->update(T_VIDEOS, array( 'demo' => $demo_video )); } // demo Video } if ($video_res >= 640 || $video_res == 0) { // $shell = shell_exec("$ffmpeg_b -y -i $video_file_full_path -vcodec libx264 -preset {$pt->config->convert_speed} -filter:v scale=640:-2 -crf 26 $video_output_full_path_360 2>&1"); $ffmpegCommand =''.$ffmpeg_b.' -y -i '.$video_file_full_path.' -i '.$watermark_image_full_path.' -filter_complex "overlay=10:10,scale=640:-2" -vcodec libx264 -preset '.$pt->config->convert_speed.' -crf 26 '.$video_output_full_path_360.' 2>&1'; $shell = shell_exec($ffmpegCommand); $upload_s3 = PT_UploadToS3($filepath . "_360p_converted.mp4"); $db->where('id', $insert); $db->update(T_VIDEOS, array( '360p' => 1, )); // demo Video if ($pt->config->demo_video == 'on' && empty($demo_video) && $have_demo == true) { $demo_video = substr($filepath, 0,strpos($filepath, '_video') - 10).sha1(time()) . "_video_360p_demo.mp4"; $shell = shell_exec("$ffmpeg_b $video_time -y -i $video_file_full_path -vcodec libx264 -preset {$pt->config->convert_speed} -filter:v scale=640:-2 -crf 26 ".$full_dir . $demo_video." 2>&1"); $upload_s3 = PT_UploadToS3($demo_video); $db->where('id', $insert); $db->update(T_VIDEOS, array( 'demo' => $demo_video )); } // demo Video } // demo Video if ($pt->config->demo_video == 'on' && empty($demo_video) && $have_demo == true) { $demo_video = substr($filepath, 0,strpos($filepath, '_video') - 10).sha1(time()) . "_video_240p_demo.mp4"; $shell = shell_exec("$ffmpeg_b $video_time -y -i $video_file_full_path -vcodec libx264 -preset {$pt->config->convert_speed} -filter:v scale=426:-2 -crf 26 ".$full_dir . $demo_video." 2>&1"); $upload_s3 = PT_UploadToS3($demo_video); $db->where('id', $insert); $db->update(T_VIDEOS, array( 'demo' => $demo_video )); } // demo Video if (file_exists($_POST['video-location'])) { unlink($_POST['video-location']); } pt_push_channel_notifiations($video_id); $_SESSION['uploads'] = array(); } else{ $db->insert(T_QUEUE, array('video_id' => $insert, 'video_res' => $video_res, 'processing' => 0)); $db->where('id', $insert); $db->update(T_VIDEOS, array( 'video_location' => $_POST['video-location'] )); } exit(); } } else { $data = array( 'status' => 400, 'message' => $error_icon . $error ); } } Any guidance with this is appreciated Hello everyone. I have a report generator for my database and for some reason it is putting a watermark of our company logo in the middle of each page. I have attached the code for the beginning of the script that makes the PDF generator work. Maybe you can find where it should be removed because I am not finding it.
<style> table{ display: table; border-collapse: collapse; border:1.5px solid #74b9f0; font-size: 12.5px; width:100%; } .no_border tr,td{ border:none; border:hidden; /* background:none; */ border:1.5px solid white; } table tr:nth-child(even) { /*(even) or (2n 0)*/ background: #f1f6ff; } table tr:nth-child(odd) { /*(odd) or (2n 1)*/ background: white; } th{text-align:left;font-weight:normal;color:#990a10;width:110px;border:0.4px solid #74b9f0;height:24px;} .title{color:black;} td{border:0.4px solid #74b9f0;height:24px;} .label{text-align:left;font-weight:normal;color:#990a10;width:110px;height:24px;} </style> <?php $StudentInfo = StudentInfo::model()->findByPk($student_transaction[0]->student_transaction_student_id); $AcademicTermPeriod = AcademicTermPeriod::model()->findByPk($student_transaction[0]->academic_term_period_id); $AcademicTerm = AcademicTerm::model()->findByPk($student_transaction[0]->academic_term_id); if($student_transaction[0]->student_transaction_nationality_id != null) $Nationality = Nationality::model()->findByPk($student_transaction[0]->student_transaction_nationality_id); else $Nationality = new Nationality; $Batch = Batch::model()->findByPk($student_transaction[0]->student_transaction_batch_id); $Course = Course::model()->findByPk($student_transaction[0]->course_id); if($student_transaction[0]->student_transaction_languages_known_id != null) $LanguagesKnown = LanguagesKnown::model()->findByPk($student_transaction[0]->student_transaction_languages_known_id); if($student_transaction[0]->student_transaction_student_address_id != null) $StudentAddress = StudentAddress::model()->findByPk($student_transaction[0]->student_transaction_student_address_id); else $StudentAddress = new StudentAddress; if($student_transaction[0]->student_transaction_parent_id != null || $student_transaction[0]->student_transaction_parent_id != 0) $parent = ParentLogin::model()->findByPk($student_transaction[0]->student_transaction_parent_id); else $parent = new ParentLogin; ?> <h3 class="title">CALL RECORDS SUMMARY</h3> <table class="no_border"> </table> I've got a script that auto-puts watermark on images code: Code: [Select] <?php //get stuff $src = $_SERVER['DOCUMENT_ROOT'].'/'.$_GET['src']; $watermarkSRC = 'img/wm.png'; header('Content-type: image/jpeg'); //create watermark $watermark = imagecreatefrompng($watermarkSRC); //wm dimensions $watermark_width = imagesx($watermark); $watermark_height = imagesy($watermark); $image = imagecreatetruecolor($watermark_width, $watermark_height); //border $border=25; //some crappy logic if(strpos($src,'.gif') !== false) { $image = imagecreatefromgif($src); } elseif(strpos($src,'.jpeg') !== false || strpos($src,'.jpg') !== false) { $image = imagecreatefromjpeg($src); } elseif(strpos($src,'.png') !== false) { $image = imagecreatefrompng($src); } else { exit("Your image is not a gif, jpeg or png image. Sorry."); } //image dimensions $width=ImageSx($image); $height=ImageSy($image); //lets make a border $img_adj_height=$height+$border; $square=imagecreatetruecolor($width,$img_adj_height); //border + image imagecopyresampled($square, $image, 0, 0, 0, 0, $width, $img_adj_height, $width, $img_adj_height); //watermark placement $dest_x = $width - $watermark_width - 5; $dest_y = $img_adj_height - $watermark_height - 5; //border + watermark imagecolortransparent($watermark,imagecolorat($watermark,0,0)); imagecopyresampled($square, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, $watermark_width, $watermark_height); //wrap up imagejpeg($square, "", 100); imagedestroy($image); imagedestroy($watermark); ?> and I want to change it so the watermark will be in a border with the transparent or white background instead of black how can I do that? This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=319561.0 I had a similar posting regarding positioning of a 2nd watermark on an uploaded video. I have resoled that successfully - thanks again for the help. Now, the watermarks look clear/sharp on a small screen, but when the screen is enlarged the images don't seem as sharp/clear. What is the trick? Solution? Is it to have a large image to begin with? The watermark.png currently is 98px w by 16px h. Here is a portion of the file code:
$watermark_image_full_path = "watermark.png"; // demo Video $video_time = ''; $demo_video = ''; if ($pt->config->demo_video == 'on' && !empty($data_insert['sell_video'])) { $have_demo = false; if (!empty($duration_file['playtime_seconds']) && $duration_file['playtime_seconds'] > 0) { $video_time = round((10 * round($duration_file['playtime_seconds'],0)) / 100,0); $video_time = '-t '.$video_time.' -async 1'; $have_demo = true; } } // demo Video $ffmpegCommand =''.$ffmpeg_b.' -y -i '.$video_file_full_path.' -i '.$watermark_image_full_path.' -i '.$watermark_image_full_path.' -filter_complex "scale=640:-2, scale=640:-2, overlay=10:10, overlay=170:170:enable=between(t\,5\,5+2)" -vcodec libx264 -preset '.$pt->config->convert_speed.' -crf 26 '.$video_output_full_path_240.' 2>&1'; $shell = shell_exec($ffmpegCommand); $upload_s3 = PT_UploadToS3($filepath . "_240p_converted.mp4"); $db->where('id', $insert); $db->update(T_VIDEOS, array( 'converted' => 1, '240p' => 1, 'video_location' => $filepath . "_240p_converted.mp4" )); if ($pt->config->queue_count > 0) { $db->where('video_id',$insert)->delete(T_QUEUE); } if ($video_res >= 3840) { $ffmpegCommand =''.$ffmpeg_b.' -y -i '.$video_file_full_path.' -i '.$watermark_image_full_path.' -i '.$watermark_image_full_path.' -filter_complex "scale=640:-2, scale=640:-2, overlay=10:10, overlay=170:170:enable=between(t\,5\,5+2)" -vcodec libx264 -preset '.$pt->config->convert_speed.' -crf 26 '.$video_output_full_path_4096.' 2>&1'; $shell = shell_exec($ffmpegCommand); $upload_s3 = PT_UploadToS3($filepath . "_4096p_converted.mp4"); $db->where('id', $insert); $db->update(T_VIDEOS, array( '4096p' => 1 )); // demo Video if ($pt->config->demo_video == 'on' && empty($demo_video) && $have_demo == true) { $demo_video = substr($filepath, 0,strpos($filepath, '_video') - 10).sha1(time()). "_video_4096p_demo.mp4"; $shell = shell_exec("$ffmpeg_b $video_time -y -i $video_file_full_path -vcodec libx264 -preset {$pt->config->convert_speed} -filter:v scale=3840:-2 -crf 26 ".$full_dir . $demo_video." 2>&1"); $upload_s3 = PT_UploadToS3($demo_video); $db->where('id', $insert); $db->update(T_VIDEOS, array( 'demo' => $demo_video )); } // demo Video } if ($video_res >= 2048) { $ffmpegCommand =''.$ffmpeg_b.' -y -i '.$video_file_full_path.' -i '.$watermark_image_full_path.' -i '.$watermark_image_full_path.' -filter_complex "scale=640:-2, scale=640:-2, overlay=10:10, overlay=170:170:enable=between(t\,5\,5+2)" -vcodec libx264 -preset '.$pt->config->convert_speed.' -crf 26 '.$video_output_full_path_2048.' 2>&1'; $shell = shell_exec($ffmpegCommand); $upload_s3 = PT_UploadToS3($filepath . "_2048p_converted.mp4"); $db->where('id', $insert); $db->update(T_VIDEOS, array( '2048p' => 1 )); // demo Video if ($pt->config->demo_video == 'on' && empty($demo_video) && $have_demo == true) { $demo_video = substr($filepath, 0,strpos($filepath, '_video') - 10).sha1(time()) . "_video_2048p_demo.mp4"; $shell = shell_exec("$ffmpeg_b $video_time -y -i $video_file_full_path -vcodec libx264 -preset {$pt->config->convert_speed} -filter:v scale=2048:-2 -crf 26 ".$full_dir . $demo_video." 2>&1"); $upload_s3 = PT_UploadToS3($demo_video); $db->where('id', $insert); $db->update(T_VIDEOS, array( 'demo' => $demo_video )); } // demo Video } if ($video_res >= 1920 || $video_res == 0) { $ffmpegCommand =''.$ffmpeg_b.' -y -i '.$video_file_full_path.' -i '.$watermark_image_full_path.' -i '.$watermark_image_full_path.' -filter_complex "scale=640:-2, scale=640:-2, overlay=10:10, overlay=170:170:enable=between(t\,5\,5+2)" -vcodec libx264 -preset '.$pt->config->convert_speed.' -crf 26 '.$video_output_full_path_1080.' 2>&1'; $shell = shell_exec($ffmpegCommand); any assistance is appreciated Hi there, Can you guys/girls tell me if this is even possible: - take pictures with eye-fi card in the camera, which uploads the images to a server - on the server, automatically add a watermark, and post them on 3 different facebookpages Hi Guys, I'm going to try and watermark my uploaded images with a small logo (placed onto the original image) so they are all watermarked, is there any tutorials anyone can recommend to do this? i can't seem to find any online. thanks for any help guys Graham Right now users log in and upload an image to the website. I want every image that is uploaded to be watermarked with a particular logo. Is this possible? Any hints or tips will be appreciated. Thank you. Hi all, can anyone see why my function is not running? im not getting the form output now. Code: [Select] <?php /* NEW.PHP Allows user to create a new entry in the database */ // creates the new record form // since this form is used multiple times in this file, I have made it a function that is easily reusable function renderForm($Name, $Rank, $error) { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>New Record</title> <link rel="stylesheet" href="style.css" type="text/css" /> </head> <body> <div id="wrapper"> <p> <?php // if there are any errors, display them if ($error != '') { echo '<div style="padding:4px; border:1px solid red; color:red;">'.$error.'</div>'; } ?> </p> <p> </p> <form action="" method="post"> <div> <table width="842" border="0" class="styletable" style="border: 1px solid #000000"> <tr> <td width="255"><strong>Name: *</strong></td> <td width="577"><input type="text" name="Name" value="<?php echo $Name; ?>" /></td> </tr> <tr> <td><strong>Rank:</strong></td> <td><input type="text" name="Rank" value="<?php echo $Rank; ?>" /></td> </tr> <tr> <td><strong>Contact Email: *</strong></td> <td><input type="text" name="ContactEmail" value="<?php echo $ContactEmail; ?>" /></td> </tr> <tr> <td><strong>Website: (omitting http://)</strong></td> <td><input type="text" name="Website" value="<?php echo $Website; ?>" /></td> </tr> <tr> <td><strong>Location:</strong></td> <td><select name="Location" id="Location"> <option value="East Midlands">East Midlands</option> <option value="East Of England">East Of England</option> <option value="Greater London">Greater London</option> <option value="North East England">North East England</option> <option value="North West England">North West England</option> <option value="South East England">South East England</option> <option value="South West England">Soth West England</option> <option value="West Midlands">West Midlands</option> <option value="Yorkshire And The Humber">Yorkshire And The Humber</option> </select> </td> </tr> <tr> <td><strong>Bio:</strong></td> <td><textarea name="BIO" id="BIO" cols="60" rows="5"></textarea></td> </tr> <tr> <td> </td> <td> </td> </tr> </table> <p>* required</p> <input type="submit" name="submit" value="Submit"> <a href="view.php">Cancel - View Records</a> </div> </form> </div> </body> </html> <?php } // connect to the database include('../connect-db.php'); // check if the form has been submitted. If it has, start to process the form and save it to the database if (isset($_POST['submit'])) { // get form data, making sure it is valid $Name = mysql_real_escape_string(htmlspecialchars($_POST['Name'])); $Rank = mysql_real_escape_string(htmlspecialchars($_POST['Rank'])); $ContactEmail = mysql_real_escape_string(htmlspecialchars($_POST['ContactEmail'])); $Website = mysql_real_escape_string(htmlspecialchars($_POST['Website'])); $Location = mysql_real_escape_string(htmlspecialchars($_POST['Location'])); $BIO = mysql_real_escape_string(htmlspecialchars($_POST['BIO'])); // check to make sure both fields are entered if ($Name == '' || $ContactEmail == '') { // generate error message $error = 'ERROR: Please fill in all required fields!'; // if either field is blank, display the form again renderForm($Name, $Rank, $error); } else { // save the data to the database mysql_query("INSERT members SET Name='$Name', Rank='$Rank',ContactEmail='$ContactEmail', Website='$Website', Location='$Location', BIO='$BIO'") or die(mysql_error()); // once saved, redirect back to the view page header("Location: view.php"); // if the form hasn't been submitted, display the form } renderForm('','',''); } ?> hey im new to this web site im looking for some help with my code its suppose to be a black jack game im trying to make an array that can hold the value of the cards once the person presses the hit me button please help me i havent fully develop code yet so you can ignore the comments code if you like thanks for looking at it. Code: [Select] <html> <head> <title>poker dice</title> <style type = "text/css"> body { background: green; color: tan; } </style> </head> <body> <center> <h1>Poker Dice</h1> <form> <? $number = $_REQUEST["number"]; $statue = $_REQUEST["statue"]; $number2 = unserialize(urldecode($number)); //check to see if this is first time on the page. if ($statue == null){ if ((!$cash) && (!$card_counter)){ Print "You will start out with a value of 100 dollars and points of 0."; $cash = 100; $card_counter = 0; } // end if Cards($number); printPage(); }else if($statue == 1){ Cards2($number); printPage(); // print "this is the second page"; }else if($statue == 2){ Cards3($number); printPage(); // print "this is the second page"; }else if($statue == 3){ Cards4($number); printPage(); // print "this is the second page"; }else if($statue == 4){ Cards5($number); printPage(); // print "this is the second page"; }else if($statue == 5){ Cards6($number); printPage(); // print "this is the second page"; }else if($statue == 6){ Cards7($number); printPage(); // print "this is the second page"; }else if($statue == 7){ Cards8($number); printPage(); // print "this is the second page"; }else{ Cards9($number); printPage(); // print "this is the second page"; } //rollDice(); if ($secondRoll == TRUE){ print "<h2>Second roll</h2>\n"; $secondRoll = FALSE; evaluate(); } else { print "<h2>First roll</h2>\n"; $secondRoll = TRUE; } // end if printStuff(); function Cards($number){ $Diamonds = array( "Ace of Diamonds", "Two of Diamonds", "Three of Diamonds", "Four of Diamonds", "Five of Diamonds", "Six of Diamonds", "Seven of Diamonds", "Eight of Diamonds", "Nine of Diamonds", "Ten of Diamonds", "Jack of Diamonds", "Queen of Diamonds", "King of Diamonds"); $Clubs = array( "Ace of Clubs", "Two of Clubs", "Three of Clubs", "Four of Clubs", "Five of Clubs", "Six of Clubs", "Seven of Clubs", "Eight of Clubs", "Nine of Clubs", "Ten of Clubs", "Jack of Clubs", "Queen of Clubs", "King of Clubs"); $Hearts = array( "Ace of Hearts", "Two of Hearts", "Three of Hearts", "Four of Hearts", "Five of Hearts", "Six of Hearts", "Seven of Hearts", "Eight of Hearts", "Nine of Hearts", "Ten of Hearts", "Jack of Hearts", "Queen of Hearts", "King of Hearts"); $Spades = array( "Ace of Spades", "Two of Spades", "Three of Spades", "Four of Spades", "Five of Spades", "Six of Spades", "Seven of Spades", "Eight of Spades", "Nine of Spades", "Ten of Spades", "Jack of Spades", "Queen of Spades", "King of Spades"); $Cards = array_merge($Diamonds, $Clubs); $Cards = array_merge($Cards, $Hearts); $Cards = array_merge($Cards, $Spades); //$Deck = shuffle($Cards); $num1 = rand(1,52); $num2 = rand(1,52); echo $Cards[$num1]; //echo " ____ "; echo $Cards[$num2]; // }else{ // echo "There is no cards being displayed."; // }//close second if statement // }//close first if statement $cards_array[0] = $Cards[$num1]; $cards_array[1] = $Cards[$num2]; //it take the object of a string and pass it as a array. $serialCards = urlencode(serialize($cards_array)); print_r($cards_array); print "<br>"; print $serialCards; print $cards_array[0]; print $cards_array[1]; print <<<HERE </tr></td> <tr> <td colspan = "5"> <center> <form methods = "post" action = "PokerFinal.php"> <input type = "submit" value = "Hit Me"> <input type = "hidden" name = "number" value = "$serialCards"> <input type ="hidden" name ="statue" value = "1"> </form> </center> </td> </tr> </table> HERE; print <<<HERE </tr></td> <tr> <td colspan = "5"> <center> <input type = "submit" value = "roll again"> </center> </td> </tr> </table> HERE; // by using the number and requestinh it will store the value of that array. //it good using a hidden box for this method. //if ($Deck[$num1] == TRUE || $Deck[$num2] == TRUE) { //} //$CurrentHand = $Deck[$num1]; //$Deck = explode(",",$CurrentHand[0]); //$Hit = array_shift($Deck); //$Cards = implode(",",$Deck); //if (isset($CurrentHand[1])) // $PlayersHand = explode("~", $CurrentHand[1]); //$PlayersHand[] = $Hit; //$CardCount = 0; /*$Aces = 0; for ($i=0; $i<count($PlayersHand); ++$i) { if (strpos($PlayersHand[$i], "Ace") !== FALSE) ++$Aces; else if (strpos($PlayersHand[$i], "Two") !== FALSE) $CardCount += 2; else if (strpos($PlayersHand[$i], "Three") !== FALSE) $CardCount += 3; else if (strpos($PlayersHand[$i], "Four") !== FALSE) $CardCount += 4; else if (strpos($PlayersHand[$i], "Five") !== FALSE) $CardCount += 5; else if (strpos($PlayersHand[$i], "Six") !== FALSE) $CardCount += 6; else if (strpos($PlayersHand[$i], "Seven") !== FALSE) $CardCount += 7; else if (strpos($PlayersHand[$i], "Eight") !== FALSE) $CardCount += 8; else if (strpos($PlayersHand[$i], "Nine") !== FALSE) $CardCount += 9; else if (strpos($PlayersHand[$i], "Ten") !== FALSE) $CardCount += 10; else if (strpos($PlayersHand[$i], "Jack") !== FALSE) $CardCount += 10; else if (strpos($PlayersHand[$i], "Queen") !== FALSE) $CardCount += 10; else if (strpos($PlayersHand[$i], "King") !== FALSE) $CardCount += 10; } $Cards = $Cards .implode("~", $PlayersHand); if ($Aces > 0) { for ($i=1; $i<=$Aces;++$i) { if ($CardCount+11 <= 21) $CardCount += 11; else $CardCount += 1; } } if ($CardCount == 21) $Cards = $Cards . "\nYou win!"; else if ($CardCount> 21) $Cards = $Cards . "\nYou lose!"; //print $Deck; print <<<HERE </tr></td> <tr> <td colspan = "7"> <center> <input type = "submit" value = "play hand"> </center> </td> </tr> </table> HERE;*/ }//end function function Cards2($number){ $Diamonds = array( "Ace of Diamonds", "Two of Diamonds", "Three of Diamonds", "Four of Diamonds", "Five of Diamonds", "Six of Diamonds", "Seven of Diamonds", "Eight of Diamonds", "Nine of Diamonds", "Ten of Diamonds", "Jack of Diamonds", "Queen of Diamonds", "King of Diamonds"); $Clubs = array( "Ace of Clubs", "Two of Clubs", "Three of Clubs", "Four of Clubs", "Five of Clubs", "Six of Clubs", "Seven of Clubs", "Eight of Clubs", "Nine of Clubs", "Ten of Clubs", "Jack of Clubs", "Queen of Clubs", "King of Clubs"); $Hearts = array( "Ace of Hearts", "Two of Hearts", "Three of Hearts", "Four of Hearts", "Five of Hearts", "Six of Hearts", "Seven of Hearts", "Eight of Hearts", "Nine of Hearts", "Ten of Hearts", "Jack of Hearts", "Queen of Hearts", "King of Hearts"); $Spades = array( "Ace of Spades", "Two of Spades", "Three of Spades", "Four of Spades", "Five of Spades", "Six of Spades", "Seven of Spades", "Eight of Spades", "Nine of Spades", "Ten of Spades", "Jack of Spades", "Queen of Spades", "King of Spades"); $Cards = array_merge($Diamonds, $Clubs); $Cards = array_merge($Cards, $Hearts); $Cards = array_merge($Cards, $Spades); //$Deck = shuffle($Cards); $num1 = rand(1,52); echo $Cards[$num1]; //echo " ____ "; // }else{ // echo "There is no cards being displayed."; // }//close second if statement // }//close first if statement $cards_array[2] = $Cards[$num1]; //it take the object of a string and pass it as a array. $serialCards = urlencode(serialize($cards_array)); print_r($cards_array); print "<br>"; print $serialCards; print $cards_array[0]; print $cards_array[1]; print $cards_array[2]; print <<<HERE </tr></td> <tr> <td colspan = "5"> <center> <form methods = "post" action = "PokerFinal.php"> <input type = "submit" value = "Hit Me"> <input type = "hidden" name = "number" value = "$serialCards"> <input type ="hidden" name ="statue" value = "2"> </form> </center> </td> </tr> </table> HERE; print <<<HERE </tr></td> <tr> <td colspan = "5"> <center> <input type = "submit" value = "roll again"> </center> </td> </tr> </table> HERE; } function Cards3($number){ $Diamonds = array( "Ace of Diamonds", "Two of Diamonds", "Three of Diamonds", "Four of Diamonds", "Five of Diamonds", "Six of Diamonds", "Seven of Diamonds", "Eight of Diamonds", "Nine of Diamonds", "Ten of Diamonds", "Jack of Diamonds", "Queen of Diamonds", "King of Diamonds"); $Clubs = array( "Ace of Clubs", "Two of Clubs", "Three of Clubs", "Four of Clubs", "Five of Clubs", "Six of Clubs", "Seven of Clubs", "Eight of Clubs", "Nine of Clubs", "Ten of Clubs", "Jack of Clubs", "Queen of Clubs", "King of Clubs"); $Hearts = array( "Ace of Hearts", "Two of Hearts", "Three of Hearts", "Four of Hearts", "Five of Hearts", "Six of Hearts", "Seven of Hearts", "Eight of Hearts", "Nine of Hearts", "Ten of Hearts", "Jack of Hearts", "Queen of Hearts", "King of Hearts"); $Spades = array( "Ace of Spades", "Two of Spades", "Three of Spades", "Four of Spades", "Five of Spades", "Six of Spades", "Seven of Spades", "Eight of Spades", "Nine of Spades", "Ten of Spades", "Jack of Spades", "Queen of Spades", "King of Spades"); $Cards = array_merge($Diamonds, $Clubs); $Cards = array_merge($Cards, $Hearts); $Cards = array_merge($Cards, $Spades); //$Deck = shuffle($Cards); $num1 = rand(1,52); echo $Cards[$num1]; //echo " ____ "; // }else{ // echo "There is no cards being displayed."; // }//close second if statement // }//close first if statement $cards_array[3] = $Cards[$num1]; //it take the object of a string and pass it as a array. $serialCards = urlencode(serialize($cards_array)); print_r($cards_array); print "<br>"; print $serialCards; print $cards_array[0]; print $cards_array[1]; print $cards_array[2]; print $cards_array[3]; print <<<HERE </tr></td> <tr> <td colspan = "5"> <center> <form methods = "post" action = "PokerFinal.php"> <input type = "submit" value = "Hit Me"> <input type = "hidden" name = "number" value = "$serialCards"> <input type ="hidden" name ="statue" value = "3"> </form> </center> </td> </tr> </table> HERE; print <<<HERE </tr></td> <tr> <td colspan = "5"> <center> <input type = "submit" value = "roll again"> </center> </td> </tr> </table> HERE; } function Cards4($number){ $Diamonds = array( "Ace of Diamonds", "Two of Diamonds", "Three of Diamonds", "Four of Diamonds", "Five of Diamonds", "Six of Diamonds", "Seven of Diamonds", "Eight of Diamonds", "Nine of Diamonds", "Ten of Diamonds", "Jack of Diamonds", "Queen of Diamonds", "King of Diamonds"); $Clubs = array( "Ace of Clubs", "Two of Clubs", "Three of Clubs", "Four of Clubs", "Five of Clubs", "Six of Clubs", "Seven of Clubs", "Eight of Clubs", "Nine of Clubs", "Ten of Clubs", "Jack of Clubs", "Queen of Clubs", "King of Clubs"); $Hearts = array( "Ace of Hearts", "Two of Hearts", "Three of Hearts", "Four of Hearts", "Five of Hearts", "Six of Hearts", "Seven of Hearts", "Eight of Hearts", "Nine of Hearts", "Ten of Hearts", "Jack of Hearts", "Queen of Hearts", "King of Hearts"); $Spades = array( "Ace of Spades", "Two of Spades", "Three of Spades", "Four of Spades", "Five of Spades", "Six of Spades", "Seven of Spades", "Eight of Spades", "Nine of Spades", "Ten of Spades", "Jack of Spades", "Queen of Spades", "King of Spades"); $Cards = array_merge($Diamonds, $Clubs); $Cards = array_merge($Cards, $Hearts); $Cards = array_merge($Cards, $Spades); //$Deck = shuffle($Cards); $num1 = rand(1,52); echo $Cards[$num1]; //echo " ____ "; // }else{ // echo "There is no cards being displayed."; // }//close second if statement // }//close first if statement $cards_array[4] = $Cards[$num1]; //it take the object of a string and pass it as a array. $serialCards = urlencode(serialize($cards_array)); print_r($cards_array); print "<br>"; print $serialCards; print <<<HERE </tr></td> <tr> <td colspan = "5"> <center> <form methods = "post" action = "PokerFinal.php"> <input type = "submit" value = "Hit Me"> <input type = "hidden" name = "number" value = "$serialCards"> <input type ="hidden" name ="statue" value = "4"> </form> </center> </td> </tr> </table> HERE; print <<<HERE </tr></td> <tr> <td colspan = "5"> <center> <input type = "submit" value = "roll again"> </center> </td> </tr> </table> HERE; } function Cards5($number){ $Diamonds = array( "Ace of Diamonds", "Two of Diamonds", "Three of Diamonds", "Four of Diamonds", "Five of Diamonds", "Six of Diamonds", "Seven of Diamonds", "Eight of Diamonds", "Nine of Diamonds", "Ten of Diamonds", "Jack of Diamonds", "Queen of Diamonds", "King of Diamonds"); $Clubs = array( "Ace of Clubs", "Two of Clubs", "Three of Clubs", "Four of Clubs", "Five of Clubs", "Six of Clubs", "Seven of Clubs", "Eight of Clubs", "Nine of Clubs", "Ten of Clubs", "Jack of Clubs", "Queen of Clubs", "King of Clubs"); $Hearts = array( "Ace of Hearts", "Two of Hearts", "Three of Hearts", "Four of Hearts", "Five of Hearts", "Six of Hearts", "Seven of Hearts", "Eight of Hearts", "Nine of Hearts", "Ten of Hearts", "Jack of Hearts", "Queen of Hearts", "King of Hearts"); $Spades = array( "Ace of Spades", "Two of Spades", "Three of Spades", "Four of Spades", "Five of Spades", "Six of Spades", "Seven of Spades", "Eight of Spades", "Nine of Spades", "Ten of Spades", "Jack of Spades", "Queen of Spades", "King of Spades"); $Cards = array_merge($Diamonds, $Clubs); $Cards = array_merge($Cards, $Hearts); $Cards = array_merge($Cards, $Spades); //$Deck = shuffle($Cards); $num1 = rand(1,52); $num2 = rand(1,52); echo $Cards[$num1]; //echo " ____ "; // }else{ // echo "There is no cards being displayed."; // }//close second if statement // }//close first if statement $cards_array[5] = $Cards[$num1]; //it take the object of a string and pass it as a array. $serialCards = urlencode(serialize($cards_array)); print_r($cards_array); print "<br>"; print $serialCards; print <<<HERE </tr></td> <tr> <td colspan = "5"> <center> <form methods = "post" action = "PokerFinal.php"> <input type = "submit" value = "Hit Me"> <input type = "hidden" name = "number" value = "$serialCards"> <input type ="hidden" name ="statue" value = "5"> </form> </center> </td> </tr> </table> HERE; print <<<HERE </tr></td> <tr> <td colspan = "5"> <center> <input type = "submit" value = "roll again"> </center> </td> </tr> </table> HERE; } function Cards6($number){ $Diamonds = array( "Ace of Diamonds", "Two of Diamonds", "Three of Diamonds", "Four of Diamonds", "Five of Diamonds", "Six of Diamonds", "Seven of Diamonds", "Eight of Diamonds", "Nine of Diamonds", "Ten of Diamonds", "Jack of Diamonds", "Queen of Diamonds", "King of Diamonds"); $Clubs = array( "Ace of Clubs", "Two of Clubs", "Three of Clubs", "Four of Clubs", "Five of Clubs", "Six of Clubs", "Seven of Clubs", "Eight of Clubs", "Nine of Clubs", "Ten of Clubs", "Jack of Clubs", "Queen of Clubs", "King of Clubs"); $Hearts = array( "Ace of Hearts", "Two of Hearts", "Three of Hearts", "Four of Hearts", "Five of Hearts", "Six of Hearts", "Seven of Hearts", "Eight of Hearts", "Nine of Hearts", "Ten of Hearts", "Jack of Hearts", "Queen of Hearts", "King of Hearts"); $Spades = array( "Ace of Spades", "Two of Spades", "Three of Spades", "Four of Spades", "Five of Spades", "Six of Spades", "Seven of Spades", "Eight of Spades", "Nine of Spades", "Ten of Spades", "Jack of Spades", "Queen of Spades", "King of Spades"); $Cards = array_merge($Diamonds, $Clubs); $Cards = array_merge($Cards, $Hearts); $Cards = array_merge($Cards, $Spades); //$Deck = shuffle($Cards); $num1 = rand(1,52); echo $Cards[$num1]; //echo " ____ "; // }else{ // echo "There is no cards being displayed."; // }//close second if statement // }//close first if statement $cards_array[6] = $Cards[$num1]; //it take the object of a string and pass it as a array. $serialCards = urlencode(serialize($cards_array)); print_r($cards_array); print "<br>"; print $serialCards; print <<<HERE </tr></td> <tr> <td colspan = "5"> <center> <form methods = "post" action = "PokerFinal.php"> <input type = "submit" value = "Hit Me"> <input type = "hidden" name = "number" value = "$serialCards"> <input type ="hidden" name ="statue" value = "6"> </form> </center> </td> </tr> </table> HERE; print <<<HERE </tr></td> <tr> <td colspan = "5"> <center> <input type = "submit" value = "roll again"> </center> </td> </tr> </table> HERE; } function Cards7($number){ $Diamonds = array( "Ace of Diamonds", "Two of Diamonds", "Three of Diamonds", "Four of Diamonds", "Five of Diamonds", "Six of Diamonds", "Seven of Diamonds", "Eight of Diamonds", "Nine of Diamonds", "Ten of Diamonds", "Jack of Diamonds", "Queen of Diamonds", "King of Diamonds"); $Clubs = array( "Ace of Clubs", "Two of Clubs", "Three of Clubs", "Four of Clubs", "Five of Clubs", "Six of Clubs", "Seven of Clubs", "Eight of Clubs", "Nine of Clubs", "Ten of Clubs", "Jack of Clubs", "Queen of Clubs", "King of Clubs"); $Hearts = array( "Ace of Hearts", "Two of Hearts", "Three of Hearts", "Four of Hearts", "Five of Hearts", "Six of Hearts", "Seven of Hearts", "Eight of Hearts", "Nine of Hearts", "Ten of Hearts", "Jack of Hearts", "Queen of Hearts", "King of Hearts"); $Spades = array( "Ace of Spades", "Two of Spades", "Three of Spades", "Four of Spades", "Five of Spades", "Six of Spades", "Seven of Spades", "Eight of Spades", "Nine of Spades", "Ten of Spades", "Jack of Spades", "Queen of Spades", "King of Spades"); $Cards = array_merge($Diamonds, $Clubs); $Cards = array_merge($Cards, $Hearts); $Cards = array_merge($Cards, $Spades); //$Deck = shuffle($Cards); $num1 = rand(1,52); $num2 = rand(1,52); echo $Cards[$num1]; //echo " ____ "; // }else{ // echo "There is no cards being displayed."; // }//close second if statement // }//close first if statement $cards_array[7] = $Cards[$num1]; //it take the object of a string and pass it as a array. $serialCards = urlencode(serialize($cards_array)); print_r($cards_array); print "<br>"; print $serialCards; print <<<HERE </tr></td> <tr> <td colspan = "5"> <center> <form methods = "post" action = "PokerFinal.php"> <input type = "submit" value = "Hit Me"> <input type = "hidden" name = "number" value = "$serialCards"> <input type ="hidden" name ="statue" value = "7"> </form> </center> </td> </tr> </table> HERE; print <<<HERE </tr></td> <tr> <td colspan = "5"> <center> <input type = "submit" value = "roll again"> </center> </td> </tr> </table> HERE; } function Cards8($number){ $Diamonds = array( "Ace of Diamonds", "Two of Diamonds", "Three of Diamonds", "Four of Diamonds", "Five of Diamonds", "Six of Diamonds", "Seven of Diamonds", "Eight of Diamonds", "Nine of Diamonds", "Ten of Diamonds", "Jack of Diamonds", "Queen of Diamonds", "King of Diamonds"); $Clubs = array( "Ace of Clubs", "Two of Clubs", "Three of Clubs", "Four of Clubs", "Five of Clubs", "Six of Clubs", "Seven of Clubs", "Eight of Clubs", "Nine of Clubs", "Ten of Clubs", "Jack of Clubs", "Queen of Clubs", "King of Clubs"); $Hearts = array( "Ace of Hearts", "Two of Hearts", "Three of Hearts", "Four of Hearts", "Five of Hearts", "Six of Hearts", "Seven of Hearts", "Eight of Hearts", "Nine of Hearts", "Ten of Hearts", "Jack of Hearts", "Queen of Hearts", "King of Hearts"); $Spades = array( "Ace of Spades", "Two of Spades", "Three of Spades", "Four of Spades", "Five of Spades", "Six of Spades", "Seven of Spades", "Eight of Spades", "Nine of Spades", "Ten of Spades", "Jack of Spades", "Queen of Spades", "King of Spades"); $Cards = array_merge($Diamonds, $Clubs); $Cards = array_merge($Cards, $Hearts); $Cards = array_merge($Cards, $Spades); //$Deck = shuffle($Cards); $num1 = rand(1,52); echo $Cards[$num1]; //echo " ____ "; // }else{ // echo "There is no cards being displayed."; // }//close second if statement // }//close first if statement $cards_array[8] = $Cards[$num1]; //it take the object of a string and pass it as a array. $serialCards = urlencode(serialize($cards_array)); print_r($cards_array); print "<br>"; print $serialCards; print <<<HERE </tr></td> <tr> <td colspan = "5"> <center> <form methods = "post" action = "PokerFinal.php"> <input type = "submit" value = "Hit Me"> <input type = "hidden" name = "number" value = "$serialCards"> <input type ="hidden" name ="statue" value = "8"> </form> </center> </td> </tr> </table> HERE; print <<<HERE </tr></td> <tr> <td colspan = "5"> <center> <input type = "submit" value = "roll again"> </center> </td> </tr> </table> HERE; } function Cards9($number){ $Diamonds = array( "Ace of Diamonds", "Two of Diamonds", "Three of Diamonds", "Four of Diamonds", "Five of Diamonds", "Six of Diamonds", "Seven of Diamonds", "Eight of Diamonds", "Nine of Diamonds", "Ten of Diamonds", "Jack of Diamonds", "Queen of Diamonds", "King of Diamonds"); $Clubs = array( "Ace of Clubs", "Two of Clubs", "Three of Clubs", "Four of Clubs", "Five of Clubs", "Six of Clubs", "Seven of Clubs", "Eight of Clubs", "Nine of Clubs", "Ten of Clubs", "Jack of Clubs", "Queen of Clubs", "King of Clubs"); $Hearts = array( "Ace of Hearts", "Two of Hearts", "Three of Hearts", "Four of Hearts", "Five of Hearts", "Six of Hearts", "Seven of Hearts", "Eight of Hearts", "Nine of Hearts", "Ten of Hearts", "Jack of Hearts", "Queen of Hearts", "King of Hearts"); $Spades = array( "Ace of Spades", "Two of Spades", "Three of Spades", "Four of Spades", "Five of Spades", "Six of Spades", "Seven of Spades", "Eight of Spades", "Nine of Spades", "Ten of Spades", "Jack of Spades", "Queen of Spades", "King of Spades"); $Cards = array_merge($Diamonds, $Clubs); $Cards = array_merge($Cards, $Hearts); $Cards = array_merge($Cards, $Spades); //$Deck = shuffle($Cards); $num1 = rand(1,52); echo $Cards[$num1]; //echo " ____ "; // }else{ // echo "There is no cards being displayed."; // }//close second if statement // }//close first if statement $cards_array[9] = $Cards[$num1]; //it take the object of a string and pass it as a array. $serialCards = urlencode(serialize($cards_array)); print_r($cards_array); print "<br>"; print $serialCards; // print <<<HERE // </tr></td> // <tr> // <td colspan = "5"> // <center> //<form methods = "post" // action = "PokerFinal.php"> //<input type = "submit" // value = "Hit Me"> // <input type = "hidden" // name = "number" // value = "$serialCards"> // <input type ="hidden" // name ="statue" // value = "9"> //</form> //</center> // </td> // </tr> // </table> //HERE; print "No more HIT ME button"; print <<<HERE </tr></td> <tr> <td colspan = "5"> <center> <input type = "submit" value = "roll again"> </center> </td> </tr> </table> HERE; } function printPage(){ }//end functon //function rollDice(){ // global $die, $secondRoll, $keepIt; //print "<table border = 1><td><tr>"; //for ($i = 0; $i < 5; $i++){ //if ($keepIt[$i] == ""){ //$die[$i] = rand(1, 6); //} else { //$die[$i] = $keepIt[$i]; //} // end if //$theFile = "die" . $die[$i] . ".jpg"; //print out dice images // print <<<HERE // <td> // <img src = "$theFile" // height = 50 // width = 50><br> //HERE; //print out a checkbox on first roll only // if ($secondRoll == FALSE){ // print <<<HERE // <input type = "checkbox" // name = "keepIt[$i]" //value = $die[$i]> //</td> //HERE; // } // end if // } // end for loop //print out submit button and end of table //print <<<HERE //</tr></td> //<tr> // <td colspan = "5"> // <center> //<input type = "submit" // value = "roll again"> //</center> // </td> //</tr> //</table> //HERE; //} // end rollDice function evaluate(){ global $die, $cash; //set up payoff $payoff = 0; //subtract some money for this roll $cash -= 2; //count the dice for ($theVal = 1; $theVal <= 6; $theVal++){ for ($dieNum = 0; $dieNum < 5; $dieNum++){ if ($die[$dieNum] == $theVal){ $numVals[$theVal]++; } // end if } // end dieNum for loop } // end theVal for loop //print out results // for ($i = 1; $i <= 6; $i++){ // print "$i: $numVals[$i]<br>\n"; // } // end for loop //count how many pairs, threes, fours, fives $numPairs = 0; $numThrees = 0; $numFours = 0; $numFives = 0; for ($i = 1; $i <= 6; $i++){ switch ($numVals[$i]){ case 2: $numPairs++; break; case 3: $numThrees++; break; case 4: $numFours++; break; case 5: $numFives++; break; } // end switch } // end for loop //check for two pairs if ($numPairs == 2){ print "You have two pairs!<br>\n"; $payoff = 1; } // end if //check for three of a kind and full house if ($numThrees == 1){ if ($numPairs == 1){ //three of a kind and a pair is a full house print "You have a full house!<br>\n"; $payoff = 5; } else { print "You have three of a kind!<br>\n"; $payoff = 2; } // end 'pair' if } // end 'three' if //check for four of a kind if ($numFours == 1){ print "You have four of a kind!<br>\n"; $payoff = 5; } // end if //check for five of a kind if ($numFives == 1){ print "You got five of a kind!<br>\n"; $payoff = 10; } // end if //check for flushes if (($numVals[1] == 1) && ($numVals[2] == 1) && ($numVals[3] == 1) && ($numVals[4] == 1) && ($numVals[5] == 1)){ print "You have a flush!<br>\n"; $payoff = 10; } // end if if (($numVals[2] == 1) && ($numVals[3] == 1) && ($numVals[4] == 1) && ($numVals[5] == 1) && ($numVals[6] == 1)){ print "You have a flush!<br>\n"; $payoff = 10; } // end if print "You bet 2<br>\n"; print "Payoff is $payoff<br>\n"; $cash += $payoff; } // end evaluate function printStuff(){ global $cash, $secondRoll; print "Cash: $cash\n"; //store variables in hidden fields print <<<HERE <input type = "hidden" name = "secondRoll" value = "$secondRoll"> <input type = "hidden" name = "cash" value = "$cash"> HERE; } // end printStuff ?> </form> </center> </html> I have a picture (attached), where I find the coordinates of black points, because I do not remember any point, so you want every point at which I find coordinates with mark a red cross as watermark. At the coordinates using this script: <?php if(isset($_GET["obrazek_x"])) file_put_contents("soubor.txt",$_GET["obrazek_x"].",".$_GET["obrazek_y"]."\n",FILE_APPEND); ?> Coordinates I save to an external file in this format: Code: [Select] 602;744 Could you advise me a solution to mark black points? I'm importing a CSV using the fgetcsv() function, which is working all good. However, when I take a look at the data in the database, I see black diamonds with question marks. This isn't too much of an issue when echoing the data back out again, as they don't appear, but when I want to use one of the CSV fields as a MySQL date, it isn't recognised as a date and is stored as 0000-00-00. e.g. I think this issue is something to do with encoding of the CSV? Can anyone offer any advice? If it helps here is my import script, and the encode type is ASCII according to mb_detect_encoding Code: [Select] <?php include 'config.php'; include 'opendb.php'; ini_set("auto_detect_line_endings", true); $row = 0; $tmpName = $_FILES['csv']['tmp_name']; if (($handle = fopen($tmpName, "r")) !== FALSE) { $num = count($data); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $noQuotes = str_replace("\"", '', $data); $originalDate = $noQuotes[1]; //$delivery_date = date('Y-m-d', strtotime($originalDate)); $parts = explode('/', $originalDate); $delivery_date = $parts[2] . '-' . $parts[1] . '-' . $parts[0]; $row++; $import="INSERT into dispatch (delivery_note_number, delivery_date, dispatch_date, customer_delivery_date, delivery_line, produce, variety, quantity, pallets, count, depot, customer, grower, haulier, status) values ('$noQuotes[0]', '$delivery_date', '$noQuotes[2]', '$noQuotes[3]', '$noQuotes[4]', '$noQuotes[5]', '$noQuotes[6]', '$noQuotes[7]', '$noQuotes[8]', '$noQuotes[9]', '$noQuotes[10]', '$noQuotes[11]', '$noQuotes[12]', '$noQuotes[13]', '$noQuotes[14]')"; echo $import; mysql_query($import) or die(mysql_error()); } //header("location:list_dispatch.php?st=recordsadded"); fclose($handle); } ?> Hey all. I'm getting down the basics of the GD Library's image creation processes. I'm trying to test out creating png images. However, where there should be transparency there is a black background. Here's my code mostly based on the image tutorial found here at phpfreaks. Code: [Select] <?php // font $font = 'c:\windows\fonts\arial.ttf'; $fontsize = 12; // array of quotes $quotes = array( "I like pie.", "Surf's Up.", "Smoke em if you got em.", "Game on.", "I need TP for my bunghole."); // select quote $pos = rand(0,count($quotes)-1); $quote = $quotes[$pos]; // image $image = imagecreatefrompng('quote.png'); $white = imagecolorallocate($image, 255, 255, 255); $black = imagecolorallocate($image, 0, 0, 0); imagettftext($image, 11, 0, 107, 32, $black, $font, $quote); imagettftext($image, 11, 0, 105, 30, $white, $font, $quote); // tell the browser that the content is an image header('Content-type: image/png'); // output image to the browser imagepng($image); // delete the image resource imagedestroy($image); ?> Cheers all, thanks! This is kind of weird, I've tried to figure out what is wrong for a while now, but I really can't seem to figure it out. My script does seem to work with the values I think it works with, but that might be where the error is. I've messed around a lot with it, but I still can't seem to understand what the problem is... I do realize I can just use the filledrectangle function instead of creating a new image for each background color, but the problem itself really annoys me. The black line doesn't appear anywhere but between the two first background colors and only if both background colors are visible... o.O Might be I need to use some other imagecopy function, but this is all so weird! <?php // image size $x=500; $y=100; // creating transparent image $im=imagecreatetruecolor($x,$y); $tc=imagecolorallocatealpha($im,255,255,255,0); imagefill($im,0,0,$tc); // background colors // the escaped lines is for making a background image transparent, to see where the black line appears $bgc[]=array(255,0,0,0); //$bgc[0]=array(255,0,0,127); $bgc[]=array(0,255,0,0); //$bgc[1]=array(0,255,0,127); $bgc[]=array(0,0,255,0); $bgc[]=array(0,255,255,0); // adding backgrounds // background count: $bgcq=count($bgc); // backgroundsize x,y: $bgs=array(ceil($x),($y+1)/$bgcq); // location: $bgsl=0; // last height: $bgsh=0; for($i=0;$i<$bgcq;$i++){ // start location for this background: $bgsl+=$bgsh; // calculating a round number for the background height if($bgsl+$bgs[1]<round($bgs[1]+($bgs[1]*$i))){ $bgsh=ceil($bgs[1]); }else{ $bgsh=floor($bgs[1]); } // creating background image: $bg=imagecreatetruecolor($bgs[0],$bgsh); // filling background image with set color $abgc=imagecolorallocatealpha($bg,$bgc[$i][0],$bgc[$i][1],$bgc[$i][2],$bgc[$i][3]); imagefill($bg,0,0,$abgc); // pasting background on image (imagecopy gives the same result) imagecopyresampled($im,$bg,0,$bgsl,0,0,$bgs[0],$bgsh,$bgs[0],$bgsh); // to see the values (test purpose), must escape header and imagepng functions //echo $bgsl.'-'.($bgsl+$bgsh).'<br />'.$bgsh.'<br />'; } // output, remember to escape it to echo variables header('Content-type: image/png'); imagepng($im,NULL,0); ?> I've tried to make the script as understandable and easy as possible... anyone got any ideas about what is wrong here, and how to maybe fix it? hi, i am trying to generate image gallery. but the problem is that when i upload the png files its thumbnail is generated with black background. JPEG an GIF thumbnail are generated successfully. i want to make background transparent. is there any solution that how i can get rid of it. i am using imagecreatetruecolor($thumbwidth, $thumbheight ); to generate thumbnail |