PHP - Create Canvas For Image
Hi all
I am trying to write a piece of code to take an image, resize it and centre it on a canvas 300 pixels tall by 400 pixels high. I know I need to use imagecopymerged but how do I add it to the below code: Code: [Select] $imagelarge = $_FILES['image']['tmp_name']; $imagelargemain = $_FILES['image']['name']; $src = imagecreatefromjpeg($imagelarge); list($width,$height)=getimagesize($imagelarge); $newwidth=300; $newheight=($height/$width)*$newwidth; $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); $filename = WEB_UPLOAD."images/right-images/". $_FILES['image']['name']; imagejpeg($tmp,$filename,100); imagedestroy($src); imagedestroy($tmp); Many thanks for your help! Pete Similar TutorialsHello i just learned how to use .ttf fonts on a webpage ,but i noticed that IE Browsers arent supporting it so i thought to make add the Fonted Text into a image so IE Browsers will see the font in a image and not a replaced font text Could someone please provide me a Simple Script to make a PNG image with the text and font and a invisible background ? Hi! my code uploads an image and saves it to an upload folder, but I want to create a thumbnail of it. For example, if I upload a 1400x1000 JPG, I would like to resize the image and it has to respect the proportion given a maximum size. if I say the maximum width/height is 250px, the image should be thumbnailed according to the max height/width, and in proportion with the width/height Thanks in advance Fernando Hi, I have a script that uploads an image to a directory and then saves the fill path to a field in a table for later use. The only problem is people are uploading huge images and then when I produce a catalogue of my listings it takes forever to load because the images are so big. What I am after is an add in script to create an ADDITIONAL image 100 x 75px, I don't really want to change my upload script. Any ideas? Thanks in advace. Here is what I have: Code: [Select] <?php $idir = "../fleet/"; // Path To Images Directory if (isset ($_FILES['fupload'])){ //upload the image to tmp directory $url = $_FILES['fupload']['name']; // Set $url To Equal The Filename For Later Use if ($_FILES['fupload']['type'] == "image/jpg" || $_FILES['fupload']['type'] == "image/jpeg" || $_FILES['fupload']['type'] == "image/pjpeg") { $file_ext = strrchr($_FILES['fupload']['name'], '$account.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php $copy = copy($_FILES['fupload']['tmp_name'], "$idir" . $_FILES['fupload']['name']); // Move Image From Temporary Location To Perm } } $fleetimage1 = mysql_real_escape_string("$idir" . $_FILES['fupload']['name']); //then insert sql code below... ?> I need to upload an image using php and store the image as blob in mysql. I understand the standard way is to create a form for the user, let the user choose the image to upload, click submit. But I need to create a php, for example, uploadImage.php?image="c:\myPhoto.jpg" and when I type http:\\www.myhome.com\uploadImage.php?image="c:\myPhoto.jpg" from a web browser in my pc, I can automatically upload myPhoto.jpg to the myhome.com server? Thank you for your kind help. Hi guys, I have a simple code below which allows to me to upload image to a file directory and save the location of my file in database the only thing i dont understand is how to 1-resize the images 2- create a thumbnail while uploading 3- allow only jpeg & JPG files to be uploaded with 200kb max also, could you tell me what is the best size i can store the images in? thanks in advance //image1 $nameone=$_FILES['myfileone']['name']; $tmp_name= $_FILES['myfileone']['tmp_name']; if ($nameone) { $locationone="images/$nameone"; move_uploaded_file($tmp_name, $locationone); $image1 = mysql_query ("UPDATE user SET image1='$locationone'"); } Hi, How to create an invisible text in an image. Any idea? Thanks. Not sure if this is the right place to post this. I have PHP form that I use to upload a document, PDF or Word Doc, I would also like the form to create a thumbnail of the document when it is uploaded, is this possible? Here is the script the reads a twitter xml feed and generates a png from the first tweet. What I want to be able to is specify a width so the text will wrap and be able to position the text within a certain dimensions. I created the files with a base image because I didn't know how to create an image with a specific color. So removing the base image section would be great. Lastly, I would like to style the font with a certain font and weight. <?php // Get the XML data from Feedburner $sxe = new SimpleXMLElement('twitter.xml', NULL, TRUE); $tweet = $sxe->status[0]->text; // Create the image from the base image $img = imagecreatefrompng('tweet-base.png'); $color = imagecolorallocate($img, 0x33, 0x33, 0x33); imagestring($img, 2, $xpos, 2, $tweet, $color); // Save the image imagepng($img, 'tweet.png'); ?> I have some code that displays 1 large image and then 5 small ones, you click on a small one and it becomes the large one "trades places" I then fixed the sizes so they don't distort when changing from large to small and then back. My problem is when the image is clicked the large image size does not change, the image does I that my issue lies here Code: [Select] <img name='picture' src=uploads/harkly_1.jpg ";echo imageResize($myImg1[0], $myImg1[1], 300); echo " border=0></td> but no clue on how to fix it this part Quote $myImg1[0], $myImg1[1 needs to change based on the selected image, can someone help me figure out how to make this happen?? Is there someway to create an if statement for this? Code: [Select] If (something){ echo "$myImg1[0], $myImg1[1]"; } else { echo "$myImg2[0], $myImg2[1]"; } My full code Code: [Select] <?php // to change the image size within the web page function imageResize($width, $height, $target) { //takes the larger size of the width and height and applies the formula accordingly... //this is so this script will work dynamically with any size image if ($width > $height) { $percentage = ($target / $width); } else { $percentage = ($target / $height); } //gets the new value and applies the percentage, then rounds the value $width = round($width * $percentage); $height = round($height * $percentage); //returns the new sizes in html image tag format... //this is so you can plug this function inside an image tag and just get the return "width='$width' height='$height'"; } ?> <HEAD> <SCRIPT LANGUAGE="JavaScript"> <!-- Original: Ronnie T. Moore, Editor --> <!-- Web Site: The JavaScript Source --> <!-- Begin var photo_1 = new Image(); var photo_2 = new Image(); var photo_3 = new Image(); photo_1.src = "uploads/harkly_1.jpg"; photo_2.src = "uploads/harkly_2.jpg"; photo_3.src = "uploads/harkly_3.jpg"; function doButtons(picimage) { eval("document['picture'].src = " + picimage + ".src"); } // End --> </script> </HEAD> <?php //get the image size of the picture and load it into an array $photo_1="uploads/harkly_1.jpg"; $photo_2="uploads/harkly_2.jpg"; $photo_3="uploads/harkly_3.jpg"; $myImg1 = getimagesize($photo_1); $myImg2 = getimagesize($photo_2); $myImg3 = getimagesize($photo_3); echo " <BODY> <center> <table border=1> <tr><td> <p> <li><a href = '' onmouseover = \"doButtons('photo_1')\"><img name='photo_1' src='$photo_1' ";echo imageResize($myImg1[0], $myImg1[1], 55); echo " border=0><p> <li><a href = '' onmouseover = \"doButtons('photo_2')\"><img name='photo_2' src='$photo_2' ";echo imageResize($myImg2[0], $myImg1[1], 55); echo " border=0><p> <li><a href = '' onmouseover = \"doButtons('photo_3')\"><img name='photo_3' src='$photo_3' ";echo imageResize($myImg3[0], $myImg1[1], 55); echo " border=0><p> <td width=440 height=300> <img name='picture' src=uploads/harkly_1.jpg ";echo imageResize($myImg1[0], $myImg1[1], 300); echo " border=0></td> </tr> </table> </center> "; ?> Hi guys, Here is what I have so far: http://www.autoshopgarage.com/new-era/generate.php What I am trying to do is instead of having Line 1 and Line 2, I want to just have one big textarea so I don't have to limit the user so much. I did it this way because I want to have two versions of text, the light version and the bold version. Is it possible to have two different fonts with just one textarea of text? Right now I have two functions: Quote ImageTTFText($image, $fontSize, $fontRotation, 435, 80, $color, $font1, wordwrap($first, 18, "\n", true)); ImageTTFText($image, $fontSize, $fontRotation, 485,120, $color_black, $font2, wordwrap($last, 18, "\n", true)); So I would limit that to just 1, and it would automatically wordwrap but what would I put for the $font variable? Is this even possible? I was thinking of just using BBCode so they could type in [b*]Bold Text[/b*] and it would use the Bold version of the font if it sees that. Any help is appreciated. Thanks! Here is the full code: Quote <?php $first = $_GET['first']; $last = $_GET['last']; $font_color = $_GET['color']; header("Content-type: image/png"); $image = imagecreatefrompng ( "banner_blank.png" ); $color_black = imagecolorallocate($image, 0, 0, 0); $color_red = imagecolorallocate($image, 255, 0, 0); if($font_color == "Red") { $color = $color_red; } elseif($font_color == "Black") { $color = $color_black; } $font1 = 'HelveticaNeueLTStd-BdEx.ttf'; $font2 = 'HelveticaNeueLTStd-LtEx.ttf'; $fontSize = "21"; ImageTTFText($image, $fontSize, $fontRotation, 435, 80, $color, $font1, wordwrap($first, 18, "\n", true)); ImageTTFText($image, $fontSize, $fontRotation, 485,120, $color_black, $font2, wordwrap($last, 18, "\n", true)); imagepng ( $image ); imagedestroy ( $image ); ?> Hi I've got this database I created with fields ProductId ProductName Image I've managed to get it to list the ID,productname, and Image urls in a list. My next step is to have the image field actually display an image and make it clickable: heres what I've done so far: Code: [Select] <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("productfeed", $con); $result = mysql_query("SELECT * FROM productfeeds"); echo "<table border='0'> <tr> <th>Firstname</th> <th>Lastname</th> <th>Image</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['ProductID'] . "</td>"; echo "<td>" . $row['ProductName'] . "</td>"; echo "<td>" . $row['ImageURL'] . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> Heres what I want to do: Code: [Select] while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['ProductID'] . "</td>"; echo "<td>" . $row['ProductName'] . "</td>"; // my changes beneath echo "<td>" . <a href="<?php echo $row['ImageURL'];?>"> <img src="<?php echo $row['LinkURL']; ?>"> </a>. "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> Can you guys point me in the right direction? Many thanks I want to open my small platform to developers, so they can build applications that could be inserted in our site as iframe. Similar as facebook is doing. From what I understand developers can build facebook application using iframe. Question: I am wondering how is about security from facebook user perspective. How Facebook prevent that application developer doesn't put malware javascript code inside iframe. I haven't noticed any automatically mechanism that prevent including something like that in iframe. But since iframe is shown on their site, this is risk. Do they just leave and if somebody report suspicious application they remove it? Or is there any other way to prevent this before it happens? Tnx for any responses Hello everyone, I am working on a form that is similar to a shopping cart system and I am thinking of creating a button that submits the checked value and saves them to a $_SESSION variable. And also a link that links to a cart.html that takes the values of a $_SESSION variable. I am have trouble figuring what tag/attribute should I use in order to achieve that.
Right now my code attached below submits the checked values to cart.html directly. However I want my submit button to save the checked box to a $_SESSION variable and STAY on the same page. And then I will implement a <a> to link to the cart.php.
I researched a little bit about this subject and I know it's somewhat related to ajax/jquery. I just wanted to know more about it from you guys. I appreciate your attention for reading the post and Thanks!
Below is the form that I currently have:
<form name= "finalForm" method="POST" action="cart.php"> <input type="Submit" name="finalSelected"/> <?php foreach($FinalName as $key => $item) {?> <tr> <td><input type="checkbox" name="fSelected[]" value="<?php echo htmlspecialchars($FinalID[$key])?>" /> <?php echo "$FinalID[$key] & $item";?> </td> </tr> <?php } ;?>Below is the code for cart.php <?php require ('connect_db.php'); if(isset($_POST['finalSelected'])) { if(!empty($_POST['fSelected'])) { $chosen = $_POST['fSelected']; foreach ($chosen as $item) echo "aID selected: $item </br>"; $delimit = implode(", ", $chosen); print_r($delimit); } } if(isset($delimit)) { $cartSQL = "SELECT * from article where aID in ($delimit)"; $cartQuery = mysqli_query($dbc, $cartSQL) or die (mysqli_error($dbc)); while($row = mysqli_fetch_array($cartQuery, MYSQLI_BOTH)) { $aTitle[] = $row[ 'name' ]; } } ?> <table> <?php if(isset($delimit)) { $c=0; foreach($aTitle as $item) {?> <tr> <td> <?php echo $aTitle[$c]; $c++;?> </td> </tr> <?php }}?> </table> Hii i want to create an api of the short url site ( http://torrentz.0fees.net ). In the api page it is says that Code: [Select] API Our API allows you to provide short url functionality to any of your existing websites. Url Only To generate a url via the API, send a POST or GET request to the site in the following format: - http://torrentz.0fees.net/index.php?api=1&return_url_text=1&longUrl={URL} This site will then generate the short url and return it as plain text. i.e: - http://torrentz.0fees.net/a1 I have created an form but not able to use it. The form script is shown below. Code: [Select] <form name="input" action="html_form_action.asp" method="get"> Username: <input type="text" name="user" /> <input type="submit" value="Submit" /> </form> Whenever i'm putting the ( http://torrentz.0fees.net/index.php?api=1&return_url_text=1&longUrl={URL} ) it shows an error. I know that the input url must be used in the ( {URL} ) section but how can i do that using php Can anyone help me with code... hi, I'm currently trying to resize and create pictures and .jpg/jpeg & .gif works perfectly but .png just creates an empty 0bit image, why?! Code: [Select] $ = imagecreatefrompng(); imagecopyresampled(); imagepng(); I'm doing something like that and it - as said - works great with .jpg and gif but at png it just fucks up. :/ HOw to create this header?
I give +. thx
http://i.snag.gy/15Ep4.jpg
For the life of me I can not figure out why this is not creating the table in the database. Second set of eyes would be great.
function install_kudos() { global $wpdb; $table_name = $wpdb->prefix . 'acikudosnew'; if ($wpdb->get_var('SHOW TABLES LIKE ' .$table_name) != $table_name) { $sql = "CREATE TABLE $table_name ( kudoid int(9) NOT NULL AUTO_INCREMENT, kudomsg text NOT NULL, kudoagent text NON NULL, kudocust text NOT NULL, kudoacct int(16) NOT NULL, kudoclient varchar(100) NOT NULL, kudoloc text NOT NULL, kudoentry TIMESTAMP DEFAULT CURRENT_TIMESTAMP, kudoadmin text NOT NULL, kudopic varchar(55) DEFAULT '' NOT NULL, PRIMARY KEY (kudoid) )"; require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); dbDelta( $sql ); } } register_activation_hook(__FILE__, 'install_kudos');
I would like to create something like foursquare badges. When ppl upload files, the most downloaded files will have a new badge, how do i create that? I'm using a php $_POST variable as the name of a file that I want to create. fopen() , according to my understanding open the file if it exists or creates it if it doesn't. $Ref = $_POST['Ref']; I using each reference element of $Ref as the name of a file in a certain directory. So if $Ref[$i] exists as a file name in a certain directory, append to the file, if it doesn't create the file in that directory and write to it. Do I use the file path of the file within fopen()? fopen(./References/$Ref,a) or fopen(./References/$Ref,w)? Hey Everyone, I need to have the ability to create PDF/X1A documents. My initial thoughts are it would be easy as i have created PDFs in the past with no hassle. I have been trawling the google and various blogs but with no joy. Does anyone have any experience creating PDF/X1A documents in PHP ? Is it possible ? Regards, -Ben |