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).

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.