PHP - Simple Image Overlay
hey guys im trying to impliment a overlay to images uploaded by the user to allow to delete and crop...now im not sure if im going aroung this the right way (but it works sort of)...the problem im having is that the overlay.gif which is a transparent image which has 2 small images at the top of each corner...but when the original image is hovered over the overlay is out of position showing the 2 small images at the bottom of the div and not at the top where it should be.
im guessing it is a css issue...any advise would be greatly appreciated...thank you
#overlay { width: 110px; height: 110px; } .selected-image{ width: 110px; height: 110px; } #overlay:hover .selected-image { opacity: 0.4; filter: alpha(opacity=40); } #overlay:hover { background-image: url('overlay.gif'); width: 110px; height: 110px; } <div id="overlay"><img class="selected-image" src="logo.png" /></div> Similar TutorialsHello. I'm currently trying to write a code to merge two separate images together, but for the life of me I can't find anything that works. Basically what I'm trying to do is add a "marking" (cat_stripes.png) to a pet image (cat.png). In the future I also want to use this for adding items to pets and things like that. Both of the images have transparent backgrounds, so that needs to be taken into account. If you haven't got a clue what I'm talking about, look up Wajas or similar virtual pet sites to get an idea of how the markings work. I just need something simple, since I don't have a site set up yet and I'm just testing some things out for a future project. I don't have any codes at the moment, since nothing has worked so far. I'm pretty new to GD too (I'm familiar with all the basic php stuff, so don't panic), so you might need to explain some of the more advanced stuff to me. Any help with this would be really appreciated, thanks. (: Here is the code I have right now:
<?php header('Content-type: image/png'); $grey = new ImagickPixel('#ebebeb'); $orange = new ImagickPixel('#0f92d6'); $image = new Imagick('assets/lop.png'); $layer = new Imagick('assets/lop-base.png'); $layer->thumbnailImage(200, 0); $image->thumbnailImage(200, 0); $layer->paintOpaqueImage($grey, $orange, 100); // Place layer on image $image->compositeImage($layer, Imagick::COMPOSITE_SOFTLIGHT, 0, 0); // Let's merge all layers (it is not mandatory). $image->flattenImages(); echo $image; ?>It's putting the layers on top of eachother very nice. The thing is is that this involves some heavy shading at times depending on the bunny breeds. Here is what the base image ($image) looks like: And here is what the overlay ($layer) looks like: This is what the outcome looks like versus the intended result: I've tried almost all of their composite constants.. I can't figure out how to do this or the best way of going about it. Because the colors are going to be dynamic throughout the site so I can't just save a .png of every color combination.. and there will be more colors layered on top of eachother like markings/patterns/etc. Thanks for any help! The code below works well and shows all the images in a folder in reverse chronological order. But I want to limit it to a certain number of images . This would enable me to have several pages of images. So the first page would display the latest 50 images, the second page would show 50-100, and the third, 100-150. Any helps on how to modify? I can create the pages manually. I just want to know how to limit the current page to a certain range. Code: [Select] <?php //Your folder $files = glob("images/*.*"); function sortnewestfilesfirst($a, $b) { return filemtime($b) - filemtime($a); } usort($files, "sortnewestfilesfirst"); $colCnt=0; echo '<table border="0" style="width:1000px;">'; for ($i=0; $i<count($files); $i++) { $colCnt++; if ($colCnt==1) echo '<tr>'; echo '<td width="20%" style="font-size:8.5px; font-family:arial">'; $num = $files[$i]; echo ' <div class="ImgBorder"> <div class="clipout"> <div class="clipin"> <a href="' . $num . '" rel="lightbox[all]"><img class="thumb ImgBorder" src="'.$num.'"> </a> </div> </div></div>'." "; echo '</td>'; if ($colCnt==6) { echo '</tr>'; $colCnt=0; } } echo '</table>'; ?> ok so ive found what looks to be a decent image uploader. which if anyone is interested can be found here; http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/ I have followed the instruction and added the few bits needed to make it work properly. However hence me beening here, it doesnt work. Im not overly familiar with the syntax of -> so maybe I am outputting the wrong name in the move_upload_file but the error I get on the server is Unable to move '/tmp/phpJnOkXP' to bla bla bla upload-new.php on line 126 Upload fail which is the move_upload line Here is my code <?php if( isset($_POST['uploadbtn']) ) { $folder = "{$_SERVER['DOCUMENT_ROOT']}/images/test/"; $fileName = $_FILES['newImage']['name']; $tmpName = $_FILES['image']['tmp_name']; include('../simple-image.php'); $image = new SimpleImage(); $image->load($tmpName); $image->resizeToWidth(600); $image->output(); $uploaded = move_uploaded_file($tmpName , $folder.$fileName); if($uploaded){ echo "Upload success"; } else { echo "Upload fail"; } } ?> <form action="" method="post" enctype="multipart/form-data" name="uploadfrm"> <input name="image" type="file" /> <input name="uploadbtn" value="Upload" type="submit" /> </form> I am trying to show images in a directory by date last modified. The code below is showing the oldest ones first then by file type. How do I modify it to show all files by last uploaded to the directory? I want the newest ones showing first. I am very new to PHP. Code: [Select] <?php //Your folder $files = glob("images/*.*"); $colCnt=0; echo '<table border="0" style="width:1000px;">'; for ($i=1; $i<count($files); $i++) { $colCnt++; if ($colCnt==1) echo '<tr>'; echo '<td width="20%" style="font-size:8.5px; font-family:arial">'; $num = $files[$i]; echo ' <a href="' . $num . '"><img class="thumb ImgBorder" src="'.$num.'" rel="lightbox" alt="random image"></a>'." "; echo '</td>'; if ($colCnt==6) { echo '</tr>'; $colCnt=0; } } echo '</table>'; ?> Hi Guys, Please can someone here help me with a simple browse for an image from the computer and then when the form is submitted it uploads the image and then saves the image url in my DB. my form page is here http://bit.ly/gntCvD Any help will be appreciated. thanks Craig I am using cakephp and i need a quick simple image upload and re-size script, can any one help? Hi, I'm trying to make a simple slideshow with forward and back buttons that change the image inside a div in php. When I press the "further" button, it jumps from index[0] to index[1] and never shows the first image. Then when I click more it doesn't go forward. When I click back, it goes back to a black screen div. Any help getting this to work is GREATLY appreciated because I've been trying for 2 days with tutorials and can't get it. Thanks. Derek Here are the php parts that are relevant, my page was too large and confusing to include. first, the $background array where I store my images. Code: [Select] $background = array ( "<img src='sundragon_environments/ocean/ocean1_FRAME.jpg'/>", "<img src='sundragon_environments/ocean/ocean1_FRAME2.jpg'/>" ); then the code to move the images forward and backwards if the buttons are pressed. Code: [Select] if(!empty($_POST['further'])) { $currentBackground=next($background); } elseif(!empty($_POST['back'])) { $currentBackground=prev($background); } and now to echo out the images inside the div. Code: [Select] <div id="background"><?php echo $currentBackground;?></div> This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=348759.0 Hi Guys I'm trying to get clients to: 1. upload an image 2. fill out details 3. submit image and details to me via email 1. Uploading the image is fine, they choose it and it displays on the next page 2. They fill in form details 3. then click submit to send to me - I get all details except the image How do I keep the image variable around to insert it into the details form and email it? The image appears to be displayed on the second page, then the variable disappears (is deleted) and isn't available in step 3 to submit as part of the email. I'm sure it's a simple fix - I'm pretty new with php and I've started kicking things so I thought it was time to ask for help. Upload-image-code <?php if($_FILES) { $img = $_FILES['filename']['img']; switch($_FILES['filename']['type']) { case 'image/jpeg' : $ext = 'jpg'; break; case 'image/png' : $ext = 'png'; break; default: $ext = ''; break; } if ($ext) { $n = "image.$ext"; move_uploaded_file($_FILES['filename']['tmp_name'], $n); echo "<span class='uploaded-photo'>uploaded image '$img' as '$n':</span> <br />"; echo "<img src='$n' />"; } else echo "'$img' is not a supported image file"; } //else echo "<span class='uploaded-photo'>No image has been uploaded</span>"; ?> $n is available to be displayed on page 2 and it works Page 2 contains the rest of the form, but when I submit the form $n isn't available to be sent with the other data (i have tried REQUEST $img as well. Submit form code <?php $name = $_REQUEST['name'] ; $email = $_REQUEST['email'] ; $phone = $_REQUEST['phone'] ; $address = $_REQUEST['address'] ; $pname = $_REQUEST['pname'] ; $pdescription = $_REQUEST['pdescription']; $plow = $_REQUEST['plow'] ; $phigh = $_REQUEST['phigh'] ; $purl = $_REQUEST['purl'] ; $ponline = $_REQUEST['ponline'] ; $n = $_REQUEST['n']; $img = $_REQUEST['img']; if (!isset($_REQUEST['email'])) { echo "we need your name and email address please" ; } elseif (empty($name)){ echo "please enter your name"; } elseif (empty($email)){ echo "please enter your email address"; } elseif (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,6})", "$email")) { echo"please check your email address - it doesn't appear to be a valid format"; } else { mail( "eamail@address.com", "Subject", "$name\n $email\n $phone\n $address\n $pname\n $pdescription\n $plow\n $phigh\n $purl\n $ponline\n $n\n $img", "$email"); header( "Location: ../index.php" ); } ?> Would really appreciate any help - if you need full code please let me know. Thanks @webecho Hi, I am planning to display remote images with the following code but it seems to return errors. <?php $image_dir = 'http://www.domain.com/images/' ; $dir_handle = opendir( $image_dir ); $count = 0 ; $display = '' ; while( $filename = readdir($dir_handle)){ if( preg_match( '/$[a-z0-9]{4}_th\.jpg$/' , $filename ) ){ $display .= " <img src='$image_dir$filename' /> " ; $count++ ; if( $count % 10 == 0 ){ $count=0; $display .= "<br />"; } } } closedir( $dir_handle ); echo $display ; ?> I am thinking might be the $image_dir cannot use address format.... Errors is as follow Quote Warning: opendir(http://www.foo.com/images/) [function.opendir]: failed to open dir: not implemented in /home/jch02140/public_html/test.php on line 3 Warning: readdir(): supplied argument is not a valid Directory resource in /home/jch02140/public_html/test.php on line 6 Warning: closedir(): supplied argument is not a valid Directory resource in /home/jch02140/public_html/test.php on line 16 I want when onmouseover on particular section to put an OPACITY #fff 0.2 layer on everything except the selected class i.e. table
Similarly as you have:
.tableHighlight:hover{background-color:#eee} <table id='table-main' class='tableHighlight'> ... but inversed (puts layer on everything else, but not the table itself) --- http://jsfiddle.net/LYcm9/1/ Visit: http://testowa.testy...e/testy-na-mocz (the behavior is going crazy). Has anybody got maybe any clue on how to fix it to work correctly?
Code itself. http://jsfiddle.net/LYcm9/5/
I have a very simple piece of code to create a grid based gallery. The thumbnails are loaded from a single directory and are name 1.jpg... 2.jpg... 3.jpg etc At the moment the images appear to be loaded in randomly. I want them to load in numerically in terms of their filename. I know I may need to use 'sort' or 'natsort' but where in the code? Thanks for any help you can give me Code: [Select] <? $images = "Images/Bag Thumbs/"; # Location of small versions $big = "ruxxwomens.php?id="; # Location of big versions (assumed to be a subdir of above) $cols = 4; # Number of columns to display if ($handle = opendir($images)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && $file != rtrim($big,"/")) { $files[] = $file; } } closedir($handle); } $colCtr = 0; echo '<table width="800" cellspacing="0" cellpadding="0" border="0"><tr>'; foreach($files as $file) { if($colCtr %$cols == 0) echo '</tr><tr>'; echo '<td align="center"><a href="' . $big . $file . '"><img src="' . $images . $file . '" cellspacing="0" cellpadding="0" border="0"></a></td>'; $colCtr++; } echo '</table>' . "\r\n"; ?> Hi everyone, I'm trying to select either a class or an id using PHP Simple HTML DOM Parser with absolutely no luck. My example is very simple and seems to comply to the examples given in the manual(http://simplehtmldom.sourceforge.net/manual.htm) but it just wont work, it's driving me up the wall. Here is my example: http://schulnetz.nibis.de/db/schulen/schule.php?schulnr=94468&lschb= I think the HTML is invalid: i cannot parse it. Well i need more examples - probly i have overseen something! If anybody has a working example of Simple-html-dom-parser...i would be happy. The examples on the developersite are not very helpful. your dilbertone Hello, im very green to php and I am having trouble creating a simple log in script. Not sure why this is not working, maybe a mysql_query mistake? I am not receiving any errors but nothing gets updated in the members table and my error message to the user displays. any help is appreciated! here is my php: <?php session_start(); $errorMsg = ''; $email = ''; $pass = ''; if (isset($_POST['email'])) { $email = ($_POST['email']); $pass = ($_POST['password']); $email = stripslashes($email); $pass = stripslashes($pass); $email = strip_tags($email); $pass = strip_tags($pass); if ((!$email) || (!$pass)) { $errorMsg = '<font color="#FF0000">Please fill in both fields</font>'; }else { include 'scripts/connect_db.php'; $email = mysql_real_escape_string ($email); $pass = md5($pass); $sql = mysql_query("SELECT * FROM members WHERE email='$email' AND password='$pass'"); $log_check = mysql_num_rows($sql); if ($log_check > 0) { while($row = mysql_fetch_array($sql)) { $id = $row["id"]; $_SESSION['id']; $email = $row["email"]; $_SESSION['email']; $username = $row["username"]; $_session['username']; mysql_query("UPDATE members SET last_logged=now() WHERE id='$id' LIMIT 1"); }//Close while loop echo "You are logged in"; exit(); } else { $errorMsg = '<font color="#FF0000">Incorrect login data, please try again</font>'; } } } ?> and the form: <?php echo $errorMsg; ?> <form action="log_in.php" method="post"> Email:<br /> <input name="email" type="text" /><br /><br /> Password:<br /> <input name="password" type="password" /><br /><br /> <input name="myBtn" type="submit" value="Log In" /> </form> Hi can someone pls help, im tryin a tutorial but keep getting errors, this is the first one i get after registering. You Are Registered And Can Now Login Warning: Cannot modify header information - headers already sent by (output started at /home/aretheyh/public_html/nealeweb.com/regcheck.php:43) in /home/aretheyh/public_html/nealeweb.com/regcheck.php on line 46 After image is drop into container , I want to move copy of the original image to be move when original image dragend within container. I tried but it display copy image each time when original image dragend. can anyone help me?
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Prototype</title> <script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script> <script src="http://d3lp1msu2r81bx.cloudfront.net/kjs/js/lib/kinetic-v4.7.2.min.js"></script> <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.min.js"></script> <style> body{padding:20px;} #container{ border:solid 1px #ccc; margin-top: 10px; width:350px; height:350px; } #toolbar{ width:350px; height:35px; border:solid 1px blue; } </style> <script> $(function(){ var $house=$("#house"); $house.hide(); var $stageContainer=$("#container"); var stageOffset=$stageContainer.offset(); var offsetX=stageOffset.left; var offsetY=stageOffset.top; var stage = new Kinetic.Stage({ container: 'container', width: 350, height: 350 }); var layer = new Kinetic.Layer(); stage.add(layer); var image1=new Image(); image1.onload=function(){ $house.show(); } image1.src="http://vignette1.wikia.nocookie.net/angrybirds/images/b/b6/Small.png/revision/latest?cb=20120501022157"; $house.draggable({ helper:'clone', }); $house.data("url","house.png"); // key-value pair $house.data("width","32"); // key-value pair $house.data("height","33"); // key-value pair $house.data("image",image1); // key-value pair $stageContainer.droppable({ drop:dragDrop, }); function dragDrop(e,ui){ var x=parseInt(ui.offset.left-offsetX); var y=parseInt(ui.offset.top-offsetY); var element=ui.draggable; var data=element.data("url"); var theImage=element.data("image"); var image = new Kinetic.Image({ name:data, x:x, y:y, image:theImage, draggable: true, dragBoundFunc: function(pos) { return { x: pos.x, y: this.getAbsolutePosition().y } } }); image.on("dragend", function(e) { var points = image.getPosition(); var image1 = new Kinetic.Image({ name: data, id: "imageantry", x: points.x+65, y: points.y, image: theImage, draggable: false }); layer.add(image1); layer.draw(); }); image.on('dblclick', function() { image.remove(); layer.draw(); }); layer.add(image); layer.draw(); } }); // end $(function(){}); </script> </head> <body> <div id="toolbar"> <img id="house" width=32 height=32 src="http://vignette1.wikia.nocookie.net/angrybirds/images/b/b6/Small.png/revision/latest?cb=20120501022157"><br> </div> <div id="container"></div> </body> </html> Edited by Biruntha, 08 January 2015 - 10:14 AM. The script for creating a new file name for the image:
$validextensions = array("jpeg", "jpg", "png"); //Extensions which are allowed $ext = explode('.', basename($_FILES['file']['name'][$i]));//explode file name from dot(.) $file_extension = end($ext); //store extensions in the variable $new_image_name = md5(uniqid()) . "." . $ext[count($ext) - 1]; $target_path = $target_path . $new_image_name;//set the target path with a new name of imageThe script creates a new file like: f6c9b8d9db05366c3504210cded9ddb2.jpgand moves the file to the "uploads" folder. And then the script also creates a thumbnail with the same file name and moves the file to the "thumbs" folder. The issue I am having is that the same ID code could happen again for a different image in the database, thus I would be calling a different original sized image than the thumbnail image. My question is: How to avoid this issue of the same ID code has happened again for a different file. What is the proper way to reference the anchor tag of the thumbnail image to its actual original sized image? With the script I have the thumbnail image would be coming from the "thumbs" folder and the anchor tag would get referenced to the "uploads" folder to get the original sized image. Edited by glassfish, 12 October 2014 - 05:51 AM. |