Blog

Photobucket

<?php

/**
 * photobucket
 *
 * Gets all the pictures from a Photobucket album.
 *
 * @version 0.2
 * @author Contributors at eXorithm
 * @link /algorithm/view/photobucket Listing at eXorithm
 * @link /algorithm/history/photobucket History at eXorithm
 * @license /home/show/license
 *
 * @param mixed $url Photobucket URL
 * @return mixed
 */
function photobucket($url='http://s283.photobucket.com/albums/kk285/konnarak_1608/romantic/')
{
	$str = file_get_contents($url);
	preg_match_all('/<img[^>]+>/i',$str, $result); 
	
	$strPics = "";
	foreach( $result as $img_tag) {
		foreach( $img_tag as $img) {
			if( !strpos($img, 'class="under off"') ) continue;
			preg_match('/< *img[^>]*src *= *["\']?([^"\']*)/i', $img, $imgURLs);
			$imgURL = str_replace("/th_", "/", $imgURLs[1]);
			$strPics .= $imgURL . "\n";
		}
	}
	return $strPics;
}

?>

eXorithm – Execute Algorithm: Discuss Algorithm round_corners

round_corners     version 0.2     Round the corners of an image. Transparency and anti-aliasing are supported.Subject: integration error

niwdalg posted: Dec 4, 2011 09:45 am [reply]

hi,

Can you help me in integrating this code? i am getting errors.

can you please give an example how this is integrated in image tag?

Subject: Image getting resized

Luciano Ziegler posted: Nov 3, 2011 01:27 pm [reply]

Hi,

Thank you very much for your code. Finally I could get the transparency working on my thumbnails. The only problem is that the script is returned the images in a different size. I send thumbnails on 150px/150px and it returns an image with 214px/214px.

Any idea on how to fix this?

Thanks

Luciano Ziegler posted: Nov 3, 2011 01:30 pm [reply]

My bad. It was my fault. Your script works perfect 😀

New Comment

eXorithm – Execute Algorithm: View / Run Algorithm swirl_image

function swirl_image ($image, $iterations, $angle
{
  $height = imagesy$image);
  $width = imagesx$image);
  
  $new_image = imagecreatetruecolor$width, $height);
  $iterations = max(1, $iterations);
  
  $wstep = ($width/2)/($iterations+1);
  $hstep = ($height/2)/($iterations+1);
  
  for ($ii=0;$ii$iterations$ii++) {
    $w = $width - ($ii+1)*$wstep*2;
    $h = $height - ($ii+1)*$hstep*2;
    $images$ii] = imagecreatetruecolor$w, $h);
    imagecopy$images$ii], $image, 0, 0, ($ii+1)*$wstep, ($ii+1)*$hstep, $w, $h);
    $images$ii] = rotate_image_alpha$images$ii], $angle*($ii+1), 'ffffff', 127);
  }
  
  for ($ii=0;$ii$iterations$ii++) {
    // Set the brush
    imagesetbrush$image, $images$ii]);
    // Draw a couple of brushes, each overlaying each
    imageline$image, imagesx$image) / 2, imagesy$image) / 2, imagesx$image) / 2, imagesy$image) / 2, IMG_COLOR_BRUSHED);
  }
  
  return $image
} 

eXorithm – Execute Algorithm: Embed Algorithm draw_cube


Embed This Algorithm

This page will help you embed the algorithm draw_cube on a page on your own website. Just configure the inputs, then click the generate button to get a snippet of code you can paste onto your site. You have two options.

  1. You can embed the entire form. Users will be able to enter their own arguments, and will need to press the run button to execute the algorithm.
  2. You can add only the output of the algorithm to your website. There will be no argument inputs or run button.

image size Argument info
degree x Argument info
degree y Argument info
degree z Argument info
vdist Argument info
dist Argument info
vertex color Argument info
face color Argument info
wireframe Argument info
dashes Argument info
rainbow Argument info
Embed the form Embed only the output

eXorithm – Execute Algorithm: View / Run Algorithm duotone_image

function duotone_image ($image$rplus$gplus$bplus$pcnt
{
  // Adapted from http://www.tuxradar.com/practicalphp/11/2/21
  
  $imagex = imagesx$image);
  $imagey = imagesy$image);
  
  $image2 = imagecreatetruecolor$imagex$imagey);
  imagesavealpha$image2, true);
  imagealphablending$image2, false);
  
  for ($x = 0; $x <$imagex; ++$x) {
    for ($y = 0; $y <$imagey; ++$y) {
      $rgb = imagecolorat$image$x$y);
      $color = imagecolorsforindex$image$rgb);
      $grey = floor(($color'red']+$color'green']+$color'blue'])/3);
      if ($pcnt) {
        $red = $grey + $grey*($rplus/150);
        $green = $grey + $grey*($gplus/150);
        $blue = $grey + $grey*($bplus/150);
      } else {
        $red = $grey + $rplus
        $green = $grey + $gplus
        $blue = $grey + $bplus
      }
      
      if ($red > 255) $red = 255;
      if ($green > 255) $green = 255;
      if ($blue > 255) $blue = 255;
      if ($red < 0) $red = 0;
      if ($green < 0) $green = 0;
      if ($blue < 0) $blue = 0;
      
      $newcol = imagecolorallocatealpha$image2$red$green$blue$color'alpha']);
      imagesetpixel ($image2$x$y$newcol);
    }
  }
  
  return $image2

eXorithm – Execute Algorithm: View / Run Algorithm frame_picture

function frame_picture ($image$thickness
{
  $color = get_average_color$image);
  
  $image2 = imagecreatetruecolorimagesx$image)+$thickness$thickness
                                 imagesy$image)+$thickness$thickness);
  
  $r  = hexdecsubstr$color, 0, 2));
  $g  = hexdecsubstr$color, 2, 2));
  $b  = hexdecsubstr$color, 4, 2));
  
  $color = imagecolorallocate$image2$r$g$b);
  
  imagefilledrectangle$image2, 0, 0, imagesx$image2)-1, imagesy$image2)-1, $color);
  
  imagecopy$image2$image$thickness$thickness, 0, 0, imagesx$image)-1, imagesy$image)-1);
  
  return $image2

eXorithm – Execute Algorithm: View / Run Algorithm country_population_graph

function country_population_graph ($country_list$data_source
{
  # ------- The external data comes from elsewhere, load it....
  if ($data_source=='geonames') {
    $valuesgeonames_populations$country_list);
  } else if ($data_source=='freebase') {
    $valuesfreebase_populations$country_list);
  } else {
    $valuesxithm_world_stats_population$country_list);
  }
  
  ksort$values);
  
  // how much rounding to do for the numbers on the y-axis
  $zeroes = strlen""roundmax$values)))-2;
  
  $divs = roundmax$values)/10, $zeroes*-1);
  
  $chrt = new stdClass
  
  $chrt->cht = "bvs"
  $chrt->chds = "0,"max$values);
  $chrt->chxt = "x,y"
  $chrt->chs = "600x300"
  $chrt->chbh = "a"
  $chrt->chxr = "1,0,"max$values).","$divs
  $chrt->chxl="0:|"implode"|"array_keys$values));
  $chrt->chd = "t:"implode","$values);
  
  return $chrt