Jump to content

Craig Hopson

Members
  • Posts

    212
  • Joined

  • Last visited

Everything posted by Craig Hopson

  1. ok i now have this function so when uploads are made it will reduce the image file size (a little) and create a thumbnail does it all look ok?? function converttojpg($originalimg){$filetype = @end(explode(".", $originalimg));if (strtolower($filetype) == 'jpg' or strtolower($filetype) == 'jpeg') { $srcImg = imagecreatefromjpeg($originalimg); imagejpeg($srcImg,$originalimg,75); imagedestroy($srcImg); }if (strtolower($filetype) == 'png') { $srcImg = imagecreatefrompng($originalimg); imagejpeg($srcImg,$originalimg,100); imagedestroy($srcImg); $NewName = str_replace(".png",".jpg",$originalimg); rename($originalimg,$NewName); }if (strtolower($filetype) == 'gif') { $srcImg = imagecreatefromgif($originalimg); imagejpeg($srcImg,$originalimg,100); imagedestroy($srcImg); $NewName = str_replace(".gif",".jpg",$originalimg); rename($originalimg,$NewName); } $thumb_img = imagecreatefromjpeg($NewName); $origw=imagesx($thumb_img);$origh=imagesy($thumb_img);$new_w = 120;$diff=$origw/$new_w;$new_h=$new_w;$dst_img = imagecreate($new_w,$new_h);imagecopyresized($dst_img,$thumb_img,0,0,0,0,$new_w,$new_h,imagesx($thumb_img),imagesy($thumb_img));$ONLYname = str_replace('uploads/'.$_COOKIE['id'].'/',"",$NewName);imagejpeg($dst_img, 'uploads/'.$_COOKIE['id'].'/thumbnail/'.$ONLYname);} Seems to be working ok only problem is the thumbnails are VERY poor quality any ideas??
  2. Scrap this anyone got a function that takes the ordinal image changes it to thumbnail and saves the output to thumbnail directory
  3. <IMG SRC="thumbnail.php?img=full_image.jpg"> do you have an example of this?The thumbnail.php script I did try but it seem to take long time to load
  4. Thanks guys you've done it again and answered my questions Thank you :Happy:
  5. i found this function ReduceImage($img){$img = file_get_contents ("$img");$im = imagecreatefromstring ($img);header ("Content-Type: image/jpeg"); imageJPEG ($im,NULL,10);imageDestroy ($im);} but when i use it on my site i get cant modify headers and if i remove the "header ("Content-Type: image/jpeg");" line i get the binary data back
  6. if i had 100 photos on my site all 1Mb in size and displayed them as thumbnails by this method echo '<img src="'.$row['img'].'" height="100px" width="100px">'; it would be a 100Mb web page????is there a way to reduce quality on the fly i tried $im = imagecreatefromjpeg($row['img']);imagejpeg($im, NULL, 60); but this just outputs the LOADS of random code....
  7. nop just use a plane text editor you will learn more
  8. hi guys i have a image 100x100 in the top corners i want rotate icons i cant get the inline styles right please help this is the code (sorry its a mess) echo '<li><div><div style="padding-top:10px;"><a href="index.php?x=rotate&img=uploads/'.$id.'/'.$file.'&rot=90&place='.$file.'" style="position: relative; left: 5px; top: 5px;"><img src="images/rotatec.png" style="border:0px;"></a> <a href="index.php?x=photoview&img='.$path.'"><img src="uploads/'.$id.'/'.$file.'" style="border:5px groove lightblue;" height="100px" width="100px"/></a> <a href="index.php?x=rotate&img=uploads/'.$id.'/'.$file.'&rot=-90&place='.$file.'" style="position: relative; right: 5px; top: 5px;"><img src="images/rotate.png" style="border:0px;"></a> </div></div><div><a href="delete.php?type=img&id='.$id.'&file='.$file.'"><img src="images/delete.png" style="border:0px"></a><a href="index.php?x=share&img=uploads/'.$id.'/'.$file.'&from='.$email.'"><img src="images/share.png" style="border:0px"></a></div></li>';
  9. cos that was the only way i could get it to do what i wanted
  10. yes there is another variable $ext holding the extension thanks i have sorted it like this $filenameA = time() . '_'.$filename;$filename = $filenameA;
  11. hi bit different problem but same topic so here goes, this code will change Avatar.png to Avatar1339516953.png $filename .= time(); how would i get 1339516953_Avatar.png
  12. Thanks do you have example
  13. ok i done this is it correct or is there a better way?? $srcImg = imagecreatefrompng($originalimg); imagejpeg($srcImg,$originalimg,100); imagedestroy($srcImg); $NewName = str_replace(".png",".jpg",$originalimg); rename($originalimg,$NewName);
  14. yes i looked at that but if the file name changes like $originalimg = $_GET['img']; $srcImg = imagecreatefrompng($originalimg); imagejpeg($srcImg,$originalimg,100); imagedestroy($srcImg); how would i just change the extension from .png to .jpg but keep the file name the same
  15. hi guys have this code which works file but i need to rename the file after its converted (xxxx.png to xxxx.jpg) $originalimg = test.png$srcImg = imagecreatefrompng($originalimg); imagejpeg($srcImg,$originalimg,100); imagedestroy($srcImg);
  16. Basically if the image being shown is upside down I have a rotate function in PHP but I need to know what photo is on the screen before I can call the rotate function
  17. hi guys i have this line off code witch slideshows photos i want to set the current photo file name to be set as a PHP variable bglayer.stop(true,true).css({opacity:1, zIndex:999}).empty().append($('<img src="'+imagesarr[i].src+'" />').css(this.scaleimage(imagesarr[i]))) Like this maybe bglayer.stop(true,true).css({opacity:1, zIndex:999}).empty().append($('<img src="'+imagesarr[i].src+'" /><? $FileName ='+imagesarr[i].src+';?>').css(this.scaleimage(imagesarr[i]))) I REALLY DONT UNDERSTAND JAVASCRIPT AT ALL please help
  18. Thanks this may just do it!!
  19. How can i reduce image file size using PHP
  20. ok so users can upload photos to my site the problem i have is space i'm cool with photo's upto 1 Mb but not any bigger how can i reduce the file size,the other problem i have is file type it could be any of the following jpeg, bmp, png or gif, I have searched Google for about an hour with no luck... Thanks
  21. hi guys i have this function to rotate images function rotate($img,$rot){//get the detail of the image $imageinfo=getimagesize($img); switch($imageinfo['mime']) { //create the image according to the content type case "image/jpg": case "image/jpeg": case "image/pjpeg": //for IE $src_img=imagecreatefromjpeg("$img"); break; case "image/gif": $src_img = imagecreatefromgif("$img"); break; case "image/png": case "image/x-png": //for IE $src_img = imagecreatefrompng("$img"); break; } //rotate the image according to the spcified degree $src_img = imagerotate($src_img, $rotation, 0); //output the image to a file imagejpeg ($src_img,$img);} i know how to call it "rotate($img,$rotation)" but how do i USE it <img src="uploads/'.$id.'/'.$file.'" style="border:5px groove lightblue;" height="100px" width="100px"/><a href="rotate(uploads/'.$id.'/'.$file.',90)" >Rotate 90</a> I KNOW THE LAST CODE IS WRONG BECAUSE WE CANT USE SERVERSIDE FUNCTIONS BROWSER SIDEbut how is it done correctly Thanks
  22. hi i have 2 errors on my site and i cant find them 72 attempt to find a semi-colon before the property name. add it 72 Property progid doesn't exist : DXImageTransform Line 72 is this <div id="nav"> <ul> <li <? if($_SERVER['QUERY_STRING'] == ''){echo 'id="current"';}?>><a href="index.php">Home</a></li> <li <? if($_SERVER['QUERY_STRING'] == 'x=login'){echo 'id="current"';}?>><a href="index.php?x=login">Login</a></li> <li <? if($_SERVER['QUERY_STRING'] == 'x=register'){echo 'id="current"';}?>><a href="index.php?x=register">Register</a></li> <li <? if($_SERVER['SCRIPT_NAME'] == 'x=contact'){echo 'id="current"';}?>><a href="contact.php">Contact</a></li> <li <? if($_SERVER['QUERY_STRING'] == 'x=about'){echo 'id="current"';}?>><a href="index.php?x=about">About</a></li> <?php////////////////////////////////////////////////////////////////////////////LINE 72///////////////////////////////////////////////////////////// if (isset($id)){ ?> <li <? if($_SERVER['QUERY_STRING'] == 'x=menu'){echo 'id="current"';}?>><a href="index.php?x=menu">Menu</a></li> <li style="float:right"><a href="logout.php">Logout</a></li> <? } ?> </ul> below is the error http://jigsaw.w3.org/css-validator/validator?uri=http%3A%2F%2Fchsites.co.uk%2Ftest2%2Findex.php
  23. ok i read the full tutorial and i didnt understand much of it at all
×
×
  • Create New...