PHP - Creating Images In Php: Drawing Rectangles.
This is so hard. :/
I have the following code: Code: [Select] <?php $signature = @imagecreate(350,60); $image_generate = imagecolorallocate($signature,84, 84, 84); $red = imagecolorallocate($signature,255,36,0); imagefilledrectangle($signature, 0, 1, 150, 30, $red); header("Content-type:image/png"); imagepng($signature); ?> How can I get the rectangle in the center? http://zchighscores.99k.org/image.php I don't really know what to change to get it in the right coordinates. :/ Similar TutorialsHere is my code:
for($i = 1; $i <= 30; $i++){ $pos1 = mt_rand(1,900); $pos2 = mt_rand(1,100); echo '<div class="itemLootBox Unique fadeIn" onclick="lootItem(this)" style="position:absolute;left:'.$pos1.'px;top:'.$pos2.'px">Lunar Rock</div>'; }The dimensions of that container is: Width: 980px Height: 130px. These correspond with $pos1 and $pos2 respectively. I reduced 980 to 900 for the mt_rand because the boxes look weird when they get positioned to the edge. And my problem is, the divs are being randomly generated, but sometimes overlap others. Is there a way to add a function / if statement so I can check against $pos1, and $pos2 to add spacing so the boxes will never overlap? (They don't have to never overlap, but some type of padding would be way better). Edit: Try to think of it as a grid like system, and each rectangle has it's own box of it's 'own' if you will. Wheres there is a padding around each grid. Not sure how to do this Edited by Monkuar, 07 December 2014 - 12:41 AM. I want to create an image using pre-existing image files. I want to use more than one file, otherwise I would use the imagecreatefromjpg function. What function should I use to create an image using a for statement to determine how many of each image is being displayed in the new image? Hello all I have a requirement to create images mostly made up of rectangles circles and squares etc I have discovered imageline but is there anything a bit more exspansive? So, We are trying to create a animation using the gifs in a directory by using the first 10 images. We just cannot figure out how to do the animation.. needs to have a 3 second delay between each frame Heres the code at the moment. Which creates the starting images and also sorts the images in the directory by time.. <?php $time = date("YmdHis"); $handle_data = file_get_contents('http://www.bungie.net/Stats/Halo3/Nightmap.ashx'); $img = new Imagick(); $img->readImageBlob($handle_data); $img->writeImage('nightmap/'.$time.'.gif'); foreach (glob('nightmap/*.gif') as $f) { # store the image name $list[] = $f; } sort($list);# sort is oldest to newest, $gif_0 = array_pop($list); $gif_1 = array_pop($list); $gif_2 = array_pop($list); $gif_3 = array_pop($list); $gif_4 = array_pop($list); $gif_5 = array_pop($list); $gif_6 = array_pop($list); $gif_7 = array_pop($list); $gif_8 = array_pop($list); $gif_9 = array_pop($list); ?> Hello guys. I'm kinda new to PHP, I've been understanding everything so far. I have trouble with "imagestring" What I want is to query a row in MySQL. I want to display some of that info in the image. It's not working properly. Here's the code: <?php $imagepath="css/images/dog.jpg"; $image=imagecreatefromjpeg($imagepath); $imgheight=imagesy($image); $color=imagecolorallocate($image, 255, 255, 255); include("config.php"); $result = mysql_query("SELECT * FROM playerinfo WHERE Level > 0 ORDER BY Level DESC", $connect); while($myrow = mysql_fetch_row($result)) { // Not working properly. imagestring($image, 5, 50, $imgheight-50, $myrow[0], $color); } // This line works like it should: //imagestring($image, 5, 50, $imgheight-50, "Using it like this works!", $color); header('Content-Type: image/jpeg'); imagejpeg($image); ?> Any help will be GREATLY appreciated it. Thanks! Hi all, Could someone help me add a thumbnail script to the below that works on scaling it down to 200px x 133px. I guess it is not that hard. <?php $destination='aircraft/'.$reg."1.jpg"; $temp_file = $_FILES['image']['tmp_name']; move_uploaded_file($temp_file,$destination); ?> Thanks This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=342341.0 Hi there, I am building a custom configuration program, where i want people to choose various items, e.g. 1. Size of a table, colour, how many drawers, other features. I want to store all my options in mysql tables. At the end of the process I want to somehow get mysql to get line co-ordinates from a table and dynamically draw a plan view and elevation view of the table showing the options that the customer has chosen. I was wondering if anyone has ever been able to do this. I'm not sure how to start, or if php is capable of doing this. any ideas would be great. I have this script from http://lampload.com/...,view.download/ (I am not using a database) I can upload images fine, I can view files, but I want to delete them. When I press the delete button, nothing happens
http://www.jayg.co.u...oad_gallery.php
<form>
<?php $dir = dirname(__FILENAME__)."/images/gallery" ; $files1 = scandir($dir); foreach($files1 as $file){ if(strlen($file) >=3){ $foil = strstr($file, 'jpg'); // As of PHP 5.3.0 $foil = $file; $pos = strpos($file, 'css'); if ($foil==true){ echo '<input type="checkbox" name="filenames[]" value="'.$foil.'" />'; echo "<img width='130' height='38' src='images/gallery/$file' /><br/>"; // for live host //echo "<img width='130' height='38' src='/ABOOK/SORTING/gallery-dynamic/images/gallery/ $file' /><br/>"; } } }?> <input type="submit" name="mysubmit2" value="Delete"> </form>
any ideas please?
thanks
Hello everyone, I found a tutorial on creating a pdf with php and I just tried to create a basic pdf to see if it worked and modify it from there. Here is the link to the tutorial: http://www.astahost.com/info/tfclt-create-pdf-php-create-fly-pdf-web-server.html Well, after uploading the following php file to the server and testing it, I got this error: Fatal error: Call to undefined function pdf_new() in /home/caresa6/public_html/BubblyBounce.com/admin/pdftest.php on line 2 Here's the code that produced the error: Code: [Select] <?php $mypdf = PDF_new(); PDF_open_file($mypdf, ""); PDF_begin_page($mypdf, 595, 842); $myfont = PDF_findfont($mypdf, "Times-Roman", "host", 0); PDF_setfont($mypdf, $myfont, 10); PDF_show_xy($mypdf, "Sample PDF, constructed by PHP in real-time.", 50, 750); PDF_show_xy($mypdf, "Made with the PDF libraries for PHP.", 50, 730); PDF_end_page($mypdf); PDF_close($mypdf); $mybuf = PDF_get_buffer($mypdf); $mylen = strlen($mybuf); header("Content-type: application/pdf"); header("Content-Length: $mylen"); header("Content-Disposition: inline; filename=gen01.pdf"); print $mybuf; PDF_delete($mypdf); ?> Can anyone help me figure out what to do from here? I have some PHP knowledge, but I'm treading in uncharted waters with this, so I am totally lost. Thanks in advance. Write a class for feeding a horse. The Horse object should keep track of the last time it was fed and calculate when it is hungry. Assume there is another class that checks the horse every 10 minutes to see if it is hungry and if it is, it calls another method which feeds it. There should be about 3 methods on the class, but more can be added if needed. Hi All
I have a a directory website but numereous listings don't have their own website so they are requesting a single page to show a summary of their business and products.
I know how to do most of it the part I am unsure of is:
I have a form where they upload text, images, etc to a database and upload the images. what I would like to do is to save it as a file under a subdirectory. Is it possible to save a file php file using php
Thank you in advance
Lional
hi i open this post so i dont open 5 new ones ok i have a task to do an event calendar now i found some tutorial for creating simple calendar BUT all of them are on english what i need is change it to croatian - that means i have custom names for days, custom names for months, and what i also need is put sunday where it belongs... at the end because we are calculating week starts by monday... so any tips? if you know some tutorial that works for these spec things i googled it but i only found like 2 calendars that actualy works other have some bugs in scripts and wont do thing or just write me tips and ill try to create it Does anybody know a good tutorial for creating thumbnails for these three file extensions "jpg, gif and png" in PHP?
I am only finding ones for "jpg".
i am able to create csv's and can do so with no trouble .. but what i am having difficulty with is being able to auto save the csv and then email it all in one script. anybody every dealt with something like this? Hi, I need help please with creating a cron job. I have the following sql commands that need to take place within the cron job. This is all i need to do every couple of hours, thus the reason for a cron job. Code below: DELETE FROM tmpsessionmodule; INSERT INTO tmpsessionmodule (SessionNo, Module) SELECT SessionNo, Module1 FROM session WHERE ((Module1) <>"" ); INSERT INTO tmpsessionmodule (SessionNo, Module) SELECT SessionNo, Module2 FROM session WHERE ((Module2) <>"" ); INSERT INTO tmpsessionmodule (SessionNo, Module) SELECT SessionNo, Module3 FROM session WHERE ((Module3) <>"" ); INSERT INTO tmpsessionmodule (SessionNo, Module) SELECT SessionNo, Module4 FROM session WHERE ((Module4) <>"" ); INSERT INTO tmpsessionmodule (SessionNo, Module) SELECT SessionNo, Module5 FROM session WHERE ((Module5) <>"" ); INSERT INTO tmpsessionmodule (SessionNo, Module) SELECT SessionNo, Module6 FROM session WHERE ((Module6) <>"" ); INSERT INTO tmpsessionmodule (SessionNo, Module) SELECT SessionNo, Module7 FROM session WHERE ((Module7) <>"" ); INSERT INTO tmpsessionmodule (SessionNo, Module) SELECT SessionNo, Module8 FROM session WHERE ((Module8) <>"" ); INSERT INTO tmpsessionmodule (SessionNo, Module) SELECT SessionNo, Module9 FROM session WHERE ((Module9) <>"" ); INSERT INTO tmpsessionmodule (SessionNo, Module) SELECT SessionNo, Module10 FROM session WHERE ((Module10) <>"" ); INSERT INTO tmpsessionmodule (SessionNo, Module) SELECT SessionNo, Module11 FROM session WHERE ((Module11) <>"" ); INSERT INTO tmpsessionmodule (SessionNo, Module) SELECT SessionNo, Module12 FROM session WHERE ((Module12) <>"" ) Can someone please help me!! Any assistance will be greatly appreciated. Thanks! Can anyone guide me on how to create thumbnails with php/gd. I'm trying to use gd to create thumbnails and then store in in my server. I'm currently using a function in my script, but some thumbnails come out black. Here's part of the code: if (($extension == "jpeg") || ($extension == "jpg")) $originalImage = ImageCreateFromJPEG($sourceImagePath); elseif ($extension == "gif") $originalImage = ImageCreateFromGIF($sourceImagePath); elseif ($extension == "png") $originalImage = ImageCreateFromPNG($sourceImagePath); elseif($extension == "bmp") $originalImage = ImageCreateFromWBMP($sourceImagePath); // removed since Windows BMP is not supported $newImage = ImageCreateTrueColor($new_x, $new_y); ImageCopyResampled($newImage, $originalImage, 0, 0, $srcx, $srcy, $new_x, $new_y, $srcw, $srch); ImageJPEG($newImage, $imagePath, $outputImageQuality); ImageDestroy($newImage); ImageDestroy($originalImage); How hard would it be to build a Private Message system where the PM's are encrypted in my database? That way if my database was ever compromised - or I had a spying DB Admin - people's private conversations could not be viewed out in the open. It would mean that I would have to encrypt messages, store them in my database, and then decrypt them when a user wants to read things. Just curious... Thanks, Debbie I want to create a REST API for my website. What I want to do is to display advertisements from my database on websites that I sell to clients. Their website will call my database for advertisements to display on their websites. Also, I am performing a site validity check where the client's site would send the site URL, site name, and site token to my database for validation. If it returns false then the site will not display as it will be invalid according to my database. I've been Googling this topic all day, but cannot seem to get my head around it. I want to set an API key on my website so that not just anybody can be querying my database. For the advertisement query, no parameters need to be sent from the client websites to my database. Can anyone offer some advice on how to do this? |