Jump to content

Remove images by size


kristallaju

Recommended Posts

Certainly, the getimagesize function should suffice for your requirements.

 

<?php
$size = getimagesize($path);

if($size[0] < 10 || $size[1] < 10) {
  // it's too small
} else {
  // it's fine
}
?>

 

&& would probably be better to use otherwise something that's like 9X100 would get deleted which isn't what the OP wanted (at least from what I can tell).

Ok basically its great solution but how to put it in my script

 

<?php

function rewriter( $body, $case_sensitive=false ) {

include "inc/synodb.php";
include "inc/config.php";
include "inc/badword.php";



$synlist=$body;
	 $synchar = array("(", ")", "[", "]", "?", ".", ",", "|", "\$", "*", "+", "^", "{", "}");
	 $synlist=str_replace($synchar," ",$synlist);
	 $synlist=str_replace("  "," ",$synlist);
	 $my_synlist = explode(" ",$synlist);
         $body = preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $body);
         $body =  preg_replace('/\b('.implode('|',$badword).')\b/','',$body);


	if (sizeof($my_synlist)>0)
	{

	for($i=0;$i<sizeof($my_synlist);$i++)
		{

		$synorand = rand(1,100);
		if($synorand < $percsyno)

			{

			$syn_replace=$my_synlist[$i];
			$syn_replace=str_replace(" ","",$syn_replace);

			$syn_replace=" ".$syn_replace." ";

			$syn_replace_target=$syndb[$syn_replace];



			if(($syn_replace!="")&&($syn_replace!=" ")&&($syn_replace_target!=""))
				{

				$body = str_replace($syn_replace,$syn_replace_target,$body);

				}

			}
		}
	}

return $body;
}


?>

 

ok i managed to make it remove non acii characters and predefined words but dont get how to get it to work with your script?

I think your gonna have to be clearer about what your trying to do. When you mentioned removing images, we assumed you meant removing actual images, but the more you talk the less likely it seems this is what you want to do. It appears now that you wish to parse HTML text, and remove the <img /> tag for any image that has a width or height (or some combination) below a certain value. Is this the case? If it is, to what purpose? Where are you getting the HTML from initially?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.