Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@sirinibin sirinibin commented Mar 2, 2017

its not workin

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