PHP - How To Convert Jpeg/jpg Format To Png/gif Transparent Format
Hi all,
I am currently making a website that has e-custom functions and a back end for the client. I want them to be able to upload images - but they need to be transparent. I do not want to leave this in the hands of the client, so I am looking at ways of using the GD library to make the change I got no issue with the png/gif type for upload/resize function since this type already transparent background but my major problems is how to deal with jpeg/jpg image type which is their background was not a transparent...so is it possible I can change/ convert to png/gif type upon successful of uploading image...so the new final image will be png/gif type with transparent background...is it doable...I am not even sure it is possible...? Thanks for any help.. Similar Tutorials
Hello All, function convertTimeFormat($time12Hour) { // Initialized required variable to an empty string. $time24Hour = ""; // Used explode() function to break the string into an array and stored its value in $Split variable. $Split = explode(":",$time12Hour); // print_r(explode (":", $time12Hour)); => Array ( [0] => 09 [1] => 50 [2] => 08AM ) // Retrieved only "hour" from the array and stored in $Hour variable. $Hour = $Split[0]; $Split[2] = substr($Split[2],0,2); // Used stripos() function to find the position of the first occurrence of a string inside another string. if($Hour == '12' && strpos($time12Hour,"AM")!== FALSE) { // Code here } elseif(strpos($time12Hour,"PM")!== FALSE && $Hour != "12") { // code here } return $time24Hour; } $time12Hour = "09:50:08AM"; $result = convertTimeFormat($time12Hour); print_r($result); /* Input : "09:50:08AM"; Output : "21:50:08PM"; */
Can anyone please tell me how I convert DD-MM-YYY (text) to TIME (unix) thought I'd say that I have this line at the top of all my pages, just in case it means a different code. Code: [Select] date_default_timezone_set('Europe/London'); //### Set the default timezone while I'm reading the cell value '20/09/1980' from an excel file using phpexcel class method $student[$i]['d_o_b'] = $objWorksheet->getCell('G' . $intRow)->getValue(); getting the value as '29484' pls help me to convert it into the date format again. I have multiple datetimes. The format is dd-mm-yy, hh:mm. I want to insert it into a table using mysql. However mysql format is yy-mm-dd, hh:mm:ss. How can i do it and what type should i use (datetime?timestamp?). Thanks for your help!! Hi I was going to start a new project which need to convert files from one fomrat to other like, you can check a site here online-convert.com , there they give user to convert in various fomats. please check my question is i have idea how to do these conversion with ffmpeg and php. Code: [Select] Audio converter Video converter Image converter Hash generator can someone please tell me how to do these conversion. Code: [Select] Document converter Ebook converter Thanks for any help Does anyone know how I can convert linux epoch number such as 1292878800 to the UTC format? Ricky Hi, I need to post to a form with cURL. I'am sending strings in Headers format... There are some documentation or some function that translates from the human readable format to the Headers format? For example: Human readable format: Quote Vendo bicicleta. Como nova. Headers format: Quote Vendo%20bicicleta.%20Como%20nova. The problem is not the spaces but more the accents. I write in Portuguese. Can you give me some clue? Best Regards, Hi. I have an input field where a date is entered, format dd-mm-yy. I need to query the database to see if this date exists. How can I convert the date to yyyymmdd before the query? Thanks Hi, I have a connection set up to an API using a PHP script - the API sends back data in JSON format, and if I capture it and echo it, it displays in extremely unfriendly format on the screen. I've tried to find a way to convert this data into readable format, ideally in a HTML table, but although there are articles on converting manually inputted JSON data into a HTML table using Javascript, I can't find a way to do it from a PHP variable. This is what I have so far: if ($_POST['getcompany']) { $companyname = $_POST['_Name']; $ch = curl_init(); $data_array2 = array( 'token' => $token ); $make_call2 = json_encode($data_array2); //echo 'Token is '.$token; $token2 = substr($token, 14); $token3 = substr($token2, 0, -3); //echo 'Token 2 is '.$token3; //echo 'Company Name is '.$companyname; //curl_setopt($ch, CURLOPT_GET, 1); //curl_setopt($ch, CURLOPT_POSTFIELDS, $make_call2); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Authorization: '.$token3.'')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_URL, 'https://connectionurl?countries=GB&name='.$companyname); //Execute the request $result = curl_exec($ch); echo 'Companies: '.$result; //This displays the data provided by the search, but is in JSON format
So I need a way to get the data held in $result, into a HTML table. Any idea how I can do this? I have tried a large number of "solutions" to this but everytime I use them I see 0000-00-00 in my date field instead of the date even though I echoed and can see that the date looks correct. Here's where I'm at: I have a drop down for the month (1-12) and date fields (1-31) as well as a text input field for the year. Using the POST array, I have combined them into the xxxx-xx-xx format that I am using in my field as a date field in mysql. <code> $date_value =$_POST['year'].'-'.$_POST['month'].'-'.$_POST['day']; echo $date_value; </code> This outputs 2012-5-7 in my test echo but 0000-00-00 in the database. I have tried unsuccessfully to use in a numberof suggested versions of: strtotime() mktime Any help would be extremely appreciated. I am aware that I need to validate this data and insure that it is a valid date. That I'm okay with. I would like some help on getting it into the database. I wish to know how i can convert this date 24-09-2010 to this format 2010-09-24 I am using PHP's GD to resize uploaded images and create new ones for security purposes. Should I leave the converted files in their native format (e.g. PNG ---> PNG) or should I convert all images to JPG (i.e. PNG ---> JPEG)?? Thanks, Debbie P.S. Should it be ".jpg" or ".jpeg" echo "<font color='000000'>No Service Found At<br /></font>"<font color='000000'> .long2ip($ip)</font>; Hi im desperately in need of some help here.. Im exporting my html page data to csv but i am unable to get the data onto a new column the code is as follows HTML FORM Code: [Select] <form id="form1" name="form1" method="post" action="index.php"> <table class="formatTblClass"> <tr> <th colspan="6"><?=$message;?></th> </tr> <tr> <td width="68"><span>First Name</span></td> <td width="215"><input class="Name" type="text" name="fn" id="fn" /></td> <td width="62"><span>Last Name</span></td> <td colspan="3"><input class="Name" name="ln" type="text" id="ln" size="50" /></td> </tr> <tr> <td colspan="6"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="71">Address</td> <td width="721"><input class="Address" name="address" type="text" id="address" size="100" /></td> </tr> </table></td> </tr> <tr> <td><span>City</span></td> <td><input class="City" type="text" name="city" id="city" /></td> <td><span>State</span></td> <td width="148"><input class="State" type="text" name="state" id="state" /></td> <td width="24"><span>ZIP</span></td> <td width="255"><input class="ZIP" type="text" name="zip" id="zip" /></td> </tr> <tr> <td><span>Phone</span></td> <td><input class="Phone" type="text" name="phone" id="phone" /></td> <td><span>Email</span></td> <td><input class="Email" type="text" name="email" id="email" /></td> <td><input name="emailMe" type="checkbox" id="emailMe" value="Yes" checked="checked" /></td> <td>Please send me email</td> </tr> <tr> <td colspan="6"><span>Comments <textarea name="comments" id="comments" cols="45" rows="5"></textarea> </span> <div align="center"> <input type="submit" name="Submit" id="Submit" value="Submit" /> <input type="reset" name="Reset" id="button" value="Reset" /> </div></td> </tr> </table> </form> <?php // Receiving variables @$pfw_ip= $_SERVER['REMOTE_ADDR']; @$fn = addslashes($_POST['fn']); @$ln = addslashes($_POST['ln']); @$address = addslashes($_POST['address']); @$city = addslashes($_POST['city']); @$state = addslashes($_POST['state']); @$zip = addslashes($_POST['zip']); @$phone = addslashes($_POST['phone']); @$email = addslashes($_POST['email']); @$emailMe = addslashes($_POST['emailMe']); @$comments = addslashes($_POST['comments']); // Validation //saving record in a text file $pfw_file_name = "formtest.csv"; $pfw_first_raw = "fn,\rln,\raddress,\rcity,\rstate,\rzip,\rphone,\remail,\remailMe,\rcomments\r\n"; $pfw_values = "$fn,\r$ln,\r$address,\r$city,\r$state,\r$zip,\r$phone,\r$email,\r$emailMe,\r".str_replace ("\r\n","<BR>",$comments )."\r\n"; $pfw_is_first_row = false; if(!file_exists($pfw_file_name)) { $pfw_is_first_row = true ; } if (!$pfw_handle = fopen($pfw_file_name, 'a+')) { die("Cannot open file ($pfw_file_name)"); exit; } if ($pfw_is_first_row) { if (fwrite($pfw_handle, $pfw_first_raw ) === FALSE) { die("Cannot write to file ($pfw_filename)"); exit; } } if (fwrite($pfw_handle, $pfw_values) === FALSE) { die("Cannot write to file ($pfw_filename)"); exit; } fclose($pfw_handle); echo("<p align='center'><font face='Arial' size='3' color='#FF0000'>thanx</font></p>"); ?> THIS IS THE OUTPUT I GET fn ln address city state zip phone emailMe comments Tom Sawyer shady lane new york new york NY124 123456789 tom@sawyer.com Yes comments THIS IS THE OUTPUT I AM LOOKING FOR fn Tom Harry ln Sawyer Potter address shady lane magic lane city new york xyz state new york xyz zip NY124 12343 phone 123456789 987654321 email tom@sawyer.com harry@magic.co.uk emailMe Yes Yes comments comments this is the comment please help me on this one.. unable to get the script export the data in top to bottom columnwise format Code: [Select] $date =date("d F Y"); It will display 18 October 2011. If I need it to display 2011-10-18. How do it go about coding it? I have a date field in the database table of this format 2012-02-08. Now I want to select fields from the database where date >= $currentdate. Do I have to do someting like $currentdate=time(); //Then convert it into YYYY-MM-DD format? Anyone know what's up with this? <?php $days = floor($posts['timestamp'] / (60 * 60 * 24)); $remainder = $posts['timestamp'] % (60 * 60 * 24); $hours = floor($remainder / (60 * 60)); $remainder = $remainder % (60 * 60); $minutes = floor($remainder / 60); $seconds = $remainder % 60; if($days > 0) { echo date("d/m/y", $posts['timestamp']); echo " at "; echo date("H:i", $posts['timestamp']); }elseif($days == 0 && $hours == 0 && $minutes == 0) { echo "few seconds ago"; }elseif($days == 0 && $hours == 0) { echo $minutes.' minutes ago'; }elseif($days == 0 && $hours > 0){ echo $hours.' hour ago'; }else{ echo "few seconds ago"; } ?> Hello!! i want to save datetimes into a mysql database. Their format is dd-mm-yy hh:mm. I think mysql format for datetime is yy-mm-dd hh:mm..How can i convert them?? Hello Guys Does anyone knows how to parse an XML format? Im just learning how to parse a CSV string but now my job suddenly involves parsing an XML string.. Can you help me on this guys? This is my XML string.. Quote <?xml version="1.0" encoding="UTF-8"?><GetSMSInboundResponse><Transaction><Code>1</Code><Description>Transaction OK</Description></Transaction><SMSInbounds><InboundSMS><ID>3126274</ID><Originator>+639105701066</Originator><Destination>+447537404702</Destination><Keyword>UCB2</Keyword><Date>2012-01-24</Date><Time>12:31:11</Time><Body>UCB2 a text having 'qoute' "double qoute" and ,commas, hehe.</Body></InboundSMS></SMSInbounds></GetSMSInboundResponse> the result is similar to this Quote Array ( [1] => Array ( [1] => UCB2 [2] => 2012-01-24 [3] => 12:31:11 [4] => UCB2 a text having 'qoute' "double qoute" and ,commas, hehe. ) ) I would like to put the result on an array or a multi dimentional array.. I dont have any ideas about XML parsing i myself is having trouble of parsing a CSV string I would love to hear you comments or solution to my problem. Any help will be appreciated... thanks Hi Guys Could somebody tell me how i would put a line break into the code below i.e: 1.07 <br /> 2010 <?php echo date('d.m.Y',strtotime($news['created_at']));?> Thanks for your help |