Skip to content

Instantly share code, notes, and snippets.

@navinpai
Created May 20, 2012 17:11
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save navinpai/2758794 to your computer and use it in GitHub Desktop.
Save navinpai/2758794 to your computer and use it in GitHub Desktop.
Remove watermark/link from 9GAG Images
<?php
// Got bored/bugged of seeing the watermarks/Link at the bottom of 9GAG images. So wrote this script to remove them
// Eg. http://d24w6bsrhbeh9d.cloudfront.net/photo/4216213_700b_v1.jpg
// Very very basic PHP, but gets stuff done!
// Coded while listening to: http://8tracks.com/jkurtis/we-ll-run-wild :D
// USAGE: Put all pics in a 'pics' folder and create an empty 'crop' folder. Run Script. Enjoy. :D
$count=0;
echo "<h6>STARTED</h6>";
foreach(glob('pics/{*.jpg,*.jpeg,*.png}', GLOB_BRACE) as $image)
{
$count++;
echo '<p>'.$image;
list($width, $height) = getimagesize($image);
$ext = substr(strrchr($image, '.'), 1);
$cropW = $width;
$cropH = $height-40;
if($ext =='jpeg'||$ext =='jpg')
$origimg = imagecreatefromjpeg($image);
else if ($ext=='png')
$origimg = imagecreatefrompng($image);
$cropimg = imagecreatetruecolor($cropW,$cropH);
// Actual Crop Code
imagecopyresized($cropimg, $origimg, 0, 0, 0, 0, $width, $height, $width, $height);
//Save Cropped Image
if($ext =='jpeg'||$ext =='jpg')
{
$savefile='crop/'.basename($image);
imagejpeg($cropimg,$savefile);
}
else if ($ext=='png')
{
$savefile='crop/'.basename($image);
imagepng($cropimg,$savefile);
}
echo '-->'.$savefile.'</p>';
imagedestroy($cropimg);
imagedestroy($origimg);
}
echo '<h6>DONE WITH '.$count.' IMAGES</h6>';
?>
@sirinibin
Copy link

its not workin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment