IMPORTANT!

Snipt is going open source. We've toyed with this idea for quite a while, and have finally decided it's the right way to move forward.

A few things:
  • The entire Snipt source code will be released on GitHub under the 3-clause BSD License on Friday, September 10th.
  • While we'd like to think we're perfect, we realize we're only human. By open sourcing the software that runs this website, certain bugs or security flaws may be discovered that could compromise the privacy of your snipts.
  • Only the Lion Burger team will be able to push commits to the Snipt.net site. Contributors should send a pull request to add new features or submit patches.
  • By using this site, you agree not to be too angry or take any legal action against Lion Burger should this whole thing go up in flames some day.
  • Follow us on Twitter for updates.
I agree, close this message
Sign up to create your own snipts, or login.

Latest 100 public snipts » image The latest public image snipts.

showing 1-20 of 33 snipts for image
  • convert pdf to png with a background color at 300 dpi
    inkscape -d 300 -D -z -e moments.png -b '#FFFFFF' moments.pdf
    

    copy | embed

    0 comments - tagged in  posted by tlevine on Aug 10, 2010 at 5:34 p.m. EDT
  • Batch resize images
    mogrify -resize <800>x<600> <*.ext>
    

    copy | embed

    0 comments - tagged in  posted by marianosimone on Jul 02, 2010 at 9:06 p.m. EDT
  • image link con target _blank
    <? 
    $img_path = "images/arr_leggi_blu.gif"; 
    $link_path = "node/47";
    $theme_name = 'pmsth';
    
    $options = array(
        'attributes' => array(
            'target' => '_blank',
        ),
        'html' => true,
    );
    
    $img = theme('image',  drupal_get_path('theme', $theme_name). "/$img_path"); 
    print l($img, $link_path, $options);
    
    ?>
    

    copy | embed

    0 comments - tagged in  posted by allaterza on Jun 17, 2010 at 11:27 a.m. EDT
  • create CAPTCHA
    <?php	
    // download jpgraph http://www.aditus.nu/jpgraph/
      ini_set('include_path', ini_get('include_path').';D:\xmapp\xampp\htdocs\php\jpgraph-3.0.7\src');
      require_once "jpgraph_antispam.php";
      $spam = new AntiSpam();
      //$chars = $spam->Rand(6);
      $spam->set("mystring");
      $spam->Stroke();
    ?>
    

    copy | embed

    0 comments - tagged in  posted by paranoid on May 25, 2010 at 2:30 a.m. EDT
  • prevent the hotlinking of images
    <?php
      // setting in http.conf file. 
      SetEnvIfNoCase Referer "^http://www\.sitepoint\.com/" locally_linked=1
      SetEnvIfNoCase Referer "^http://sitepoint\.com/" locally_linked=1
      SetEnvIfNoCase Referer "^$" locally_linked=1
      <FilesMatch "\.(gif|png|jpe?g)$">
        Order Allow,Deny
        Allow from env=locally_linked
      </FilesMatch>
    ?>
    

    copy | embed

    0 comments - tagged in  posted by paranoid on May 25, 2010 at 2:01 a.m. EDT
  • add a watermark to an image
    <?php
    // text watermark
      $image = imagecreatefromjpeg('test.jpg');
      $color = imagecolorallocate($image, 68, 68, 68);
      imagestring($image, 5, 90, 0, "Abbey '07", $color);
      header('Content-Type: image/jpg');
      imagejpeg($image);
    
    // image watermark
      $image = imagecreatefromjpeg('test.jpg');
      $iWidth = imagesx($image);
      $watermark = imagecreatefrompng('watermark.png');
      $wmWidth = imagesx($watermark);
      $wmHeight = imagesy($watermark);
      $xPos = $iWidth - $wmWidth;
      imagecopymerge($image, $watermark, $xPos, 0, 0, 0,$wmWidth, $wmHeight, 100);
      header('Content-Type: image/jpg');
      imagepng($image);
    ?>
    

    copy | embed

    0 comments - tagged in  posted by paranoid on May 24, 2010 at 11:44 a.m. EDT
  • how php thumbnail a image?
    <?php
      $sourceImage = 'source.jpg';
      $thumbWidth = 200;
      $thumbHeight = 200;
      $original = imagecreatefromjpeg($sourceImage);
      $dims = getimagesize($sourceImage);
      if( $dims[0] > $dims[1] ) {
      	$thumbHeight = floor( $dims[1]*( $thumbWidth/$dims[0]) );  	 
      }else if( $dims[0] < $dims[0] )  {
      	$thumbWidth = floor( $dims[0]*($thumbHeight/$dims[1]) );
      }
      $thumb = imagecreatetruecolor($thumbWidth,$thumbHeight);
      imagecopyresampled( $thumb, $original, 0, 0, 0, 0,$thumbWidth, $thumbHeight, $dims[0], $dims[1] );
      header( "Content-type: image/jpeg" );
      imagejpeg( $thumb );
    ?>
    

    copy | embed

    0 comments - tagged in  posted by paranoid on May 24, 2010 at 9:54 a.m. EDT
  • Magicfields duplicate image fields
    <?php 
    							
    							$images = getFieldOrder('gallery_pic');
    													
    							foreach ($images as $image) { 
    							$my_image_url = get('gallery_pic',1,$image);	
    							//print $my_image_url;
    							?>
    
    							<li>
    							<a href="<?php echo $my_image_url; ?>" rel="overlay">
    							<?php
    							  // $title = get_the_title();
    							   $img_phpthumb = array ("w" => 56, "h" => 56, "zc" => 1);  
    							   $img_htm = array("alt" => "event thumbnail", "class" => "left event-thumb" );
    							   echo gen_image('gallery_pic',1,$image,$img_phpthumb,$img_htm); ?>
    							</a>
    							</li>
    							
    							<?php   
    							}
    							?>		
    

    copy | embed

    0 comments - tagged in  posted by panprojektant on May 09, 2010 at 6:11 p.m. EDT
  • IMG Hover Opacity
    a:hover img {
    	opacity: .75;
    }
    

    copy | embed

    0 comments - tagged in  posted by m on May 08, 2010 at 7:56 p.m. EDT
  • Magicfields gen_image
    <?php
           $title = get_the_title();
           $img_phpthumb = array ("w" => 189, "h" => 130, "zc" => 1);
           $img_htm = array("alt" => "event thumbnail", "class" => "left event-thumb", "title" => $title );
           echo gen_image('event_thumbnail',1,1,$img_phpthumb,$img_htm); ?>
    

    copy | embed

    0 comments - tagged in  posted by panprojektant on Apr 28, 2010 at 5:56 p.m. EDT
  • Toggle child table row with button in parent table row
    //html markup
    <tr class="note_parent">
    <td><a href="#"><img src="your toggle image" alt="toggle" style="display:none;" /></a></td>
    </tr>
    
    <tr class="add_note" style="display:none;">
    <td>hidden content</td>
    </tr>
    
    //jQuery functions
    $("tr.note_parent").hover(function() {
    		$(this).find("a img").css("display", "inline");
    	},
    	function() {
    		$(this).find("a img").css("display", "none");
    });
    $("tr.note_parent a img").click(function() {											 
      $(this).parents("tr:first").next("tr.add_note").css("display", "table-row");		
    		return false;
    });
    

    copy | embed

    0 comments - tagged in  posted by vagrantradio on Mar 31, 2010 at 9:33 a.m. EDT
  • Hi Quality Image Resizing in C#.NET
    using System;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Drawing.Imaging;
    using System.IO;
    
    public class ImageProcessing
    {
        public static Bitmap ResizeImage(Bitmap image, int pixelWidth, int pixelHeight, int compressionQuality)
        {
            // Bully compression quality in range 1 to 100
            if (compressionQuality < 1)
            {
                compressionQuality = 1;
            }
            if (compressionQuality > 100)
            {
                compressionQuality = 100;
            }
    
            Bitmap tempImage = new Bitmap(pixelWidth, pixelHeight, PixelFormat.Format32bppArgb);
            tempImage.SetResolution(image.HorizontalResolution, image.VerticalResolution);
    
            Graphics g = Graphics.FromImage(tempImage);
            g.InterpolationMode = InterpolationMode.HighQualityBicubic;
            g.PixelOffsetMode = PixelOffsetMode.HighQuality;
            g.SmoothingMode = SmoothingMode.HighQuality;
    
            g.DrawImage(image,
                new Rectangle(0, 0, pixelWidth, pixelHeight),
                new Rectangle(0, 0, image.Width, image.Height),
                GraphicsUnit.Pixel);
            g.Dispose();
    
            ImageCodecInfo jpegCodec = null;
    
            foreach (ImageCodecInfo codec in ImageCodecInfo.GetImageEncoders())
            {
                if (codec.MimeType == "image/jpeg")
                {
                    jpegCodec = codec;
                }
            }
    
            EncoderParameters encoderParams = new EncoderParameters(1);
            EncoderParameter quality = new EncoderParameter(Encoder.Quality, (long)compressionQuality);
            encoderParams.Param[0] = quality;
    
            Stream imageStream = new MemoryStream();
            tempImage.Save(imageStream, jpegCodec, encoderParams);
    
            Bitmap finalImage = new Bitmap(imageStream);
    
            // Clean up resources
            g.Dispose();
            tempImage.Dispose();
    
            return finalImage;
        }
    }
    

    copy | embed

    0 comments - tagged in  posted by Sironfoot on Mar 04, 2010 at 7:52 p.m. EST
  • image link
    <? 
    $img_path = "images/arr_leggi_blu.gif"; 
    $link_path = "node/47";
    $theme_name = 'pmsth';
    
    $img = theme('image',  drupal_get_path('theme', $theme_name). "/$img_path"); 
    print l($img, $link_path, array('html' => true));
    
    ?>
    

    copy | embed

    0 comments - tagged in  posted by allaterza on Feb 06, 2010 at 6:24 a.m. EST
  • image
    <? 
    $path = "images/arr_leggi_blu.gif"; 
    $theme_name = 'pmsth';
    
    print theme('image',  drupal_get_path('theme', $theme_name). "/$path");
    ?>
    

    copy | embed

    0 comments - tagged in  posted by allaterza on Feb 06, 2010 at 6:13 a.m. EST
  • ASCII image via PHP
    <?php
     
    function image2ascii( $image )
    {
        // return value
        $ret = '';
     
        // open the image
        $img = ImageCreateFromJpeg($image); 
     
        // get width and height
        $width = imagesx($img);
        $height = imagesy($img); 
     
        // loop for height
        for($h=0;$h<$height;$h++)
        {
            // loop for height
            for($w=0;$w<=$width;$w++)
            {
                // add color
                $rgb = ImageColorAt($img, $w, $h);
                $r = ($rgb >> 16) & 0xFF;
                $g = ($rgb >> <img src='http://www.sastgroup.com/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> & 0xFF;
                $b = $rgb & 0xFF;
                // create a hex value from the rgb
                $hex = '#'.str_pad(dechex($r), 2, '0', STR_PAD_LEFT).str_pad(dechex($g), 2, '0', STR_PAD_LEFT).str_pad(dechex($b), 2, '0', STR_PAD_LEFT);
     
                // now add to the return string and we are done
                if($w == $width)
                {
                    $ret .= '';
                }
                else
                {
                    $ret .= '<span style="color:'.$hex.';">#</span>';
                }
            }
        }
        return $ret;
    }
     
    //ESEMPIO APPLICATO
     
    // an image to convert
    $image = 'test.jpg';
     
    // do the conversion
    $ascii = image2ascii( $image );
     
    // and show the world
    echo $ascii; 
     
    ?>
    

    copy | embed

    0 comments - tagged in  posted by azote on Nov 03, 2009 at 4:24 a.m. EST
  • Random Image
    <?php
    
    $folder = 'images/';
    
    $extList = array();
    $extList['gif'] = 'image/gif';
    $extList['jpg'] = 'image/jpeg';
    $extList['jpeg'] = 'image/jpeg';
    $extList['png'] = 'image/png';
    
    $img = null;
    
    if (isset($_GET['img'])) {
    	$imageInfo = pathinfo($_GET['img']);
    
    	if (isset($extList[strtolower($imageInfo['extension'])]) && file_exists($folder.$imageInfo['basename']))
    		$img = $folder.$imageInfo['basename'];
    } else {
    	$fileList = array();
    	$handle = opendir($folder);
    
    	while (false !== ($file = readdir($handle))) {
    		$file_info = pathinfo($file);
    		if (isset( $extList[ strtolower( $file_info['extension'])])) {
    			$fileList[] = $file;
    		}
    	}
    	closedir($handle);
    
    	if (count($fileList) > 0) {
    		$imageNumber = time() % count($fileList);
    		$img = $folder.$fileList[$imageNumber];
    	}
    }
    
    if ($img!=null) {
    	$imageInfo = pathinfo($img);
    	$contentType = 'Content-type: '.$extList[ $imageInfo['extension'] ];
    	header($contentType);
    	readfile($img);
    } else {
    	if (function_exists('imagecreate')) {
    		header ("Content-type: image/png");
    		$im = @imagecreate (100, 100) or die ("Cannot initialize new GD image stream");
    		$background_color = imagecolorallocate ($im, 255, 255, 255);
    		$text_color = imagecolorallocate ($im, 0,0,0);
    		imagestring ($im, 2, 5, 5,  "IMAGE ERROR", $text_color);
    		imagepng ($im);
    		imagedestroy($im);
    	}
    }
    

    copy | embed

    0 comments - tagged in  posted by Sirupsen on Sep 24, 2009 at 3:13 p.m. EDT
  • Automatically resize an image to max width/height and keep aspect ratio.
            $image = "directory/imagename.ext"; // Location/name of image
            $max_width = "250"; // Max width to display image
            $max_height = "250"; // Max height to display image
             
            list($width, $height) = getimagesize($image);
            $scale = min($max_width/$width, $max_height/$height);
             
            if ($scale < '1') {
                $scale_width = floor($scale * $width);
                $scale_height = floor($scale * $height);
            } else {
                $scale_width = $width;
                $scale_height = $height;
            }
             
            echo "
            <img border=\"0\" src=\"directory/imagename.ext\" width=\"" . $scale_width . "\" height=\"" . $scale_height . "\" />";
    

    copy | embed

    0 comments - tagged in  posted by Webline on Aug 16, 2009 at 11:00 a.m. EDT
  • jQuery hover image swap
    <script type="text/javascript">
    $(function() {
        $("img.swap").hover(
            function () {
            	$(this).attr("src", $(this).attr("src").replace(/.jpg/, "_swap.jpg"));
    		$(this).attr("src", $(this).attr("src").replace(/.gif/, "_swap.gif"));			
            },
            function () {
            	$(this).attr("src", $(this).attr("src").replace(/_swap.jpg/, ".jpg"));
            	$(this).attr("src", $(this).attr("src").replace(/_swap.gif/, ".gif"));			
            }
        );
    });
    </script>
    

    copy | embed

    4 comments - tagged in  posted by 44sunsets on Jul 23, 2009 at 12:47 a.m. EDT
  • get image header information
    identify -verbose
    

    copy | embed

    0 comments - tagged in  posted by oz on Jun 24, 2009 at 2:14 p.m. EDT
  • Grab image files from directory
    <?php
    $files=glob("path/to/directory/*.jpg*", GLOB_NOSORT);
    
    $firstfile=reset($files);
    
    echo "<ul id=\"rotator\">\n";
    	foreach($files as $file){
    			if($firstfile==$file){
    				echo "\t<li class=\"show\"><a href=\"#\"><img src=\"".$file."\" width=\"\" height=\"\" alt=\"\" /></a></li>\n";
    			}else{
    				echo "\t<li><a href=\"#\"><img src=\"".$file."\" width=\"\" height=\"\" alt=\"\" /></a></li>\n";
    			}
    	}
    echo "</ul>\n";
    ?>
    

    copy | embed

    0 comments - tagged in  posted by dmoore on May 30, 2009 at 4:04 p.m. EDT
Sign up to create your own snipts, or login.