Creating An Image
I am making a links page for my site that takes the links out of the database and displays the name on a button, but the text on each button is different lengths and I was wondering if there was a way I could align them center on the button?
This is the button.php code:
<?php
header ("Content-type: image/png");
$string = $_GET['text'];
$im = @imagecreatefrompng ("button1.png");
$text_color = imagecolorallocate ($im, 255, 255, 255);
imagettftext($im, 10, 0, 5, 35, $text_color, "c:phpfontsariblk.ttf", "$string");
imagepng ($im);
imagedestroy($im);
?>
View Complete Forum Thread with Replies
Related Forum Messages:
Creating Watermark With Another Image & Resizing Watermarked Image
I have a script that watermarks an image; it adds a transparent gif over my base image. I also have a script to resize my image. But here is where the problem comes in; these are two different scripts - none of the code will interconnect (variable wise - that is), so I am having a problem trying to piece together a PHP GD Image code that will create a watermark and will then be resized. Below is my code for resizing my image, but from there - I know I need to use imagecreategif somewhere and imagecopy somewhere; but where, I do not know. Code:
View Replies !
Creating Image From Uploaded Image And Transparent PNG
Say the client wants to be able to change the image, but not the text treatment, and doesn't have the Photoshop knowledge to actually replace it and re-save it themself. Is there anyway to use a PNG with the rounded edges, text treatment, and transparent center, have the client upload a standard rectangular-shaped image, and use PHP to layer the uploaded image underneath the transparent one, creating a new image file?
View Replies !
Image Creating With PHP
I want to know how to make images created with PHP codes. I tried PHP.net but saw nothing there ;_; an example of what I want is: $img=ImageCreate(256,224); $c[bg]= ImageColorAllocate($img, 40, 40, 90); $c[bxb0]=ImageColorAllocate($img, 0, 0, 0); $c[bxb1]=ImageColorAllocate($img,225,200,180); $c[bxb2]=ImageColorAllocate($img,190,160,130); $c[bxb3]=ImageColorAllocate($img,130,110, 90); I took that from an existing file. there is much more than that too.
View Replies !
Creating A Image Gallery
I'm working on a image gallery and I can't figure out the best way to do it. Is it such a good idea to store all images on a MySql database or locally? If i'm going to store images on a MySql database, how is this done, can you upload a whole directory? Right now it's coded to load images locally but then comes the problem how to sort everything up, like show 10 images per page, 5 per row etc. I would like any sugguestions on this. And one more thing, how do I display more than one image per row? Not sure if that's making any sense but here's the code i'm using:
View Replies !
Creating An Image File With Only PHP
Is it possible to create an image file from a string using only functions from core PHP (in other words, without 3rd party libraries/applications)? I'm interested in any image file that is displayable without plugins or helper applications, like jpg, png, gif.
View Replies !
GD Creating A Watermarked Image
I wrote a function which watermarks an image. The function works, but i can't figure out how to output the image into a file. I want to feed this function a URL, $image..and at the end of this code, I want to overwrite the $image file with the new watermarked $image file. Im getting an error stating that this file cannot be opened. <?php function watermark($image) { //$image = $HTTP_GET_VARS['image']; // Useful if using in an img tag to call images //$image = str_replace(array("/", ".."), "", $image); // Prevent abuse $overlay = '/home/httpd/vhosts/picmonkey.com/httpdocs/ADMIN/overlay.png' $dir = '/home/httpd/vhosts/picmonkey.com/httpdocs/IMAGEUPLOADS/' // A default image for the demo...remove if you wish. // Set offset from bottom-right corner $w_offset = 0; $h_offset = 0; $extension = strtolower(substr($image, strrpos($image, ".") + 1)); // Load image from file switch ($extension) { case 'jpg': $background = imagecreatefromjpeg($image); break; case 'jpeg': $background = imagecreatefromjpeg($image); break; case 'png': $background = imagecreatefrompng($image); break; case 'gif': $background = imagecreatefromgif($image); break; default: die("Image is of unsupported type."); }
View Replies !
Creating And Presenting An Image In Php
Maybe this isn't really a PHP problem. But it's possible that PHP has a good solution for it. I have a php page which collects some input from the user, constructs an image, and then displays it to the user. The line of php that does the actual presentation to the user is: print "<a href='$string'><img src='$string' width=784 height=431 border=0></a>"; where $string is something like 'r.pl?ar=7;cl=10' so the user gets to see a (large) thumbnail, and can then click on it to see the full-sized version. (The actual nitty-gritty of the image creation is done in Perl not PHP. I wrote it before I became more familiar with PHP and learned that PHP uses the GD library. I could rewrite it into PHP if I have to.) My problem is that my code calls r.pl twice, to do the same thing: once when the page is created, and once when the user clicks on the image. This wastes quite a bit of cpu time on the server, and slows the response for the user. What I would prefer to do is call r.pl once, put the resulting image in some kind of temporary session-specific file on the server (or in its memory), and then use this temporary thing twice, in place of $string above. Is this somehow possible?
View Replies !
Creating A TIFF Image
I just wondered if there was a function to create a TIFF image using either Image Magick or the GD Library? I have searched through the PHP manual, this forum, blogs and Google and Can't find anything of any use. I thought that imagetiff() might work, but no such luck.
View Replies !
Dynamically Creating A Image
I need to dymaically create a thumbnail button that when the user clicks on it, it does 2 things so i need to call php to echo out <a href commands 1. links to another page called (page1.php) 2. popup another page in new browser called (page2.php) but set this popup in the background but the problem is <a href only allows 1 page to be linked how do i do the above? can anyone show me an example of what should be written in the php echo command?
View Replies !
Creating Image With, And Set Its Date?
I have a partially built image gallery using PHP and MySQL, each image is uploaded, resized and then thumbnails created etc. All this works fine, but I would really like to give the resized photos their original date, but as I am resizing them they are created with the current date. Is there any way to give a resized photo a different date than the time it is resized?
View Replies !
Dynamically Creating An Image With Imagecreate()
I have a multitude of images that I am trying to bring up dynamically depending on the scenario. These images are different sizes. To complicare things just a little more, I am rewriting a javaScript. Am I heading into the correct direction? Here is the original JS that I am attempting to rewrite: (This is most of the way translated to PHP)
View Replies !
Creating An Image Out Of Multiple Images
I have some questions regarding image manipulation: - Is it possible add an alpha channel to an image via PHP? - Can I multiply an image with another image creating a new image? I want to create border with transparency around images uploaded to an photalbum.
View Replies !
Creating An Hyperlink From A Sql Query Image
I have an sql query that pulls an image filename out and displays that image. echo "<img src='/images/thumbnails/{row["Filename"]}' width='75' height='50'>"; I have another images folder with the larger pictures, they also have the same filename. What I'm trying to do with no success! is for the thumbnail image displayed from the query be an hyperlink to a blank page and display the larger image.
View Replies !
Creating An Image From An Array Of Raw Data
I have an array of numbers (which I shall be manipulating server-side), which I wish to convert into an image. The elements of the array are essentially the 1D subscripts of a 256*256 image. I've been looking at the GD library functions all day, but I can't seem to translate the array to a jpeg or png or whatever. (The GD library functions are working though.) It seems that creating an image from another image is easy, but not from the raw data. How can I make a greyscale image out of this array, scaled to the maximum pixel?
View Replies !
Problems With Creating A CAPTCHA Image
So our site is getting bombarded by spammers using our contact forms to contact our agents. My boss wanted me to try and stop it. I have a CAPTCHA image working on my desktop(WINXP running Apache with PHP Version 5.2.4 w/ gd 2.0.34) where the image works fine. When I upload it to either of our two actual live servers(PHP Version 5.1.6 w/ gd 2.0.28 and PHP Version 4.3.9 w/ gd 2.0.28), there comes 1 of 3 problems. Code:
View Replies !
Creating Thumbnail From Uploaded Image
i have an upload form and when i upload an image, i want the image i upload to go into a directory i have "photos/"(the upload form already does this...) and i want a copy of the image to be resized to 39x51 and put into a diff. directory "photos/thumbs". Any suggestions? here is my current code:
View Replies !
Creating An Image - Speed Issues
I am writing a gallery script and use imagecreatefromjpeg and fpassthru to output images without any change to them (i.e., no thumbnail creation etc. - just deliver the image via the php script). However I note that the image creation is quite slow - the user can see that the image is created line-by-line, from top to bottom. Code:
View Replies !
Creating A Unique Image Name On Upload
I have a MySQL database which holds information about a number of images, and I want to display these images in PHP pages. I'm trying to write an upload page which will add images to this database, but in order to store a unique pathname/url for each one I need to create a unique name - or prefix - for each image as it is uploaded, and which is not already in the database.
View Replies !
Passing Variables To An Image Creating Php File
I have been working with the gd functions in PHP to render an image. I was able to solve the (apparently) usual header problems and such like via searching through this page and help documentation, such that I am now able to produce an image by doing the following : Code:
View Replies !
Creating Links To Image Files Automatically
I was told I need to do this with PHP but I have no idea how or where to begin.. I need some kind of explanation or tutorial "PHP for idiots" Here is what I would like to do... I create images and want to be able to post them on my website.. But I want to post the links to the images... Not the images themselves.... On one directory in my file manager.. I have just about 200 images... How would I go about adding a link to each of those images to my website without having to individually copy and paste the link... Code:
View Replies !
Creating Image/area Maps On Dynamic Images
I'm generating a dynamic image on a website (using php.net/image library) and I want add hyperlinks to certain locations on the image - similar to HTML image map. Could someone pls suggest me a good way of doing this - with/without having to store the dynamic image.
View Replies !
Creating An Image With Multiple Text Lines / Wordwrap Using Imagettftext
I am in the process of creaing my first image using the GD library and imagettftext. I have got so far, but now hit a stumbling block. The process is as follows... User answers choices to create the text of a letter. Letter variables added to image?get Image called from page. I have got it all working fine apart from getting text to start on newlines when it reaches the end of a section. Code:
View Replies !
GD Functions - Creating A "Simple" Image
I want to create a "simple" square image at a variable height & width.. the image would be either transparent or perhaps use a background color.. And contain a "number" positioned in the top left corner maybe like: ----------------- - 1 - ----------------- Like I said "simple".. since I've yet to look into this, and I've yet to work with the gd library.. I'm wondering if someone can point me to some "examples".. Or perhaps, you already have a function to do just that.. I'm starting to work on a little calendar function, which I've written already.. I basically want to make it a little "schedular" app.. I want to create the image for an "onclick" event.. which opens a "view" of the selected day(s) event(s)... The image will give those (who use those "ancient" browsers) something to click on.. since some older browser do not support "onClick" event assigned to a table cell.
View Replies !
How Do I Get The Image Height Width When Generating Image From PHP (getimagesize Does Seem To Work)
Is it possible to obtain the width/ height of an image when that image is dyanically created using a PHP script and passing GET attributes. For example: <img src="images/showImage.php?image_id=5" /> My images are created from images stored on the server, their paths stored on in database table and retrieved using the GET image_id and PHP script (showImage.php). Because the images are different sizes I would like to be able to use a PHP function / class that can take an image path and generate the IMG width and height attributes. This would just tidy up the page when loading. So when I try to use PHP 'getimagesize' like so: $wh = getimagesize ($_SERVER['DOCUMENT_ROOT'] . "/images/showImage.php? image_id=5"); .... I get an error saying that the file or directory does not exist: Warning: getimagesize(/customersites/0/home/httpd/vhosts/ mydomain.co.uk/httpdocs/images/showImage.php?image_id=5): failed to open stream: No such file or directory in /customersites/0/home/httpd/ vhosts/mydomain.co.uk/httpdocs/classes/html.class.php on line 11 I thin it may be the GET atttribute that is throwing it. How would I go about doing this?
View Replies !
Determine Image Information On Image Stored In MySQL BLOB
I store images in my DB as BLOB. When I want to place them in an html table, I want to determine the width of the image in order to asign the correct width to the column inside table. For JPEGs this is working fine, this is my code: $image = @imagecreatefromstring($r["foto"]); return @imagesx($image); where $r["foto"] is the field selected from the db which contains the image. For GIFs however, its getting really on my nerves !! I know imagecreatefromstring is not supported in gd2 and I tried several thinks. None of them worked ! : - $temp = tmpfile(); list($width, $height, $type, $attr) = getimagesize($temp); echo $attr; gives me :Warning: getimagesize: Unable to open 'Resource id #6' for reading - $handle = fopen("/tmp/tmp.dat", "w+"); fwrite($handle, $r["foto"]); list($width, $height, $type, $attr) = getimagesize($handle); echo $attr; gives me : Warning: getimagesize: Unable to open 'Resource id #6' for reading - Doing this with imagecreatefromgif($temp); wont work either ! Can somebody help me out please? by telling me what I'm doing wrong or what I should do.
View Replies !
Script To Post A Placeholder Image If Image Is Not Found On Server
I'm creating a site with an archive of photo galleries, and on each gallery page i'm looking to have a sidebar that shows a cross-section of other galleries in groups of 10, via thumbnails... except that sometimes, the updated galleries won't actually be there yet, so i'd like to have a script that basically looks for "set053/001.jpg", and if that image hasn't been uploaded, then a placeholder image saying "coming soon" would be shown. Ugh, that's a horrible descrition. Here's the outline of it: -Say there are 52 photo sets (updates will be made regularly). -If you're on any gallery between 1 and 10, this "sidebar" will show thumbnails of the other galleries within that group of 10. -On a gallery between 11-20, you'll see the sidebar thumbnails for galleries 11-20... and so forth. -But on the most recent set of 10, in this instance galleries 51-60, the galleries 53 thru 60 haven't yet been uploaded, so having a static sidebar that shows "galleries 51-60" would yeild broken images for the thumbs for 53 - 60 right now. So hopefully that made more sense... basically, if PHP can find "set053/001.jpg" on the server, it shows it. If it can't, then have it show something like "images/comingsoon.jpg".
View Replies !
Writing A Blob Image Out To A File - Jpg Image Looks Weird?
I've got simple watermarking working. I write a Blob image out from my db to a temp file and then overlay the watermark image to create 1 whole image. The watermark is perfect, but the exported blob behind it looks all garbled - parts are visible but its not right! I've looked at the temp file thats created by the line "fwrite($t_img, $data);" and the image looks corrupt, but displaying this field using usual php methods the blob looks fine..... Here's the code :- @MYSQL_CONNECT("$server","$user","$password"); @mysql_select_db("$database"); $query = "SELECT image, mime_type, image_width, image_height FROM items WHERE ID='$id'"; $result = @MYSQL_QUERY($query); $data = @MYSQL_RESULT($result,0,"image"); $type = @MYSQL_RESULT($result,0,"mime_type"); $image_width = @MYSQL_RESULT($result,0,"image_width"); $image_height = @MYSQL_RESULT($result,0,"image_height"); // Write blob data out to temp image file to prep for Watermark // creating a temp image name $t_img_name = tempnam ("./temp", "timg"); $t_img = fopen($t_img_name, "w"); // $content is the blob field with the image. fwrite($t_img, $data); fclose($t_img); //-$size = getimagesize($t_img_name); //echo $size[0]." - ".$size[1]; $img = imagecreatefromjpeg($t_img_name); $watermarkImage = 'images/watermark2.png' $x = 165; $y = 130; imagesetbrush($img, imagecreatefrompng($watermarkImage)); imageline($img, $x, $y, $x, $y, IMG_COLOR_BRUSHED); imagejpeg($img); // End of watermark protection // don't forget to delete the temp file after all. //unlink($t_img_name); $type = "image/jpg"; if(strlen($data) < 1) { header("Location: ./images/nopicsubmitted.jpg"); } else { //header("Content-type: $type"); header("Content-Type: application/octet-stream"); echo $img; } Can anyone spot if i've made a mistake, used wrong function or syntax etc?
View Replies !
Resize Uploading *.gif Image For Image Display And Thumbnail
how to resize the uploading *. gif image...for display image size and thumbnail size...Okay I know how to do a uploading image...only for resizing part kind of lost it...because I find all tutorial not suit for what I look after..Ok the idea is.. when I upload image ..the php will resize the image into two type size and put into two folder "folder for images" and "folder for thumb" and size for all this type of image are...images = 100x100 thumb = 80x80 with same name file.
View Replies !
Get Image From DB Fails. Image Are Not Returned Correctly.
I have a problem retreiving images from a MSSQL 2000 database with php. I wrote an ASP page using "response.binarywrite" to get the same image, and this worked 100%. Therefore, the images in my database is not corrupt. Only the top part of the image is returned to the client's browser window. Same result with both IE6 and Opera 7.11. I guess the problem is header related, and I've tried to output different headers with no luck whatsoever. Here is my php code: getimagefromdb.php ----------------------- <?php error_reporting(E_ERROR); header("Content-type: image/jpg"); $sql_servername = 'name_of_dbserver' $sql_user = 'sql_user_name' $sql_userpw = 'sql_user_password' $db = 'database_name_where_images_is' $query = "SELECT coverImage FROM dvds WHERE id = ".$_GET['ID']; if (false != $conn = mssql_connect($sql_servername,$sql_user,$sql_userp w)) { mssql_select_db($db,$conn); $rs = mssql_query($query,$conn); $arrImage = mssql_fetch_row($rs); mssql_close($conn); echo $arrImage[0]; } ?> Next is a simple example of a page requesting image with ID=1: index.php ----------- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252" /> </head> <body> <table> <tr> <td> Image: <img src="getimagefromdb.php?ID=1" /> </td> </tr> </table> </body> </html>
View Replies !
Building An Image Tag Using An Image From A Diffrent Site
I am trying to edit a code so that images that are placed using a wysiwyg editor (live linked) would display, as of now only images residing on your server that are are displayed. What would I change so that it could assemble the tag from anywhere, not only from my site ($mosConfig_live_site)? Code:
View Replies !
Image Upload Problem - New Image Not Displaying
I have a consistent problem that needs knocking on the head. I have an image upload script that uploads an image and replaces the old image. The image that is displayed is sometimes that old image and the page must be manually refreshed to get the new one. I need the new image to be displayed with out have to manually refresh the page. So far I have identified the following: • Ive been testing in ie and firefox – the problem only happens in firefox. • If the upload script is activated more than once it works as desired – but not the first time. I need it to work the first time. • I have set the page to automatically refresh. – this works in ie, but firefox still needs a manual refresh. • I’ve included the following which makes no difference: • header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); • header("Cache-Control: no-cache"); • header("Pragma: no-cache");
View Replies !
Using Exec To Rotate And Lays An Image Over Another Image.
I'm using exec to rotate and lays an image over another image. Here's the command: composite -compose atop -geometry 200x200+10-10 "tmp/img1.tmp" -matte -background none -rotate 67 "tmp/img2.tmp" "tmp/img3.tmp" It works in the newer version of imagemagick, but not the old. Anyone who can help me with a new command?
View Replies !
Image Array, Display One Image, With 'Next' Button
I need help building an array and have it display the $row[i] based on a $_GET variable number in the URL- I want to show one image from an album and have a 'NEXT' button so that I can cycle though all the images in that album. This is a very small/simple gallery, all images will be in one table as shown below. Code:
View Replies !
Borken Image.. At The First Time..refresh The Image
I have one problem regarding broken image.. The problem is quite mystery.. It's happen to other user pc only (the page that we browse reside at the same server)..not at my pc.. it never happen.. When other user go to the url. the face the broken image at the first time and need to refresh their browser .. in order to see the image.. this is the e.g of the code.. Code:
View Replies !
Imagejpeg Generating String Not Image Even With Header("Content-type:image/jpeg")
does anyone know why i can't generate images with: header("Content-type:image/jpeg"); imagejpeg($img_number); i've tried different examples but i always get a text output as if the header doesn't make a difference at all. <?php //random_number.php $img_number = imagecreate(100,50); $white = imagecolorallocate($img_number,255,255,255); $black = imagecolorallocate($img_number,0,0,0); $grey_shade = imagecolorallocate($img_number,204,204,204); imagefill($img_number,0,0,$grey_shade); ImageRectangle($img_number,5,5,94,44,$black); ImageRectangle($img_number,0,0,99,49,$black); header("Content-type:image/jpeg"); imagejpeg($img_number); ?>
View Replies !
Image Generation For Dynamic Image
I've implemented the PHP Online poll available on this site, and it works great. But I'd like to increase the number of responses from 3 to at least 4 or 6. I've already implemented my changes to the MySQL DB, and all PHP code am having problems changing the graph.php code to all for 4 responses. It does the calculation correctly for the printed text, but nothing for the dynamic image. Any suggestions?
View Replies !
|