Jump to content

fruzzgle

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

About fruzzgle

  • Birthday 02/01/1993

Contact Methods

  • AIM
    fruzzgle

Profile Information

  • Gender
    Male
  • Location
    KS City :]

fruzzgle's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello, you don't know me and I don't know you, but i'm a member of the W3Schools forum and I'm just spreading around my EasyImage class to the php communities. Enjoy- EasyImage For a project I'm working on I've needed to generate images with php. I used the GD functions without any kind of organization and realized it was going to be very hard to manage. So I've made a class called EasyImage that will manage your images a little easier and you can organize it better this way. Since it was going so well I decided to add some more functions, fill in the gaps, and share with you guys on W3Schools php freaks . I'm not sure if there is already something like this out there, if there is then I guess I've just wasted my time. Regardless, I will still use my own class instead. I'll provide an api of the class and a download link. It may be a little buggy, incomplete, and I still have lots of ideas for it so give my your suggestions and bug reports and I will work on them. But 90% of this version is just a repackaging of the already present functions (in an easier to use way of course). Thank you for your support! Class EasyImage //IMAGE function addLayer($EasyImageObject, $x, $y, $opacity) function antialias($boolean) function closeImage() function cropImage($xStart, $yStart, $xEnd, $yEnd) function resizeCanvas($width, $height) function resizeImage($width, $height) function rotateImage($degrees, $hexColor) function scaleImage($amount) function setTile($EasyImageObject) function setTransparentColor($hexColor) function scaleX($amount) function scaleY($amount) //DRAW function drawArc($x, $y, $width, $hheight, $start, $end, $lineThickness, $hexColor) function drawEllipse($centerX, $centerY, $width, $height, $lineThickness, $hexColor) function drawLine($xStart, $yStart, $xEnd, $yEnd, $lineThickness, $hexColor) function drawCircle($centerX, $centerY, $radius, $lineThickness, $hexColor) function drawPixel($x, $y, $hexColor) function drawPolygon($polygonArray, $offsetX, $offsetY, $hexColor) function drawRect($xStart, $yStart, $xEnd, $yEnd, $hexColor) function drawString($String, $x, $y, $hexColor) //FILL function fill($hexColor) function fillArc($x, $y, $width, $height, $start, $end, $hexColor) function fillCircle($centerX, $centerY, $radius, $hexColor) function fillEllipse($centerX, $centerY, $width, $height, $hexColor) function fillPolygon($polygonArray, $offsetX, $offsetY, $hexColor) function fillRect($xStart, $yStart, $xEnd, $yEnd, $hexColor) //FILTER function adjustBrightness($amount) function colorize($red, $green, $blue, $alpha) function contrast($amount) function edgeDetect() function emboss() function gaussianBlur() function grayScale() function invert() -AKA: Negative function meanRemoval() -AKA: Sharpen function selectiveBlur() function smooth($amount) //OBJECTS Class EasyGIF extends EasyImage function loadImage($source) function printImage(); function saveImage($destination) Class EasyPNG extends EasyImage function loadImage($source) function printImage(); function saveImage($destination) Class EasyJPG extends EasyImage function loadImage($source) function printImage(); function saveImage($destination) I would love to go through and give a description and example image of each function. But I don't want to spend another 2 hours doing it. Instead I will give you some points that I think you may need to know, giv you a few example codes, and show you how to use this file. Notes: Antialias: I've tested this function and have not gotten it to work. To my knowledge, it has to be enabled by the server first. I'm really not sure if anyone can get it working but it remains in case someone does. Draw Functions: For any draw function with the parameter $lineThickness, I recommend you always set it to 1 (for now). The method I use to create thicker lines didn't turn out the way I expected it to and I have a new algorithm in mind for it. I haven't gotten around to it though. You can try it, if you like the affect, use it! Rotate Function: This is also buggy. The $hexColor parameter is supposed to change the color of background that becomes visible as the image rotates. However, the color always shows as a dark greenish-blue for me. Maybe you will have more luck. setTransparentColor Function: I recommend calling this last or before you print or add a layer. If you call this function then, say, scale it 200% then you will not also scale the transparent color. So in this situation you would have to scale first, then use this function. Transparencies: Speaking of transparencies. If you are new to images for whatever reason, only gifs and pngs can support them. You can use it for jpgs only if the transparent area is over a opaque (fully visible), or over a gif or png image (at which point it will become part of the gif or png, no longer a jpg). Extended Objects: EasyGIF, EasyJPG, and EasyPNG are the only savable, loadable, and printable objects. If you create one you will still be able to use the EasyImage functions (are you new to objects?). The only use for creating an EasyImage object is if you aren't going to load, save, or print it. This can be used for layers. Examples: Basic Image- <?php include("EasyImage.php"); //We need this to start $Box = new EasyPNG(100, 100); //Make a new EasyPNG object that is 100x100 $Box->fill("FF00FF"); //Fill the whole space with a bright purple/pink color $Box->fillRect(25, 25, 75, 75, "00FF00"); //Place a green, filled rectangle at (25,25) to (75,75). $Box->drawString("A Box", 35, 50, "FF0000"); //Write the red words, "A Box", at position (35,50). $Box->scaleImage(3); //Make this 300% the original size $Box->setTransparentColor("FF00FF"); //Make that original color transparent. (It's ugly) $Box->saveImage("box.png"); //You're done- Go look at your image. ?> (imageshack image) Misc. Note: when naming objects, it's customary to capitalize every individual word. When naming variables and functions, it's customary to capitalize every word except the first. My Fish Image- This shows the whole purpose of PHP images. PHP GD isn't just-another-photoshop. It's much less powerful, slower, and harder to use in comparison, but there is one thing photoshop can't do- you can't create dynamic text inside (Number of downloads): <?php $Background = new EasyPNG(300, 150); $Background->fill("669999"); $Background->drawRect(0, 0, 299, 149, "33404D"); /*FISH*/ $fishColor = "75BAFF"; $transColor = "FF00FF"; $Fish = new EasyPNG(300, 150); //Make the background transparent (default is black) $Fish->fill("FF00FF"); //Head $Fish->fillArc(150, 75, 75, 75, 30, 310, $fishColor); $Fish->fillCircle(140, 65, 10, "FFFFFF"); $Fish->fillCircle(140, 65, 5, "000000"); //body $Fish->fillRect(45, 50, 130, 100, $fishColor); //Tail $Fish->fillCircle(40, 75, 35, $fishColor); $Fish->fillCircle(30, 75, 35, $transColor); //Legs (tiktaalik ftw) $Fish->drawLine(75, 100, 75, 120, 5, $fishColor); $Fish->drawLine(75, 120, 85, 120, 5, $fishColor); $Fish->drawLine(105, 100, 105, 120, 5, $fishColor); $Fish->drawLine(105, 120, 115, 120, 5, $fishColor); /*TEXT*/ $Text = new EasyImage(300, 150); $Text->fill($transColor); $Text->drawString("Generated with EasyImage |", 5, 130, "000000"); $Text->drawString(" Downloads: " . $downloads, 190, 130, "990000"); $Text->drawString("that's", 170, 30, "000000"); $Text->font = 5; //I don't have a setFontSize() function. You can do it manually like this. Sizes range from 1-5 (default is 3) $Text->drawString("MISTER", 180, 50, "000000"); $Text->font = 3; $Text->drawString("fish", 190, 70, "000000"); $Text->drawString("to you, buddy! D:<", 170, 90, "000000"); //put it all together $Fish->setTransparentColor($transColor); $Text->setTransparentColor($transColor); $Background->addLayer($Fish, -20, -10, 100); $Background->addLayer($Text, 0, 0, 100); $Background->printImage(); $Background->saveImage("fishimage.png"); ?> (imageshack image) With this you can create things like thumbnails, click/visit/download counters, captchas, game server info, etc. Download: http://mwilliamson9811.byethost24.com/geteasyimage.php Comments always appreciated. I know this sort of thing probably isn't in high demand but hopefully this doesn't turn into a ghost topic >< ENJOY
  2. I don't know if your going to get really made because I double post but- I changed the upload.php file and fixed the spelling error. I also made the folder name the same as the one in the script and added the thing to the error message. it still didn't work and the error message didn't display the type. Edit: invalid file array(0) { } What? I didn't use arrays!
  3. There is a folder set up called upload. I'm going to check to make sure the actual folder is upload and not uploads though @btherl: Thanks, I'll add those.
  4. Well, I'm having trouble with a file upload page. I just started really learning php today after many failed attempts to in the past. I'm using the w3schools tutorial to php, I already know xhtml, css, and a decent amount of javascript. http://groogstestpages.freehostia.com/upload.php Here is my failed upload test upload.php <html> <head> <title> Upload Test </title> <link href="upload.css" rel="stylesheet" type="text/css"> </head> <body> <div id="wrapper"> <form action="upload_file.php" method="post" encypte="multipart/form-data"> <label for="file">File:</label> <input type="file" name="file" id="file"> <input type="submit" name="submit" value="Upload"> </form> </div> </body> </html> upload_file.php <html> <head> <title> Upload Test Complete </title> <link href="upload.css" rel="stylesheet" type="text/css"> </head> <body> <div id="wrapper"> <?php if (($_FILES['file']['type'] == "image/gif") || ($_FILES['file']['type'] == "image/pjpeg")) { if ($_FILES['file']['error'] > 0){ echo "Error" . $_FILES['file']['error'] . "<br />"; } else { echo "Name: " . $_FILES['file']['name'] . "<br />"; echo "Type: " . $_FILES['file']['type'] . "<br />"; echo "Size: " . ($_FILES['file']['size'] / 1024) . "KB <br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; move_uploaded_file($_FILE['file']['tmp-name'], "upload/" . $_FILES['file']['name']); echo "stored in: " . "upload/" . $_FILES['file']['name']; } } else { echo "invalid file"; } ?> </div> </body> </html> I followed the tutorial like w3schools said, and I'm not the kind that copies and pastes code, I took an hour to write and understand this script. Seeing it's telling me it's an invalid file I'm thinking that means it has something to do with the beginning of the script- if (($_FILES['file']['type'] == "image/gif") || ($_FILES['file']['type'] == "image/pjpeg")) http://www.w3schools.com/php/php_file_upload.asp This is the w3 tutorial. I've taken out some of the script I didn't really want in there (like the size limit on files one)
  5. Edit: After much time and thought I fixed the problem.
  6. Oh that's ok. I found this program that a friend advised and it hooks up my apache and mysql for me. It's called EasyPHP. My localhost works great and everything works! [img]http://img208.imageshack.us/img208/4883/easyphp9fz.png[/img] There is one thing though, when ever I turn this program off and try to view the localhost it isn't accessible. When ever it's on I can, so if I turn it off will databases from my site (when I make a site) be able to connect to mysql through localhost? This may be a problem for me. Does this happen with apache too?
  7. Screenshot [img]http://img287.imageshack.us/img287/1527/apacheerror6db.png[/img]
  8. Ok, I'll restart. Durring the installation it asked for my site, I don't have one right now and am just learning the php so will it affect the installation or localhost if I didn't put anything in there. Edit: Ok I restarted and In my tasks bar I see the apache logo and when I click on it I get- apache 2.2 - start. When I try to start it, it says- "The requested Operation has Failed!". And my localhost still doesn't work. What do I do?
  9. Sure thing  :D btw: is there a web hosting site I can test my php scripts for free? Or will I be able to do that already with localhots/whatever.php? Edit: After installing it, it didn't work. Do I have to be on IE or can I do it on firefox?
  10. I downloaded apache but I can't install it. The install file doesn't know how to run itself (I think that's what it means when the file looks like this). [img]http://img206.imageshack.us/img206/3913/installerror2ik.png[/img]
  11. Yah, http://localhost doesn't work either. What do I need to set up?
  12. I type localhost in the adress bar and get nothing. How do I get localhost?
  13. I know there is this thing you can download and in most hosting plans they have a php admin. With the php admin you can create new databases, tables, quaries, and all kinds of stuff. But the php Admin really confuses me and I think It would be a lot easyer If I did it all manually. Lets say I want to create a users database, how would I do this- -What code is used to create new database (somthing like mysql_create_database or somthing). -And how do I run the code and create it. Do I make a new page for it and visit the page once- creating a new database? Thanks in Advanced.
  14. I'm a begginer and am taking a tutorial on it. I just started the MySQL connect. Here's my code: [code]<?php mysql_connect("localhost", "admin", "1admin") or die(mysql_error()); echo "Connected to MySQL<br/>"; ?>[/code] I test it and get this- Can't connect to local MySQL server through socket '/tmp/mysql.sock' (46) I have no Idea what this means?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.